11name : " Deploy - Prod"
22
3- run-name : " ${{ github.event. inputs.git_tag }}"
3+ run-name : " ${{ inputs.git_tag }}"
44
55on :
66 workflow_dispatch :
@@ -16,54 +16,48 @@ permissions:
1616 contents : read # This is required for actions/checkout
1717
1818jobs :
19- terraform_plan_apply :
20- name : Terraform Plan/Apply (prod)
19+ terraform_plan_apply_base_iam :
20+ name : Terraform Plan/Apply base-iam (prod)
2121 runs-on : ubuntu-latest
2222 environment : prod
2323 steps :
24- - name : Checkout Tag
24+ - name : Checkout
2525 uses : actions/checkout@v6
2626 with :
2727 ref : refs/tags/${{ github.event.inputs.git_tag}}
2828 fetch-depth : " 0"
2929
30- - name : Configure AWS Credentials
31- uses : aws- actions/configure-aws-credentials@v5
30+ - name : Apply base_iam
31+ uses : ./.github/ actions/tf-plan-apply
3232 with :
33- role-to-assume : ${{ secrets.AWS_ASSUME_ROLE }}
34- role-skip-session-tagging : true
35- aws-region : ${{ vars.AWS_REGION }}
36- mask-aws-account-id : true
33+ aws_assume_role : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/prod-github-bootstrap
34+ bucket_prefix : " prod"
35+ aws_account_id : ${{ secrets.AWS_ACCOUNT_ID }}
36+ aws_region : ${{ vars.AWS_REGION }}
37+ working_directory : " ./base_iam" # Use separate base_iam directory
38+ workspace : ${{ secrets.AWS_WORKSPACE }}
39+ tf_vars_file : ${{ vars.TF_VARS_FILE }}
40+ tf_extra_args : " -var aws_account_id=${{ secrets.AWS_ACCOUNT_ID }}"
3741
38- - name : Setup Terraform
39- uses : hashicorp/setup-terraform@v3
42+ terraform_plan_apply :
43+ name : Terraform Plan/Apply (prod)
44+ needs : ["terraform_plan_apply_base_iam"]
45+ runs-on : ubuntu-latest
46+ environment : prod
47+ steps :
48+ - name : Checkout Tag
49+ uses : actions/checkout@v6
4050 with :
41- terraform_version : 1.14.5
42- terraform_wrapper : false
43-
44- - name : Initialise Terraform
45- id : init
46- run : terraform init -backend-config=backend-prod.conf
47- working-directory : ./infrastructure
48- shell : bash
49-
50- - name : Select Terraform Workspace
51- id : workspace
52- run : terraform workspace select ${{ secrets.AWS_WORKSPACE }}
53- working-directory : ./infrastructure
54- shell : bash
55-
56- - name : Check Terraform Formatting
57- run : terraform fmt -check
58- working-directory : ./infrastructure
59-
60- - name : Run Terraform Plan
61- id : plan
62- run : |
63- terraform plan -input=false -no-color -var-file="${{vars.TF_VARS_FILE}}" -out tf.plan
64- working-directory : ./infrastructure
65- shell : bash
51+ ref : refs/tags/${{ inputs.git_tag}}
52+ fetch-depth : " 0"
6653
67- - name : Run Terraform Apply
68- run : terraform apply -auto-approve -input=false tf.plan
69- working-directory : ./infrastructure
54+ - name : Apply Main
55+ uses : ./.github/actions/tf-plan-apply
56+ with :
57+ # use newly updated role
58+ aws_assume_role : arn:aws:iam::${{ secrets.AWS_ACCOUNT_ID }}:role/prod-github-actions-role
59+ bucket_prefix : " prod"
60+ aws_account_id : ${{ secrets.AWS_ACCOUNT_ID }}
61+ aws_region : ${{ vars.AWS_REGION }}
62+ workspace : ${{ secrets.AWS_WORKSPACE }}
63+ tf_vars_file : ${{ vars.TF_VARS_FILE }}
0 commit comments