diff --git a/.gitignore b/.gitignore index a7eba6d64..95975da4a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ .terraform* DS_Store +.DS_Store diff --git a/terraform/.github/workflows/terraform.yml b/terraform/.github/workflows/terraform.yml new file mode 100644 index 000000000..263d89993 --- /dev/null +++ b/terraform/.github/workflows/terraform.yml @@ -0,0 +1,60 @@ +name: "Vprofile IAC" +on: + push: + branches: + - main + - stage + paths: + - terraform/** + pull_request: + branches: + - main + paths: + - terraform/** + +env: + AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} + AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + BUCKET_TF_STATE: ${{ secrets.BUCKET_TF_STATE }} + AWS_REGION: us-east-1 + EKS_CLUSTER: vprofile-eks + +job: + terraform: + name: "APPLY terraform code changes" + runs on: ubuntu-latest + defaults: + run: + shell: + working-directory: ./terraform + + steps: + - name: checkout source code + uses: actions/checkout@v4 + + - name: setup terraform with specified version + uses: actions/checkout@v2 + #with: + # terraform_version 1.6.3 + + - name: terraform init + id: init + run: terraform init -backend-config="bucket=$BUCKET_TF_STATE" + + - name: terraform format + id: fmt + run: terrform fmt -check + + - name: terraform validate + id: validate + run: terrform validate + + - name: terraform plan + id: plan + run: terraform plan -no-color -input=false -out planfile + continue-on-error: true + + - name: terraform plan status + if: steps.plan.outcome == 'failure' + run: exit 1 +##### \ No newline at end of file diff --git a/terraform/terraform.tf b/terraform/terraform.tf index 67b75c673..55fdf7843 100644 --- a/terraform/terraform.tf +++ b/terraform/terraform.tf @@ -27,9 +27,9 @@ terraform { } backend "s3" { - bucket = "gitopsterrastate" + bucket = "tf-gitops" key = "terraform.tfstate" - region = "us-east-2" + region = "us-east-1" } required_version = "~> 1.6.3" diff --git a/terraform/variables.tf b/terraform/variables.tf index a41d982a0..d19424a8e 100644 --- a/terraform/variables.tf +++ b/terraform/variables.tf @@ -1,11 +1,11 @@ variable "region" { description = "AWS region" type = string - default = "us-east-2" + default = "us-east-1" } variable "clusterName" { description = "Name of the EKS cluster" type = string - default = "kitops-eks" + default = "vprofile-eks" } diff --git a/terraform/vpc.tf b/terraform/vpc.tf index 5775ce1c3..5cdb9c9a2 100644 --- a/terraform/vpc.tf +++ b/terraform/vpc.tf @@ -24,3 +24,4 @@ module "vpc" { "kubernetes.io/role/internal-elb" = 1 } } +##### \ No newline at end of file