Skip to content

Commit 2446f8d

Browse files
committed
feat: Allow deployment roles to be created with an environment name that differs from the infra.
1 parent 734b108 commit 2446f8d

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

tofu/modules/deployment/locals.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
locals {
2+
system_environment = coalesce(var.system_environment, var.environment)
3+
}

tofu/modules/deployment/main.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_iam_role" "deployment" {
2-
name = "${var.project}-${var.environment}-deployment-role"
2+
name = "${var.project}-${local.system_environment}-deployment-role"
33
assume_role_policy = jsonencode(yamldecode(templatefile("${path.module}/templates/assume-policy.yaml.tftpl", {
44
oidc_arn : var.oidc_arn
55
repository : var.repository
@@ -9,7 +9,7 @@ resource "aws_iam_role" "deployment" {
99
}
1010

1111
resource "aws_iam_role_policy" "deployment" {
12-
name = "${var.project}-${var.environment}-deployment-policy"
12+
name = "${var.project}-${local.system_environment}-deployment-policy"
1313
role = aws_iam_role.deployment.name
1414

1515
policy = jsonencode(yamldecode(templatefile("${path.module}/templates/iam-policy.yaml.tftpl", {
@@ -18,5 +18,6 @@ resource "aws_iam_role_policy" "deployment" {
1818
region : data.aws_region.current.region
1919
partition : data.aws_partition.current.partition
2020
project : var.project
21+
system_environment : local.system_environment
2122
})))
2223
}

tofu/modules/deployment/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ variable "environment" {
44
default = "development"
55
}
66

7+
variable "system_environment" {
8+
type = string
9+
description = "Environment name for the system, if different from the deployment environment."
10+
default = null
11+
}
12+
713
variable "oidc_arn" {
814
type = string
915
description = "ARN of the OpenID Connect provider for the GitHub repository."

0 commit comments

Comments
 (0)