Skip to content

Commit 215b0a4

Browse files
committed
NRL-1595 check deployed version written to state correctly
1 parent 13318c3 commit 215b0a4

File tree

3 files changed

+27
-17
lines changed

3 files changed

+27
-17
lines changed

.github/workflows/deploy-account-wide-infra.yml

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ jobs:
102102
ACCOUNT_NAME: ${{ vars.ACCOUNT_NAME }}
103103
run: |
104104
terraform -chdir=terraform/account-wide-infrastructure/${ACCOUNT_NAME} show -no-color tfplan > terraform/account-wide-infrastructure/$ACCOUNT_NAME/tfplan.txt
105-
ls terraform/account-wide-infrastructure/$ACCOUNT_NAME/
105+
106106
aws s3 cp terraform/account-wide-infrastructure/$ACCOUNT_NAME/tfplan s3://nhsd-nrlf--mgmt--github-ci-logging/acc-$ACCOUNT_NAME/${{ github.run_id }}/tfplan
107107
aws s3 cp terraform/account-wide-infrastructure/$ACCOUNT_NAME/tfplan.txt s3://nhsd-nrlf--mgmt--github-ci-logging/acc-$ACCOUNT_NAME/${{ github.run_id }}/tfplan.txt
108108
@@ -149,22 +149,21 @@ jobs:
149149
terraform -chdir=terraform/account-wide-infrastructure/${ACCOUNT_NAME} workspace new ${ACCOUNT_NAME} || \
150150
terraform -chdir=terraform/account-wide-infrastructure/${ACCOUNT_NAME} workspace select ${ACCOUNT_NAME}
151151
152-
# - name: Terraform Apply
153-
# env:
154-
# AWS_ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
155-
# run: |
156-
# terraform -chdir=terraform/account-wide-infrastructure apply tfplan \
157-
# -var 'assume_account=AWS_ACCOUNT_ID' \
158-
# -var 'assume_role=terraform'
159-
160-
# TODO: fix this
161-
# # Is this where we'd burn commit & datetime into state?
162-
# - name: Update environment config version
163-
# env:
164-
# ENVIRONMENT: ${{ 'account-dev' }}
165-
# run: |
166-
# deployed_version=$(terraform -chdir=terraform/account-wide-infrastructure/${ACCOUNT_NAME} output --raw version)
167-
# poetry run python ./scripts/set_env_config.py inactive-version ${deployed_version} $ENVIRONMENT
152+
- name: Terraform Apply
153+
env:
154+
ACCOUNT_NAME: ${{ vars.ACCOUNT_NAME }}
155+
ACCOUNT_ID: ${{ secrets.AWS_ACCOUNT_ID }}
156+
run: |
157+
terraform -chdir=terraform/account-wide-infrastructure/${ACCOUNT_NAME} tfplan \
158+
-var assume_account=${ACCOUNT_ID} \
159+
-var assume_role=terraform
160+
161+
- name: Update environment config version
162+
env:
163+
ACCOUNT_NAME: ${{ vars.ACCOUNT_NAME }}
164+
run: |
165+
deployed_version=$(terraform -chdir=terraform/account-wide-infrastructure/${ACCOUNT_NAME} output --raw version)
166+
echo $deployed_version
168167
169168
# Slack notif: starting deploy of account-wide infra <branch deets>
170169
# tf-plan: ensure output is visible in job output

terraform/account-wide-infrastructure/dev/data.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,10 @@ data "aws_secretsmanager_secret" "emails" {
1717
data "aws_secretsmanager_secret_version" "emails" {
1818
secret_id = data.aws_secretsmanager_secret.emails.id
1919
}
20+
21+
data "external" "current-info" {
22+
program = [
23+
"bash",
24+
"../../../scripts/get-current-info.sh",
25+
]
26+
}

terraform/account-wide-infrastructure/dev/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,7 @@ output "athena_kms_key_arn" {
2222
description = "KMS key ARN for Athena encryption"
2323
value = var.enable_reporting ? module.dev-athena[0].kms_key_arn : null
2424
}
25+
26+
output "version" {
27+
value = data.external.current-info.result.version
28+
}

0 commit comments

Comments
 (0)