Skip to content

Commit

Permalink
Deploy to preproduction and production accounts
Browse files Browse the repository at this point in the history
Plan the account deployments in PR pipelines, and run in main build.

Fixes CTC-129 #major
  • Loading branch information
gregtyler committed Dec 12, 2023
1 parent e8efa1e commit d00428d
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/account-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@ on:
description: "The terraform workspace to target for account actions"
required: true
type: string
plan_only:
description: "Whether to only plan the deployment, not run it"
required: false
type: boolean
default: false
secrets:
aws_access_key_id:
description: "AWS Access Key ID"
Expand Down Expand Up @@ -55,7 +60,7 @@ jobs:
working-directory: ./terraform/account

- name: Terraform Apply
if: github.ref == 'refs/heads/main'
if: inputs.plan_only == false
env:
TF_WORKSPACE: ${{ inputs.workspace_name }}
run: |
Expand Down
20 changes: 20 additions & 0 deletions .github/workflows/workflow-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,23 @@ jobs:
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

deploy-preproduction-account:
needs: [test-dev-env]
name: TF Deploy Preproduction Account
uses: ./.github/workflows/account-deploy.yml
with:
workspace_name: preproduction
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

deploy-production-account:
name: TF Deploy Production Account
needs: [deploy-preproduction-account]
uses: ./.github/workflows/account-deploy.yml
with:
workspace_name: production
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
21 changes: 21 additions & 0 deletions .github/workflows/workflow-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,32 @@ jobs:
name: TF Plan Dev Account
uses: ./.github/workflows/account-deploy.yml
with:
plan_only: true
workspace_name: development
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

plan-preproduction-account:
name: TF Plan Preproduction Account
uses: ./.github/workflows/account-deploy.yml
with:
plan_only: true
workspace_name: preproduction
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

plan-production-account:
name: TF Plan Production Account
uses: ./.github/workflows/account-deploy.yml
with:
plan_only: true
workspace_name: production
secrets:
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}

deploy-pr-env:
name: Deploy PR Environment
needs:
Expand Down
10 changes: 10 additions & 0 deletions terraform/account/terraform.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@
"account_id": "493907465011",
"account_name": "development",
"is_production": false
},
"preproduction": {
"account_id": "936779158973",
"account_name": "preproduction",
"is_production": false
},
"production": {
"account_id": "764856231715",
"account_name": "production",
"is_production": true
}
}
}

0 comments on commit d00428d

Please sign in to comment.