Skip to content

Commit 70cb5f1

Browse files
committed
Names fixed to handle AWS global unique names for S3 and dynamo
1 parent 521f758 commit 70cb5f1

File tree

5 files changed

+14
-11
lines changed

5 files changed

+14
-11
lines changed

terraform/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ init:
2626
init-reconfigure:
2727
$(tf_cmd) init $(tf_state) -upgrade $(tf_vars) -reconfigure
2828

29-
plan:
29+
plan: workspace
3030
$(tf_cmd) plan $(tf_vars)
3131

3232
plan-changes: workspace

terraform/api_gateway/mtls_cert.tf

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
locals {
22
# NHSD cert file
3-
truststore_file_name = "server-renewed-cert.pem"
3+
truststore_file_name = var.environment == "int" ? "imms-int-cert.pem" : "server-renewed-cert.pem"
44
}
55

66
data "aws_s3_bucket" "cert_storage" {
@@ -9,16 +9,16 @@ data "aws_s3_bucket" "cert_storage" {
99

1010
data "aws_s3_object" "cert" {
1111
bucket = data.aws_s3_bucket.cert_storage.bucket
12-
key = local.truststore_file_name
12+
key = local.truststore_file_name
1313
}
1414

1515
resource "aws_s3_bucket" "truststore_bucket" {
16-
bucket = "${var.prefix}-truststores"
16+
bucket = "${var.prefix}-truststores"
1717
force_destroy = true
1818
}
1919

2020
resource "aws_s3_object_copy" "copy_cert_from_storage" {
2121
bucket = aws_s3_bucket.truststore_bucket.bucket
2222
key = local.truststore_file_name
23-
source ="${data.aws_s3_object.cert.bucket}/${local.truststore_file_name}"
23+
source = "${data.aws_s3_object.cert.bucket}/${local.truststore_file_name}"
2424
}

terraform/dynamodb.tf

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
12
resource "aws_dynamodb_table" "audit-table" {
2-
name = "immunisation-batch-${local.environment}-audit-table"
3+
name = "immunisation-batch-${local.unique_name}-audit-table"
34
billing_mode = "PAY_PER_REQUEST"
45
hash_key = "message_id"
56

@@ -47,7 +48,7 @@ resource "aws_dynamodb_table" "audit-table" {
4748
}
4849

4950
resource "aws_dynamodb_table" "delta-dynamodb-table" {
50-
name = "imms-${local.environment}-delta"
51+
name = "imms-${local.unique_name}-delta"
5152
billing_mode = "PAY_PER_REQUEST"
5253
hash_key = "PK"
5354

@@ -106,7 +107,7 @@ resource "aws_dynamodb_table" "delta-dynamodb-table" {
106107
}
107108

108109
resource "aws_dynamodb_table" "events-dynamodb-table" {
109-
name = "imms-${local.environment}-imms-events"
110+
name = "imms-${local.unique_name}-imms-events"
110111
billing_mode = "PAY_PER_REQUEST"
111112
hash_key = "PK"
112113
stream_enabled = true

terraform/s3_config.tf

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
resource "aws_s3_bucket" "batch_data_source_bucket" {
23
bucket = "${local.batch_prefix}-data-sources"
34
force_destroy = local.is_temp
@@ -93,7 +94,7 @@ resource "aws_s3_bucket_lifecycle_configuration" "datasources_lifecycle" {
9394

9495
resource "aws_s3_bucket" "batch_data_destination_bucket" {
9596
# Deliberately not using `local.batch_prefix` as we don't want separate blue / green destinations in prod.
96-
bucket = "immunisation-batch-${local.environment}-data-destinations"
97+
bucket = "immunisation-batch-${local.unique_name}-data-destinations"
9798
force_destroy = local.is_temp
9899
}
99100

@@ -195,7 +196,7 @@ resource "aws_s3_bucket" "batch_config_bucket" {
195196
# For now, only create in internal-dev and prod as we only have one shared Redis instance per account.
196197
count = local.create_config_bucket ? 1 : 0
197198

198-
bucket = "imms-${local.environment}-supplier-config"
199+
bucket = "imms-${local.unique_name}-supplier-config"
199200
}
200201

201202
resource "aws_s3_bucket_public_access_block" "batch_config_bucket_public_access_block" {

terraform/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ locals {
2121
env = terraform.workspace
2222
prefix = var.aws_account_name == "int" ? "${var.project_name}-${var.service}-${local.env}-int" : "${var.project_name}-${var.service}-${local.env}"
2323
short_prefix = var.aws_account_name == "int" ? "${var.project_short_name}-${local.env}-int" : "${var.project_short_name}-${local.env}"
24-
batch_prefix = "immunisation-batch-${local.env}"
24+
batch_prefix = var.aws_account_name == "int" ? "immunisation-batch-${local.env}-int" : "immunisation-batch-${local.env}"
2525
config_env = var.aws_account_name
2626
config_bucket_env = local.environment == "prod" ? "prod" : "internal-dev"
2727

@@ -33,6 +33,7 @@ locals {
3333
create_config_bucket = true
3434
config_bucket_arn = local.create_config_bucket ? aws_s3_bucket.batch_config_bucket[0].arn : data.aws_s3_bucket.existing_config_bucket[0].arn
3535
config_bucket_name = local.create_config_bucket ? aws_s3_bucket.batch_config_bucket[0].bucket : data.aws_s3_bucket.existing_config_bucket[0].bucket
36+
unique_name = var.aws_account_name == "int" ? "preprod-${var.aws_account_name}" : var.aws_account_name # Because some dbs already exist with that name
3637
}
3738

3839
data "aws_vpc" "default" {

0 commit comments

Comments
 (0)