Skip to content

Instantly share code, notes, and snippets.

View Yamini-crypto's full-sized avatar

Yamini-crypto

View GitHub Profile
# Add new variable to variables.tf file
variable "ignore_tags" {
description = "Determines whether the `tags` value is ignored after initial apply. See README note for more details"
type = bool
default = true
}
lifecycle {
create_before_destroy = true
ignore_changes = [tag]
}
}
mkdir terraform-gitops-example
cd terraform-gitops-example
terraform init
Create Terraform Configuration File (main.tf):
provider "aws" {
region = "us-west-1"
}
data "aws_autoscaling_groups" "app" {
filter {
name = "tag:id"
values = ["app-asg"]
}
}
module "asg-app" {
source = "../modules/asg/"
## 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 = {
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
terraform state show $asg_location | grep $(terraform output -raw asg_name) > /dev/null 2>&1
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
# 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
#Install reloader
helm repo add stakater https://stakater.github.io/stakater-charts
helm repo update
helm install reloader stakater/reloader -n kube-system