diff --git a/apps/gp-news/usw2dev/dynamodb.tf b/apps/gp-news/usw2dev/dynamodb.tf new file mode 100644 index 0000000..cb402f0 --- /dev/null +++ b/apps/gp-news/usw2dev/dynamodb.tf @@ -0,0 +1,21 @@ +resource "aws_dynamodb_table" "briefing_history" { + name = "${var.app_name}-${var.env_name}-briefing-history" + billing_mode = "PAY_PER_REQUEST" + hash_key = "pk" + range_key = "sk" + + attribute { + name = "pk" + type = "S" + } + + attribute { + name = "sk" + type = "S" + } + + ttl { + attribute_name = "expires_at" + enabled = true + } +} diff --git a/apps/gp-news/usw2dev/iam.tf b/apps/gp-news/usw2dev/iam.tf index e822e6f..3f18d97 100644 --- a/apps/gp-news/usw2dev/iam.tf +++ b/apps/gp-news/usw2dev/iam.tf @@ -126,6 +126,19 @@ resource "aws_iam_policy" "gp_news_lambda_custom" { "ssm:GetParameterHistory" ] Resource = [for p in aws_ssm_parameter.lambda_params : p.arn] + }, + { + Sid = "AllowBriefingHistoryDynamoDB" + Effect = "Allow" + Action = [ + "dynamodb:BatchWriteItem", + "dynamodb:DescribeTable", + "dynamodb:PutItem", + "dynamodb:Query" + ] + Resource = [ + aws_dynamodb_table.briefing_history.arn + ] } ] }) diff --git a/apps/gp-news/usw2dev/outputs.tf b/apps/gp-news/usw2dev/outputs.tf index d1cb7a8..a2a6550 100644 --- a/apps/gp-news/usw2dev/outputs.tf +++ b/apps/gp-news/usw2dev/outputs.tf @@ -18,8 +18,17 @@ output "lambda_function_name" { value = aws_lambda_function.gp_news_lambda.function_name } +output "briefing_history_table_arn" { + description = "The ARN of the DynamoDB table storing selected briefing news history" + value = aws_dynamodb_table.briefing_history.arn +} + +output "briefing_history_table_name" { + description = "The name of the DynamoDB table storing selected briefing news history" + value = aws_dynamodb_table.briefing_history.name +} + output "gha_role_arn" { description = "The ARN of the IAM role for GitHub Actions" value = aws_iam_role.gp_news_gha_ecr.arn } -