Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EM: Fix SNS issues #9213

Merged
merged 12 commits into from
Jan 3, 2025
Original file line number Diff line number Diff line change
@@ -1,34 +1,59 @@
# ---------------------------------------
# live fms data json trigger
# ---------------------------------------
resource "aws_sns_topic_subscription" "live_serco_fms_sns_subscription" {
topic_arn = aws_sns_topic.live_serco_fms_s3_events.arn
protocol = "lambda"
endpoint = module.format_json_fms_data.lambda_function_arn
resource "aws_s3_bucket_notification" "historic_data_store" {
depends_on = [aws_lambda_permission.historic, aws_lambda_permission.live_serco_fms]
bucket = module.s3-data-bucket.bucket.id

lambda_function {
lambda_function_arn = module.calculate_checksum.lambda_function_arn
events = [
"s3:ObjectCreated:*"
]
filter_suffix = ".bak"
}
lambda_function {
lambda_function_arn = module.calculate_checksum.lambda_function_arn
events = [
"s3:ObjectCreated:*",
]
filter_suffix = ".zip"
}
lambda_function {
lambda_function_arn = module.calculate_checksum.lambda_function_arn
events = [
"s3:ObjectCreated:*",
]
filter_suffix = ".bacpac"
}
lambda_function {
lambda_function_arn = module.format_json_fms_data.lambda_function_arn
events = [
"s3:ObjectCreated:*",
]
filter_suffix = ".JSON"
filter_prefix = "serco/fms/"
}
}

resource "aws_lambda_permission" "live_serco_fms_with_sns" {
statement_id = "LiveServcoFMSLambdaAllowExecutionFromSNS"

resource "aws_lambda_permission" "live_serco_fms" {
statement_id = "LiveSercoFMSLambdaAllowExecutionFromS3Bucket"
action = "lambda:InvokeFunction"
function_name = module.format_json_fms_data.lambda_function_name
principal = "sns.amazonaws.com"
source_arn = aws_sns_topic.live_serco_fms_s3_events.arn
principal = "s3.amazonaws.com"
source_arn = module.s3-data-bucket.bucket.arn
}


# ---------------------------------------
# historic data json trigger
# ---------------------------------------
resource "aws_sns_topic_subscription" "historic_sns_subscription" {
topic_arn = aws_sns_topic.historic_s3_events.arn
protocol = "lambda"
endpoint = module.calculate_checksum.lambda_function_arn
}

resource "aws_lambda_permission" "historic_with_sns" {
statement_id = "ChecksumLambdaAllowExecutionFromHistoricDataSNS"
resource "aws_lambda_permission" "historic" {
statement_id = "ChecksumLambdaAllowExecutionFromHistoricData"
action = "lambda:InvokeFunction"
function_name = module.calculate_checksum.lambda_function_name
principal = "sns.amazonaws.com"
source_arn = aws_sns_topic.historic_s3_events.arn
principal = "s3.amazonaws.com"
source_arn = module.s3-data-bucket.bucket.arn
}
119 changes: 0 additions & 119 deletions terraform/environments/electronic-monitoring-data/s3_sns.tf

This file was deleted.

Loading