payments-dashboard/terraform/data.tf

53 lines
1.1 KiB
Terraform
Raw Permalink Normal View History

resource "aws_dynamodb_table" "dashboard" {
name = local.table_name
billing_mode = "PAY_PER_REQUEST"
hash_key = "pk"
attribute {
name = "pk"
type = "S"
}
ttl {
attribute_name = "ttl"
enabled = true
}
server_side_encryption {
enabled = true
kms_key_arn = local.dynamodb_cmk_arn
}
}
resource "aws_sqs_queue" "process_csv_dlq" {
name = "payments-processPaymentCsv-async-dlq"
message_retention_seconds = 1209600
sqs_managed_sse_enabled = true
}
data "aws_iam_policy_document" "process_csv_dlq" {
statement {
sid = "AllowLambdaOnFailure"
effect = "Allow"
principals {
type = "Service"
identifiers = ["lambda.amazonaws.com"]
}
actions = ["sqs:SendMessage"]
resources = [aws_sqs_queue.process_csv_dlq.arn]
condition {
test = "ArnEquals"
variable = "aws:SourceArn"
values = [aws_lambda_function.this["process_csv"].arn]
}
}
}
resource "aws_sqs_queue_policy" "process_csv_dlq" {
queue_url = aws_sqs_queue.process_csv_dlq.id
policy = data.aws_iam_policy_document.process_csv_dlq.json
}