11locals {
2- govnotify_tables = [" notifications" , " received_text_messages" ]
3- create_govnotify_resource_count = local. is_live_environment ? 1 : 0
2+ govnotify_tables_customer_services = [" notifications" , " received_text_messages" ]
3+ create_govnotify_customer_services_resource_count = local. is_live_environment ? 1 : 0
44}
55
66
@@ -34,11 +34,11 @@ data "aws_iam_policy_document" "customer_services_s3_access" {
3434}
3535
3636resource "aws_iam_policy" "customer_services_s3_access" {
37- count = local. create_govnotify_resource_count
37+ count = local. create_govnotify_customer_services_resource_count
3838 name = " customer_services_s3_access"
3939 policy = data. aws_iam_policy_document . customer_services_s3_access . json
4040}
41- data "aws_iam_policy_document" "gov_notify_lambda_logs " {
41+ data "aws_iam_policy_document" "gov_notify_customer_services_lambda_logs " {
4242 statement {
4343 actions = [
4444 " logs:CreateLogGroup" ,
@@ -50,16 +50,16 @@ data "aws_iam_policy_document" "gov_notify_lambda_logs" {
5050 }
5151}
5252
53- resource "aws_iam_policy" "gov_notify_lambda_logs " {
54- count = local. create_govnotify_resource_count
55- name = " gov_notify_lambda_logs "
56- policy = data. aws_iam_policy_document . gov_notify_lambda_logs . json
53+ resource "aws_iam_policy" "gov_notify_customer_services_lambda_logs " {
54+ count = local. create_govnotify_customer_services_resource_count
55+ name = " gov_notify_customer_services_lambda_logs "
56+ policy = data. aws_iam_policy_document . gov_notify_customer_services_lambda_logs . json
5757}
5858
59- resource "aws_iam_role_policy_attachment" "gov_notify_lambda_logs " {
60- count = local. create_govnotify_resource_count
59+ resource "aws_iam_role_policy_attachment" "gov_notify_customer_services_lambda_logs " {
60+ count = local. create_govnotify_customer_services_resource_count
6161 role = aws_iam_role. customer_services_gov_notify_ingestion [0 ]. name
62- policy_arn = aws_iam_policy. gov_notify_lambda_logs [0 ]. arn
62+ policy_arn = aws_iam_policy. gov_notify_customer_services_lambda_logs [0 ]. arn
6363}
6464
6565data "aws_iam_policy_document" "lambda_assume_role" {
@@ -85,30 +85,30 @@ data "aws_iam_policy_document" "customer_services_gov_notify_lambda_execution" {
8585}
8686
8787resource "aws_iam_policy" "customer_services_gov_notify_lambda_execution" {
88- count = local. create_govnotify_resource_count
88+ count = local. create_govnotify_customer_services_resource_count
8989 name = " customer_services_gov_notify_lambda_execution"
9090 policy = data. aws_iam_policy_document . customer_services_gov_notify_lambda_execution . json
9191}
9292
9393resource "aws_iam_role" "customer_services_gov_notify_ingestion" {
94- count = local. create_govnotify_resource_count
94+ count = local. create_govnotify_customer_services_resource_count
9595 name = " customer_services_gov_notify_ingestion_lambda_role"
9696 assume_role_policy = data. aws_iam_policy_document . lambda_assume_role . json
9797}
9898
9999resource "aws_iam_role_policy_attachment" "customer_services_gov_notify_ingestion" {
100- count = local. create_govnotify_resource_count
100+ count = local. create_govnotify_customer_services_resource_count
101101 role = aws_iam_role. customer_services_gov_notify_ingestion [0 ]. name
102102 policy_arn = aws_iam_policy. customer_services_s3_access [0 ]. arn
103103}
104104
105105resource "aws_iam_role_policy_attachment" "customer_services_gov_notify_lambda_invoke" {
106- count = local. create_govnotify_resource_count
106+ count = local. create_govnotify_customer_services_resource_count
107107 role = aws_iam_role. customer_services_gov_notify_ingestion [0 ]. name
108108 policy_arn = aws_iam_policy. customer_services_gov_notify_lambda_execution [0 ]. arn
109109}
110110
111- data "aws_iam_policy_document" "gov_notify_lambda_secret_access " {
111+ data "aws_iam_policy_document" "gov_notify_customer_services_lambda_secret_access " {
112112 statement {
113113 actions = [
114114 " secretsmanager:GetSecretValue" ,
@@ -120,20 +120,20 @@ data "aws_iam_policy_document" "gov_notify_lambda_secret_access" {
120120 }
121121}
122122
123- resource "aws_iam_policy" "gov_notify_lambda_secret_access " {
124- count = local. create_govnotify_resource_count
125- name = " gov_notify_lambda_secret_access "
126- policy = data. aws_iam_policy_document . gov_notify_lambda_secret_access . json
123+ resource "aws_iam_policy" "gov_notify_customer_services_lambda_secret_access " {
124+ count = local. create_govnotify_customer_services_resource_count
125+ name = " gov_notify_customer_services_lambda_secret_access "
126+ policy = data. aws_iam_policy_document . gov_notify_customer_services_lambda_secret_access . json
127127}
128128
129- resource "aws_iam_role_policy_attachment" "gov_notify_lambda_secret_access " {
130- count = local. create_govnotify_resource_count
129+ resource "aws_iam_role_policy_attachment" "gov_notify_customer_services_lambda_secret_access " {
130+ count = local. create_govnotify_customer_services_resource_count
131131 role = aws_iam_role. customer_services_gov_notify_ingestion [0 ]. name
132- policy_arn = aws_iam_policy. gov_notify_lambda_secret_access [0 ]. arn
132+ policy_arn = aws_iam_policy. gov_notify_customer_services_lambda_secret_access [0 ]. arn
133133}
134134
135135# Define a IAM Policy Document for Glue StartCrawler Permissions:
136- data "aws_iam_policy_document" "gov_notify_glue_crawler " {
136+ data "aws_iam_policy_document" "gov_notify_customer_services_glue_crawler " {
137137 statement {
138138 actions = [" glue:StartCrawler" ]
139139 effect = " Allow"
@@ -142,24 +142,24 @@ data "aws_iam_policy_document" "gov_notify_glue_crawler" {
142142}
143143
144144# create a New IAM Policy Resource:
145- resource "aws_iam_policy" "gov_notify_glue_crawler " {
146- count = local. create_govnotify_resource_count
147- name = " gov_notify_glue_crawler_access "
148- policy = data. aws_iam_policy_document . gov_notify_glue_crawler . json
145+ resource "aws_iam_policy" "gov_notify_customer_services_glue_crawler " {
146+ count = local. create_govnotify_customer_services_resource_count
147+ name = " gov_notify_customer_services_glue_crawler_access "
148+ policy = data. aws_iam_policy_document . gov_notify_customer_services_glue_crawler . json
149149}
150150
151151# attach the gov_notify_glue_crawler to the customer_services_gov_notify_ingestion_lambda_role by creating a new aws_iam_role_policy_attachment resource.
152- resource "aws_iam_role_policy_attachment" "gov_notify_glue_crawler " {
153- count = local. create_govnotify_resource_count
152+ resource "aws_iam_role_policy_attachment" "gov_notify_customer_services_glue_crawler " {
153+ count = local. create_govnotify_customer_services_resource_count
154154 role = aws_iam_role. customer_services_gov_notify_ingestion [0 ]. name
155- policy_arn = aws_iam_policy. gov_notify_glue_crawler [0 ]. arn
155+ policy_arn = aws_iam_policy. gov_notify_customer_services_glue_crawler [0 ]. arn
156156}
157157
158158module "gov-notify-ingestion-customer-services" {
159- count = local. create_govnotify_resource_count
159+ count = local. create_govnotify_customer_services_resource_count
160160 source = " ../modules/aws-lambda"
161161 tags = module. tags . values
162- lambda_name = " govnotify_api_ingestion_repairs "
162+ lambda_name = " govnotify_api_ingestion_customer_services "
163163 lambda_role_arn = aws_iam_role. customer_services_gov_notify_ingestion [0 ]. arn
164164 identifier_prefix = local. short_identifier_prefix
165165 handler = " main.lambda_handler"
@@ -186,7 +186,7 @@ module "gov-notify-ingestion-customer-services" {
186186
187187# Create a CloudWatch Event Rule to trigger the GovNotify Customer Services Lambda function.
188188resource "aws_cloudwatch_event_rule" "govnotify_customer_services_trigger_event" {
189- count = local. create_govnotify_resource_count
189+ count = local. create_govnotify_customer_services_resource_count
190190 name = " ${ local . short_identifier_prefix } govnotify_customer_services_trigger_event"
191191 description = " Trigger event for Customer Services GovNotify API ingestion"
192192 schedule_expression = " cron(0 0 * * ? *)"
@@ -195,7 +195,7 @@ resource "aws_cloudwatch_event_rule" "govnotify_customer_services_trigger_event"
195195}
196196
197197# Create a Lambda Permission to allow CloudWatch to invoke the GovNotify Customer Services Lambda function.
198- resource "aws_lambda_permission" "allow_cloudwatch_to_call_govnotify " {
198+ resource "aws_lambda_permission" "allow_cloudwatch_to_call_govnotify_customer_services " {
199199 statement_id = " AllowCloudWatchToInvokeGovNotifyFunction"
200200 action = " lambda:InvokeFunction"
201201 function_name = module. gov-notify-ingestion-customer-services [0 ]. lambda_function_arn
@@ -205,7 +205,7 @@ resource "aws_lambda_permission" "allow_cloudwatch_to_call_govnotify" {
205205
206206# Create a CloudWatch Event Target to trigger the GovNotify Customer Services Lambda function.
207207resource "aws_cloudwatch_event_target" "govnotify_customer_services_trigger_event_target" {
208- count = local. create_govnotify_resource_count
208+ count = local. create_govnotify_customer_services_resource_count
209209 rule = aws_cloudwatch_event_rule. govnotify_customer_services_trigger_event [0 ]. name
210210 target_id = " govnotify-customer_services-trigger-event-target"
211211 arn = module. gov-notify-ingestion-customer-services [0 ]. lambda_function_arn
@@ -214,11 +214,14 @@ resource "aws_cloudwatch_event_target" "govnotify_customer_services_trigger_even
214214 "table_names": ${ jsonencode (local. govnotify_tables )}
215215 }
216216 EOF
217- depends_on = [module . gov-notify-ingestion-customer-services , aws_lambda_permission . allow_cloudwatch_to_call_govnotify ]
217+ depends_on = [
218+ module . gov-notify-ingestion-customer-services ,
219+ aws_lambda_permission . allow_cloudwatch_to_call_govnotify_customer_services
220+ ]
218221}
219222
220223resource "aws_glue_crawler" "govnotify_customer_services_landing_zone" {
221- for_each = {for idx , source in local . govnotify_tables : idx => source }
224+ for_each = {for idx , source in local . govnotify_tables_customer_services : idx => source }
222225
223226 database_name = " ${ local . identifier_prefix } -landing-zone-database"
224227 name = " ${ local . short_identifier_prefix } GovNotify Customer Services Landing Zone ${ each . value } "
@@ -238,7 +241,7 @@ resource "aws_glue_crawler" "govnotify_customer_services_landing_zone" {
238241}
239242
240243resource "aws_glue_crawler" "govnotify_customer_services_raw_zone" {
241- for_each = {for idx , source in local . govnotify_tables : idx => source }
244+ for_each = {for idx , source in local . govnotify_tables_customer_services : idx => source }
242245
243246 database_name = module. department_customer_services_data_source . raw_zone_catalog_database_name
244247 name = " ${ local . short_identifier_prefix } GovNotify Customer Services Raw Zone ${ each . value } "
0 commit comments