diff --git a/.github/workflows/terraform-dev.yml b/.github/workflows/terraform-dev.yml index f93951e..8d9fd89 100644 --- a/.github/workflows/terraform-dev.yml +++ b/.github/workflows/terraform-dev.yml @@ -5,6 +5,11 @@ on: branches: - develop +env: + AWS_REGION: "sa-east-1" + TERRAFORM_DYNAMODB_LOCK_TABLE: "buildrun-terraform-state-lock" + TERRAFORM_S3_STATEFILE_BUCKET: "buildrun-sa-east-1-terraform-s3-statefile" + permissions: id-token: write contents: read @@ -31,7 +36,7 @@ jobs: with: role-to-assume: arn:aws:iam::179916804929:role/BuildRun-GithubActions-Role role-session-name: GitHub_to_AWS_via_FederatedOIDC - aws-region: ${{ vars.AWS_REGION }} + aws-region: ${{ env.AWS_REGION }} - name: Read destroy configuration id: read-destroy-config @@ -42,10 +47,10 @@ jobs: - name: Terraform Init run: | cd infra && terraform init \ - -backend-config="bucket=${{ vars.TERRAFORM_S3_STATEFILE_BUCKET }}" \ + -backend-config="bucket=${{ env.TERRAFORM_S3_STATEFILE_BUCKET }}" \ -backend-config="key=${{ github.event.repository.name }}" \ -backend-config="region=${{ env.AWS_REGION }}" \ - -backend-config="dynamodb_table=${{ vars.TERRAFORM_DYNAMODB_LOCK_TABLE }}" + -backend-config="dynamodb_table=${{ env.TERRAFORM_DYNAMODB_LOCK_TABLE }}" - name: Terraform Validate run: terraform validate diff --git a/infra/backend.tf b/infra/backend.tf index ba773ad..d57eb76 100644 --- a/infra/backend.tf +++ b/infra/backend.tf @@ -1,10 +1,3 @@ terraform { - backend "s3" { -# bucket = "buildrun-sa-east-1-terraform-s3-statefile" -# dynamodb_table = "buildrun-terraform-state-lock" -# key = "buildrun-infra-terraform-pipeline" -# region = "sa-east-1" -# profile = "terraform" -# shared_credentials_file = "~/.aws/credentials" - } + backend "s3" {} } \ No newline at end of file diff --git a/readme.md b/readme.md index e69de29..cc3afa5 100644 --- a/readme.md +++ b/readme.md @@ -0,0 +1,8 @@ +# Pipeline Infra (AWS + Terraform + Github Actions + Multi Env) + +## Getting Started + +- Create Github Actions IAM Role in your AWS Account (one-time-only-manual-config) +- Create S3 Bucket in your AWS Account (one-time-per-region-manual-config) +- Create DynamoDB table in your AWS Account (one-time-per-region-manual-config) +- Clone this repo and start your project with a fully functional terraform pipeline \ No newline at end of file