Skip to content

Commit 7abdd54

Browse files
authored
VED-720: Apply the exact plan generated in the Terraform plan step. (#870)
* VED-720: Apply the exact plan generated in the Terraform plan step. * VED-720: Add auto-approve back in for the Azure DevOps pipelines.
1 parent ce30afa commit 7abdd54

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

.github/workflows/deploy-backend.yml

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,13 @@ jobs:
7878

7979
- name: Terraform Plan
8080
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
81-
run: make plan apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
81+
run: make plan-ci apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
82+
83+
- name: Save Terraform Plan
84+
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02
85+
with:
86+
name: tfplan
87+
path: ${{ vars.TERRAFORM_DIR_PATH }}/tfplan
8288

8389
terraform-apply:
8490
needs: terraform-plan
@@ -106,14 +112,20 @@ jobs:
106112
with:
107113
terraform_version: "1.12.2"
108114

115+
- name: Retrieve Terraform Plan
116+
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0
117+
with:
118+
name: tfplan
119+
path: ${{ vars.TERRAFORM_DIR_PATH }}
120+
109121
- name: Terraform Init
110122
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
111123
run: make init apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
112124

113125
- name: Terraform Apply
114126
working-directory: ${{ vars.TERRAFORM_DIR_PATH }}
115127
run: |
116-
make apply apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
128+
make apply-ci apigee_environment=$APIGEE_ENVIRONMENT environment=$BACKEND_ENVIRONMENT sub_environment=$BACKEND_SUB_ENVIRONMENT
117129
echo "ID_SYNC_QUEUE_ARN=$(make -s output name=id_sync_queue_arn)" >> $GITHUB_ENV
118130
119131
- name: Install poetry

terraform/Makefile

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,18 @@ init-reconfigure:
3232
plan: workspace
3333
$(tf_cmd) plan $(tf_vars)
3434

35+
plan-ci: workspace
36+
$(tf_cmd) plan $(tf_vars) -out=tfplan -input=false
37+
3538
plan-changes: workspace
3639
$(tf_cmd) plan $(tf_vars) -out=plan && $(tf_cmd) show -no-color -json plan | jq -r '.resource_changes[] | select(.change.actions[0]=="update" or .change.actions[0]=="create" or .change.actions[0]=="add") | .address'
3740

41+
# TODO - remove --auto-approve once we've switched to the new deployment pipeline in GitHub Actions
3842
apply: workspace
39-
$(tf_cmd) apply $(tf_vars) -auto-approve
43+
$(tf_cmd) apply $(tf_vars) --auto-approve
44+
45+
apply-ci: workspace
46+
$(tf_cmd) apply $(tf_vars) -input=false tfplan
4047

4148
clean:
4249
rm -rf build .terraform upload-key

0 commit comments

Comments
 (0)