Skip to content

Commit 60daeeb

Browse files
authored
Merge pull request #110 from NHSDigital/feature/eja-eli-239-amend-terraform-asset-names
eli-239 making resources workflow safe and amending dynamoDB naming t…
2 parents dd46b26 + 36e3804 commit 60daeeb

File tree

16 files changed

+29
-52
lines changed

16 files changed

+29
-52
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../_shared/default_variables.tf

infrastructure/modules/dynamodb/dynamodb.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_dynamodb_table" "dynamodb_table" {
2-
name = "${terraform.workspace == "default" ? "" : "${terraform.workspace}-"}${var.table_name_suffix}"
2+
name = "${terraform.workspace == "default" ? "" : "${terraform.workspace}-"}${var.project_name}-${var.environment}-${var.table_name_suffix}"
33
billing_mode = "PAY_PER_REQUEST"
44
hash_key = var.partition_key
55

infrastructure/modules/dynamodb/variables.tf

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
variable "workspace" {
2-
description = "Usually the developer short code or the name of the environment."
3-
type = string
4-
}
5-
6-
variable "project_name" {
7-
default = "eligibility-signposting-api"
8-
type = string
9-
}
10-
111
variable "table_name_suffix" {
122
description = "Name of the DynamoDB table"
133
type = string
@@ -34,9 +24,3 @@ variable "sort_key_type" {
3424
type = string
3525
default = null
3626
}
37-
38-
variable "tags" {
39-
description = "A map of tags to assign to resources."
40-
type = map(string)
41-
default = {}
42-
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../_shared/default_variables.tf

infrastructure/modules/s3/variables.tf

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,6 @@ variable "bucket_name" {
33
type = string
44
}
55

6-
variable "project_name" {
7-
default = "eligibility-signposting-api"
8-
type = string
9-
}
10-
11-
variable "environment" {
12-
description = "The purpose of the account dev/test/ref/prod or the workspace"
13-
type = string
14-
}
15-
166
variable "bucket_expiration_days" {
177
default = 90
188
description = "How long to keep bucket contents before expiring"

infrastructure/stacks/_shared/locals.tf

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -17,24 +17,9 @@ locals {
1717
workspace = lower(terraform.workspace)
1818
}
1919

20-
sso_role_patterns = {
21-
dev = "AWSReservedSSO_vdselid_dev_*"
22-
test = "AWSReservedSSO_vdselid_test_*"
23-
preprod = "AWSReservedSSO_vdselid_preprod_*"
24-
}
25-
2620
terraform_state_bucket_name = "eligibility-signposting-api-${var.environment}-tfstate"
2721
terraform_state_bucket_arn = "arn:aws:s3:::eligibility-signposting-api-${var.environment}-tfstate"
2822

29-
account_ids = {
30-
dev = "448049830832"
31-
test = "050451367081"
32-
preprod = "203918864209"
33-
# prod = "476114145616"
34-
}
35-
36-
current_account_id = lookup(local.account_ids, var.environment, data.aws_caller_identity.current.account_id)
37-
3823
role_arn_pre = "arn:aws:iam::603871901111:role/db-system-worker"
3924
role_arn_prod = "arn:aws:iam::232116723729:role/db-system-worker"
4025

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
module "eligibility_status_table" {
22
source = "../../modules/dynamodb"
33
workspace = local.workspace
4-
table_name_suffix = "eligibilty_data_store"
4+
table_name_suffix = "eligibility_datastore"
55
partition_key = "NHS_NUMBER"
66
partition_key_type = "S"
77
sort_key = "ATTRIBUTE_TYPE"
88
sort_key_type = "S"
99
tags = local.tags
10+
environment = local.environment
11+
stack_name = local.stack_name
1012
}

infrastructure/stacks/api-layer/iam_roles.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ resource "aws_iam_role" "eligibility_lambda_role" {
3131

3232

3333
resource "aws_iam_role" "write_access_role" {
34-
name = "external-write-role-${terraform.workspace == "default" ? "" : "-${terraform.workspace}"}"
34+
count = terraform.workspace == "default" ? 1 : 0
35+
name = "eligibility-signposting-api-${local.environment}-external-write-role"
3536
assume_role_policy = data.aws_iam_policy_document.dps_assume_role.json
3637
permissions_boundary = aws_iam_policy.assumed_role_permissions_boundary.arn
3738
}

infrastructure/stacks/api-layer/s3_buckets.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module "s3_rules_bucket" {
33
bucket_name = "eli-rules"
44
environment = var.environment
55
project_name = var.project_name
6+
stack_name = local.stack_name
7+
workspace = terraform.workspace
68
}
79

810
module "s3_audit_bucket" {
@@ -11,4 +13,6 @@ module "s3_audit_bucket" {
1113
environment = var.environment
1214
project_name = var.project_name
1315
bucket_expiration_days = 180
16+
stack_name = local.stack_name
17+
workspace = terraform.workspace
1418
}

infrastructure/stacks/api-layer/truststore_s3_bucket.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ module "s3_truststore_bucket" {
33
bucket_name = "truststore"
44
environment = var.environment
55
project_name = var.project_name
6+
stack_name = local.stack_name
7+
workspace = terraform.workspace
68
}
79

810
resource "aws_s3_bucket_policy" "truststore" {

0 commit comments

Comments
 (0)