Skip to content

Commit fda28c6

Browse files
committed
overhaul
1 parent 6021430 commit fda28c6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+268
-280
lines changed

terraform/ack_lambda.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ resource "aws_ecr_repository_policy" "ack_lambda_ECRImageRetreival_policy" {
6868
],
6969
"Condition" : {
7070
"StringLike" : {
71-
"aws:sourceArn" : "arn:aws:lambda:eu-west-2:${local.immunisation_account_id}:function:${local.short_prefix}-ack-lambda"
71+
"aws:sourceArn" : "arn:aws:lambda:eu-west-2:${var.immunisation_account_id}:function:${local.short_prefix}-ack-lambda"
7272
}
7373
}
7474
}
@@ -105,7 +105,7 @@ resource "aws_iam_policy" "ack_lambda_exec_policy" {
105105
"logs:CreateLogStream",
106106
"logs:PutLogEvents"
107107
]
108-
Resource = "arn:aws:logs:eu-west-2:${local.immunisation_account_id}:log-group:/aws/lambda/${local.short_prefix}-ack-lambda:*"
108+
Resource = "arn:aws:logs:eu-west-2:${var.immunisation_account_id}:log-group:/aws/lambda/${local.short_prefix}-ack-lambda:*"
109109
},
110110
{
111111
Effect = "Allow"
@@ -148,7 +148,7 @@ resource "aws_iam_policy" "ack_lambda_exec_policy" {
148148
"sqs:DeleteMessage",
149149
"sqs:GetQueueAttributes"
150150
],
151-
Resource = "arn:aws:sqs:eu-west-2:${local.immunisation_account_id}:${local.short_prefix}-ack-metadata-queue.fifo" },
151+
Resource = "arn:aws:sqs:eu-west-2:${var.immunisation_account_id}:${local.short_prefix}-ack-metadata-queue.fifo" },
152152
{
153153
"Effect" : "Allow",
154154
"Action" : [

terraform/api_gateway/api.tf

Lines changed: 0 additions & 66 deletions
This file was deleted.

terraform/api_gateway/variables.tf

Lines changed: 0 additions & 11 deletions
This file was deleted.

terraform/delta.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ resource "aws_ecr_repository_policy" "delta_lambda_ECRImageRetreival_policy" {
6969
],
7070
"Condition" : {
7171
"StringLike" : {
72-
"aws:sourceArn" : "arn:aws:lambda:eu-west-2:${local.immunisation_account_id}:function:${local.short_prefix}-${local.function_name}"
72+
"aws:sourceArn" : "arn:aws:lambda:eu-west-2:${var.immunisation_account_id}:function:${local.short_prefix}-${local.function_name}"
7373
}
7474
}
7575
}

terraform/dps_role_creation.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ resource "aws_iam_role" "dynamo_s3_access_role" {
66
{
77
Effect : "Allow",
88
Principal : {
9-
AWS : "arn:aws:iam::${local.dspp_core_account_id}:root"
9+
AWS : "arn:aws:iam::${var.dspp_core_account_id}:root"
1010
},
1111
Action : "sts:AssumeRole"
1212
}
@@ -22,7 +22,7 @@ resource "aws_iam_role_policy" "dynamo_s3_access_policy" {
2222
Statement = [
2323
{
2424
Effect = "Allow",
25-
Action = local.environment == "prod" ? [
25+
Action = var.environment == "prod" ? [
2626
"dynamodb:GetItem",
2727
"dynamodb:Query"
2828
] : [

terraform/dynamodb.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
resource "aws_dynamodb_table" "audit-table" {
2-
name = "immunisation-batch-${local.environment}-audit-table"
2+
name = "immunisation-batch-${var.sub_environment}-audit-table"
33
billing_mode = "PAY_PER_REQUEST"
44
hash_key = "message_id"
55

@@ -37,7 +37,7 @@ resource "aws_dynamodb_table" "audit-table" {
3737
}
3838

3939
point_in_time_recovery {
40-
enabled = local.environment == "prod"
40+
enabled = var.environment == "prod"
4141
}
4242

4343
server_side_encryption {
@@ -47,7 +47,7 @@ resource "aws_dynamodb_table" "audit-table" {
4747
}
4848

4949
resource "aws_dynamodb_table" "delta-dynamodb-table" {
50-
name = "imms-${local.environment}-delta"
50+
name = "imms-${var.sub_environment}-delta"
5151
billing_mode = "PAY_PER_REQUEST"
5252
hash_key = "PK"
5353

@@ -96,7 +96,7 @@ resource "aws_dynamodb_table" "delta-dynamodb-table" {
9696
}
9797

9898
point_in_time_recovery {
99-
enabled = local.environment == "prod"
99+
enabled = var.environment == "prod"
100100
}
101101

102102
server_side_encryption {
@@ -106,7 +106,7 @@ resource "aws_dynamodb_table" "delta-dynamodb-table" {
106106
}
107107

108108
resource "aws_dynamodb_table" "events-dynamodb-table" {
109-
name = "imms-${local.environment}-imms-events"
109+
name = "imms-${var.sub_environment}-imms-events"
110110
billing_mode = "PAY_PER_REQUEST"
111111
hash_key = "PK"
112112
stream_enabled = true
@@ -147,7 +147,7 @@ resource "aws_dynamodb_table" "events-dynamodb-table" {
147147
}
148148

149149
point_in_time_recovery {
150-
enabled = local.environment == "prod"
150+
enabled = var.environment == "prod"
151151
}
152152

153153
server_side_encryption {

terraform/ecs_batch_processor_config.tf

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ resource "aws_iam_policy" "ecs_task_exec_policy" {
9393
"logs:CreateLogStream",
9494
"logs:PutLogEvents"
9595
],
96-
Resource = "arn:aws:logs:${var.aws_region}:${local.immunisation_account_id}:log-group:/aws/vendedlogs/ecs/${local.short_prefix}-processor-task:*"
96+
Resource = "arn:aws:logs:${var.aws_region}:${var.immunisation_account_id}:log-group:/aws/vendedlogs/ecs/${local.short_prefix}-processor-task:*"
9797
},
9898
{
9999
Effect = "Allow",
@@ -148,7 +148,7 @@ resource "aws_iam_policy" "ecs_task_exec_policy" {
148148
Action = [
149149
"ecr:GetAuthorizationToken"
150150
],
151-
Resource = "arn:aws:ecr:${var.aws_region}:${local.immunisation_account_id}:repository/${local.short_prefix}-processing-repo"
151+
Resource = "arn:aws:ecr:${var.aws_region}:${var.immunisation_account_id}:repository/${local.short_prefix}-processing-repo"
152152
},
153153
{
154154
Effect = "Allow"
@@ -279,7 +279,7 @@ resource "aws_iam_policy" "fifo_pipe_policy" {
279279
"pipes:DescribePipe"
280280
],
281281
Resource = [
282-
"arn:aws:pipes:${var.aws_region}:${local.immunisation_account_id}:pipe/${local.short_prefix}-pipe",
282+
"arn:aws:pipes:${var.aws_region}:${var.immunisation_account_id}:pipe/${local.short_prefix}-pipe",
283283
aws_ecs_task_definition.ecs_task.arn
284284
]
285285
},
@@ -296,11 +296,11 @@ resource "aws_iam_policy" "fifo_pipe_policy" {
296296
],
297297
Effect = "Allow",
298298
Resource = [
299-
"arn:aws:logs:${var.aws_region}:${local.immunisation_account_id}:log-group:/aws/vendedlogs/pipes/${local.short_prefix}-pipe-logs:*",
300-
"arn:aws:ecs:${var.aws_region}:${local.immunisation_account_id}:task/${local.short_prefix}-ecs-cluster/*",
301-
"arn:aws:logs:${var.aws_region}:${local.immunisation_account_id}:log-group:/aws/vendedlogs/ecs/${local.short_prefix}-processor-task:*",
299+
"arn:aws:logs:${var.aws_region}:${var.immunisation_account_id}:log-group:/aws/vendedlogs/pipes/${local.short_prefix}-pipe-logs:*",
300+
"arn:aws:ecs:${var.aws_region}:${var.immunisation_account_id}:task/${local.short_prefix}-ecs-cluster/*",
301+
"arn:aws:logs:${var.aws_region}:${var.immunisation_account_id}:log-group:/aws/vendedlogs/ecs/${local.short_prefix}-processor-task:*",
302302
aws_sqs_queue.supplier_fifo_queue.arn,
303-
"arn:aws:ecs:${var.aws_region}:${local.immunisation_account_id}:cluster/${local.short_prefix}-ecs-cluster",
303+
"arn:aws:ecs:${var.aws_region}:${var.immunisation_account_id}:cluster/${local.short_prefix}-ecs-cluster",
304304
aws_ecs_task_definition.ecs_task.arn
305305
]
306306
},

terraform/endpoints.tf

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ data "aws_iam_policy_document" "logs_policy_document" {
88
source_policy_documents = [templatefile("${local.policy_path}/log.json", {})]
99
}
1010
module "get_status" {
11-
source = "./lambda"
11+
source = "./modules/lambda"
1212
prefix = local.prefix
1313
short_prefix = local.short_prefix
1414
function_name = "get_status"
@@ -23,13 +23,13 @@ locals {
2323
imms_table_name = aws_dynamodb_table.events-dynamodb-table.name
2424
imms_lambda_env_vars = {
2525
"DYNAMODB_TABLE_NAME" = local.imms_table_name,
26-
"IMMUNIZATION_ENV" = local.environment,
27-
"IMMUNIZATION_BASE_PATH" = strcontains(local.environment, "pr-") ? "immunisation-fhir-api-${local.environment}" : "immunisation-fhir-api"
26+
"IMMUNIZATION_ENV" = var.environment,
27+
"IMMUNIZATION_BASE_PATH" = strcontains(var.environment, "pr-") ? "immunisation-fhir-api-${var.environment}" : "immunisation-fhir-api"
2828
# except for prod and ref, any other env uses PDS int environment
29-
"PDS_ENV" = local.environment == "prod" ? "prod" : local.environment == "ref" ? "ref" : "int",
30-
"PDS_CHECK_ENABLED" = tostring(local.environment != "int")
29+
"PDS_ENV" = var.environment == "prod" ? "prod" : var.environment == "ref" ? "ref" : "int",
30+
"PDS_CHECK_ENABLED" = tostring(var.environment != "int")
3131
"SPLUNK_FIREHOSE_NAME" = module.splunk.firehose_stream_name
32-
"SQS_QUEUE_URL" = "https://sqs.eu-west-2.amazonaws.com/${local.immunisation_account_id}/${local.short_prefix}-ack-metadata-queue.fifo"
32+
"SQS_QUEUE_URL" = "https://sqs.eu-west-2.amazonaws.com/${var.immunisation_account_id}/${local.short_prefix}-ack-metadata-queue.fifo"
3333
"REDIS_HOST" = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].address
3434
"REDIS_PORT" = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].port
3535
}
@@ -41,7 +41,7 @@ data "aws_iam_policy_document" "imms_policy_document" {
4141
}),
4242
templatefile("${local.policy_path}/log.json", {}),
4343
templatefile("${local.policy_path}/lambda_to_sqs.json", {
44-
"local_account" : local.immunisation_account_id
44+
"local_account" : var.immunisation_account_id
4545
"queue_prefix" : local.short_prefix
4646
}),
4747
templatefile("${local.policy_path}/dynamo_key_access.json", {
@@ -58,15 +58,15 @@ data "aws_iam_policy_document" "imms_policy_document" {
5858
}
5959

6060
module "imms_event_endpoint_lambdas" {
61-
source = "./lambda"
61+
source = "./modules/lambda"
6262
count = length(local.imms_endpoints)
6363

6464
prefix = local.prefix
6565
short_prefix = local.short_prefix
6666
function_name = local.imms_endpoints[count.index]
6767
image_uri = module.docker_image.image_uri
6868
policy_json = data.aws_iam_policy_document.imms_policy_document.json
69-
environments = local.imms_lambda_env_vars
69+
environment_variables = local.imms_lambda_env_vars
7070
vpc_subnet_ids = local.private_subnet_ids
7171
vpc_security_group_ids = [data.aws_security_group.existing_securitygroup.id]
7272
}
@@ -106,15 +106,14 @@ output "oas" {
106106
}
107107

108108
module "api_gateway" {
109-
source = "./api_gateway"
109+
source = "./modules/api_gateway"
110110

111111
prefix = local.prefix
112112
short_prefix = local.short_prefix
113113
zone_id = data.aws_route53_zone.project_zone.zone_id
114114
api_domain_name = local.service_domain_name
115-
environment = local.environment
115+
environment = var.sub_environment
116116
oas = local.oas
117-
config_env = local.config_env
118117
}
119118

120119
resource "aws_lambda_permission" "api_gw" {

terraform/environments/non-prod/blue/variables.tfvars

Lines changed: 0 additions & 3 deletions
This file was deleted.

terraform/environments/non-prod/green/variables.tfvars

Lines changed: 0 additions & 3 deletions
This file was deleted.

0 commit comments

Comments
 (0)