Skip to content

Commit b64b962

Browse files
VIA-373 AJ/AS Update GitHub workflow for all environments to deploy IAM before app
1 parent b26ba9a commit b64b962

File tree

25 files changed

+349
-10
lines changed

25 files changed

+349
-10
lines changed

.github/workflows/stage-4-deploy.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ jobs:
8181
run: echo "TF_VAR_alarms_slack_channel_id=${{ secrets.ALARMS_SLACK_CHANNEL_ID }}" >> $GITHUB_ENV
8282
- name: "Set the app version being deployed"
8383
run: echo "TF_VAR_app_version=${{ steps.tag-or-sha.outputs.value }}" >> $GITHUB_ENV
84-
- name: "Terraform init (shared)"
85-
id: init-shared
86-
run: TF_ENV=shared make terraform-init
87-
- name: "Terraform plan (shared)"
88-
id: plan-shared
89-
run: TF_ENV=shared make terraform-plan opts="-out=terraform-shared.tfplan"
90-
- name: "Terraform apply (shared)"
91-
id: apply-shared
92-
run: TF_ENV=shared make terraform-apply opts="-auto-approve" opts="terraform-shared.tfplan"
84+
- name: "Terraform init (iam)"
85+
id: init-iam
86+
run: TF_ENV=${{ inputs.environment }}/iam make terraform-init
87+
- name: "Terraform plan (iam)"
88+
id: plan-iam
89+
run: TF_ENV=${{ inputs.environment }}/iam make terraform-plan opts="-out=terraform-iam.tfplan"
90+
- name: "Terraform apply (iam)"
91+
id: apply-iam
92+
run: TF_ENV=${{ inputs.environment }}/iam make terraform-apply opts="-auto-approve" opts="terraform-iam.tfplan"
9393
- name: "Terraform init (app)"
9494
id: init-app
9595
run: TF_ENV=${{ inputs.environment }} make terraform-init

infrastructure/environments/shared/.terraform.lock.hcl renamed to infrastructure/environments/dev/iam/.terraform.lock.hcl

File renamed without changes.
File renamed without changes.
File renamed without changes.

infrastructure/environments/shared/main.tf renamed to infrastructure/environments/dev/iam/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "deploy_iam" {
2-
source = "../../modules/deploy_iam"
2+
source = "../../../modules/deploy_iam"
33

44
account_id = data.aws_caller_identity.current.account_id
55
prefix = local.prefix
File renamed without changes.
File renamed without changes.

infrastructure/environments/preprod/iam/.terraform.lock.hcl

Lines changed: 44 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
data "aws_caller_identity" "current" {}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
locals {
2+
region = "eu-west-2"
3+
4+
project_identifier = "vaccinations-app"
5+
project_identifier_shortcode = "vita"
6+
7+
environment = "preprod"
8+
deploy_workspace = var.is_github_action ? "gh" : terraform.workspace
9+
prefix = "${local.deploy_workspace}-${local.project_identifier_shortcode}-${data.aws_caller_identity.current.account_id}"
10+
11+
default_tags = {
12+
ManagedBy = "Terraform"
13+
Project = local.project_identifier
14+
Environment = local.environment
15+
}
16+
}
17+
18+
resource "null_resource" "check_workspace" {
19+
lifecycle {
20+
precondition {
21+
condition = var.is_github_action || terraform.workspace != "default"
22+
error_message = <<EOT
23+
❌ Default workspace is not allowed locally. It is reserved for GitHub actions.
24+
✅ Please switch to a named workspace like this (replace <name> with your workspace):
25+
( cd infrastructure/environments/dev; terraform workspace select <name>; terraform workspace list )
26+
EOT
27+
}
28+
}
29+
}

0 commit comments

Comments
 (0)