Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #5

Merged
merged 3 commits into from
May 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions .github/workflows/terraform-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
9 changes: 1 addition & 8 deletions infra/backend.tf
Original file line number Diff line number Diff line change
@@ -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" {}
}
8 changes: 8 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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