This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir terraform-gitops-example | |
cd terraform-gitops-example | |
terraform init | |
Create Terraform Configuration File (main.tf): | |
provider "aws" { | |
region = "us-west-1" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data "aws_autoscaling_groups" "app" { | |
filter { | |
name = "tag:id" | |
values = ["app-asg"] | |
} | |
} | |
module "asg-app" { | |
source = "../modules/asg/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Codedeploy main.tf | |
resource "aws_iam_role" "codedeploy_service_role" { | |
name = "codedeploy_service_role" | |
assume_role_policy = jsonencode({ | |
Version = "2012-10-17", | |
Statement = [ | |
{ | |
Action = "sts:AssumeRole", | |
Effect = "Allow", | |
Principal = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform refresh | |
# setting variables for auto scaling groups and policies location in state file | |
asg_location=module.asg.aws_autoscaling_group.id[0] | |
# checking the status of asgs in terraform state if there are changes then the new asg will be imported in place of that | |
# importing the updates in asg | |
terraform state show $asg_location | grep $(terraform output -raw asg_name) > /dev/null 2>&1 | |
if [ $? != 0 ] | |
then | |
terraform state rm $asg_location |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform state show $asg_location | grep $(terraform output -raw asg_name) > /dev/null 2>&1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: v1 | |
kind: ServiceAccount | |
metadata: | |
annotations: | |
eks.amazonaws.com/role-arn: arn:aws:iam::234543234:role/secret-iam-role | |
name: external-secrets-sa | |
namespace: external-secrets |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install external secrets | |
helm repo add external-secrets https://charts.external-secrets.io | |
helm install external-secrets \ | |
external-secrets/external-secrets \ | |
-n external-secrets \ | |
--create-namespace \ | |
--set installCRDs=true \ | |
--set webhook.port=9443 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Install reloader | |
helm repo add stakater https://stakater.github.io/stakater-charts | |
helm repo update | |
helm install reloader stakater/reloader -n kube-system |
OlderNewer