Skip to content

Commit

Permalink
update variable names
Browse files Browse the repository at this point in the history
  • Loading branch information
jay-whitwell committed Dec 18, 2024
1 parent 85c40bb commit fe2060b
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 11 deletions.
5 changes: 5 additions & 0 deletions terraform/environment/modules/lambda/outputs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,8 @@ output "lambda_role" {
description = "The lambda role"
value = aws_iam_role.lambda_role
}

output "lambda_name" {
description = "The lambda name"
value = aws_lambda_function.lambda_function.function_name
}
4 changes: 4 additions & 0 deletions terraform/environment/region.tf
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ module "eu_west_1" {
ecs_task_roles = module.iam.ecs_task_roles
environment_name = local.environment_name
event_bus_enabled = local.environment.event_bus_enabled
event_receiver_lambda_name = module.event_receiver.lambda_name
google_analytics_id_use = local.environment.google_analytics_id_use
google_analytics_id_view = local.environment.google_analytics_id_view
gov_uk_onelogin_client_id_secret_name = local.environment.gov_uk_onelogin_client_id_secret_name
Expand All @@ -33,6 +34,7 @@ module "eu_west_1" {
lpa_codes_endpoint = local.environment.lpa_codes_endpoint
lpas_collection_endpoint = local.environment.lpas_collection_endpoint
lpa_data_store_endpoint = local.environment.lpa_data_store_endpoint
receive_account_ids = local.environment.receive_account_ids
mock_onelogin_enabled = local.environment.mock_onelogin_enabled
mock_onelogin_service_container_version = local.mock_onelogin_version
mock_onelogin_service_repository_url = data.aws_ecr_repository.mock_onelogin.repository_url
Expand Down Expand Up @@ -107,6 +109,7 @@ module "eu_west_2" {
ecs_task_roles = module.iam.ecs_task_roles
environment_name = local.environment_name
event_bus_enabled = local.environment.event_bus_enabled
event_receiver_lambda_name = module.event_receiver.lambda_name
google_analytics_id_use = local.environment.google_analytics_id_use
google_analytics_id_view = local.environment.google_analytics_id_view
gov_uk_onelogin_client_id_secret_name = local.environment.gov_uk_onelogin_client_id_secret_name
Expand All @@ -120,6 +123,7 @@ module "eu_west_2" {
lpa_codes_endpoint = local.environment.lpa_codes_endpoint
lpas_collection_endpoint = local.environment.lpas_collection_endpoint
lpa_data_store_endpoint = local.environment.lpa_data_store_endpoint
receive_account_ids = local.environment.receive_account_ids
mock_onelogin_enabled = local.environment.mock_onelogin_enabled
mock_onelogin_service_container_version = local.mock_onelogin_version
mock_onelogin_service_repository_url = data.aws_ecr_repository.mock_onelogin.repository_url
Expand Down
10 changes: 6 additions & 4 deletions terraform/environment/region/event_bus.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
module "event_bus" {
source = "./modules/event_bus"
environment_name = var.environment_name
event_bus_enabled = var.event_bus_enabled
current_region = data.aws_region.current.name
source = "./modules/event_bus"
environment_name = var.environment_name
event_bus_enabled = var.event_bus_enabled
current_region = data.aws_region.current.name
receive_account_ids = var.receive_account_ids
event_receiver_lambda_name = var.event_receiver_lambda_name
providers = {
aws.region = aws.region
}
Expand Down
6 changes: 3 additions & 3 deletions terraform/environment/region/modules/event_bus/bus.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ resource "aws_cloudwatch_event_rule" "receive_events_from_mlpa" {

resource "aws_cloudwatch_event_bus_policy" "cross_account_receive" {
count = length(var.receive_account_ids) > 0 ? 1 : 0
event_bus_name = aws_cloudwatch_event_bus.main.name
event_bus_name = aws_cloudwatch_event_bus.main[0].name
policy = data.aws_iam_policy_document.cross_account_receive.json
provider = aws.region
}
Expand All @@ -42,7 +42,7 @@ data "aws_iam_policy_document" "cross_account_receive" {
"events:PutEvents",
]
resources = [
aws_cloudwatch_event_bus.main.arn
aws_cloudwatch_event_bus.main[0].arn
]

principals {
Expand All @@ -55,5 +55,5 @@ data "aws_iam_policy_document" "cross_account_receive" {
resource "aws_cloudwatch_event_target" "receive_events" {
count = var.event_bus_enabled ? 1 : 0
rule = aws_cloudwatch_event_rule.receive_events_from_mlpa[0].name
arn = aws_sqs_queue.receive_events_queue.arn
arn = aws_sqs_queue.receive_events_queue[0].arn
}
4 changes: 2 additions & 2 deletions terraform/environment/region/modules/event_bus/sqs.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ data "aws_iam_policy_document" "receive_events_queue_policy" {

resource "aws_lambda_event_source_mapping" "receive_events_mapping" {
count = var.event_bus_enabled ? 1 : 0
event_source_arn = aws_sqs_queue.receive_events_queue.arn
function_name = var.lambda_function_name
event_source_arn = aws_sqs_queue.receive_events_queue[0].arn
function_name = var.event_receiver_lambda_name
enabled = true
provider = aws.region
}
5 changes: 3 additions & 2 deletions terraform/environment/region/modules/event_bus/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ variable "event_bus_enabled" {
default = false
}

variable "lambda_function_name" {
description = "The name of the ingress lambda"
variable "event_receiver_lambda_name" {
description = "The name of the ingress from MLPA lambda"
type = string
}


variable "current_region" {
description = "The current region"
type = string
Expand Down
11 changes: 11 additions & 0 deletions terraform/environment/region/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ variable "event_bus_enabled" {
default = false
}

variable "event_receiver_lambda_name" {
description = "The name of the event receiver lambda."
type = string
default = ""
}

variable "feature_flags" {
description = "The feature flags to use."
type = map(string)
Expand Down Expand Up @@ -183,6 +189,11 @@ variable "load_balancer_deletion_protection_enabled" {
default = false
}

variable "receive_account_ids" {
description = "The account ID of the MLPA account."
type = list(string)
}

variable "mock_onelogin_enabled" {
description = "Whether or not to enable the mock One Login service."
type = bool
Expand Down
15 changes: 15 additions & 0 deletions terraform/environment/terraform.tfvars.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"session_expiry_warning": 5,
"ship_metrics_queue_enabled": true,
"sirius_account_id": "288342028542",
"receive_account_ids": [
"653761790766"
],
"load_balancer_deletion_protection_enabled": false,
"notify_key_secret_name": "notify-api-key",
"associate_alb_with_waf_web_acl_enabled": false,
Expand Down Expand Up @@ -148,6 +151,9 @@
"session_expiry_warning": 5,
"ship_metrics_queue_enabled": true,
"sirius_account_id": "288342028542",
"receive_account_ids": [
"653761790766"
],
"load_balancer_deletion_protection_enabled": false,
"notify_key_secret_name": "notify-api-key-demo",
"associate_alb_with_waf_web_acl_enabled": true,
Expand Down Expand Up @@ -246,6 +252,9 @@
"session_expiry_warning": 5,
"ship_metrics_queue_enabled": true,
"sirius_account_id": "288342028542",
"receive_account_ids": [
"653761790766"
],
"load_balancer_deletion_protection_enabled": false,
"notify_key_secret_name": "notify-api-key-demo",
"associate_alb_with_waf_web_acl_enabled": false,
Expand Down Expand Up @@ -344,6 +353,9 @@
"session_expiry_warning": 5,
"ship_metrics_queue_enabled": false,
"sirius_account_id": "288342028542",
"receive_account_ids": [
"653761790766"
],
"load_balancer_deletion_protection_enabled": true,
"notify_key_secret_name": "notify-api-key",
"associate_alb_with_waf_web_acl_enabled": true,
Expand Down Expand Up @@ -442,6 +454,9 @@
"session_expiry_warning": 5,
"ship_metrics_queue_enabled": false,
"sirius_account_id": "649098267436",
"receive_account_ids": [
"653761790766"
],
"load_balancer_deletion_protection_enabled": true,
"notify_key_secret_name": "notify-api-key",
"associate_alb_with_waf_web_acl_enabled": true,
Expand Down
1 change: 1 addition & 0 deletions terraform/environment/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ variable "environments" {
session_expiry_warning = number
ship_metrics_queue_enabled = bool
sirius_account_id = string
receive_account_ids = list(string)
load_balancer_deletion_protection_enabled = bool
notify_key_secret_name = string
associate_alb_with_waf_web_acl_enabled = bool
Expand Down

0 comments on commit fe2060b

Please sign in to comment.