openclaw/workers/ppal-aws/terraform/dynamodb.tf
Shunsuke Hayashi abed5cb5cb feat(ppal-aws): add Terraform configuration for Discord Bot
Add AWS infrastructure as code for PPAL Discord Bot:
- API Gateway (HTTP API) for Discord Interactions endpoint
- Lambda function (Node.js 20.x container image)
- DynamoDB tables (users, conversations) with PAY_PER_REQUEST
- Secrets Manager for tokens (Discord, GitHub, OpenAI)
- IAM role with inline policies for Lambda execution

Files:
- versions.tf: Terraform 1.0+ with AWS provider 5.x
- variables.tf: environment, project_name, lambda config
- api_gateway.tf: HTTP API with CloudWatch logging
- lambda.tf: ECR-based Lambda with function URL
- dynamodb.tf: GSI-enabled tables with PITR & encryption
- secrets.tf: 4 secrets with placeholder values
- iam.tf: Inline policies for DynamoDB, Secrets, Logs, ECR
- outputs.tf: Endpoint URLs, ARNs (sensitive)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-25 19:04:55 +09:00

74 lines
1.2 KiB
HCL

resource "aws_dynamodb_table" "users" {
name = "${var.project_name}-users"
billing_mode = "PAY_PER_REQUEST"
hash_key = "user_id"
attribute {
name = "user_id"
type = "S"
}
attribute {
name = "guild_id"
type = "S"
}
global_secondary_index {
name = "GuildIndex"
hash_key = "guild_id"
projection_type = "ALL"
}
point_in_time_recovery {
enabled = true
}
server_side_encryption {
enabled = true
}
tags = {
Name = "${var.project_name}-users"
}
}
resource "aws_dynamodb_table" "conversations" {
name = "${var.project_name}-conversations"
billing_mode = "PAY_PER_REQUEST"
hash_key = "conversation_id"
attribute {
name = "conversation_id"
type = "S"
}
attribute {
name = "user_id"
type = "S"
}
attribute {
name = "created_at"
type = "S"
}
global_secondary_index {
name = "UserIndex"
hash_key = "user_id"
range_key = "created_at"
projection_type = "ALL"
}
point_in_time_recovery {
enabled = true
}
server_side_encryption {
enabled = true
}
tags = {
Name = "${var.project_name}-conversations"
}
}