openclaw/workers/clawdbot-aws/terraform/vpc.tf
Shunsuke Hayashi 4d74fdf593 feat(aws): add ECS Fargate deployment for Clawdbot Discord bot
Add complete ECS Fargate infrastructure for Clawdbot Discord bot
deployment on AWS.

## Infrastructure (Terraform)
- **VPC**: 100.64.0.0/16 with DNS support
- **Public Subnets**: 2 subnets in different AZs
- **ECR Repository**: clawdbot/bot with lifecycle policy
- **IAM Roles**: Task Role (DynamoDB+S3) + Execution Role
- **ECS Resources**: Fargate (256 CPU, 2048 MB memory)
- **Security Group**: Outbound only
- **CloudWatch**: Log group with 7-day retention

## Security Improvements
- Discord Bot Token → AWS Secrets Manager
- IAM policy with least privilege principle
- No plaintext secrets in code

## Code Quality
- Fix all 22 lint errors
- Add *.d.ts to oxlint ignore patterns
- Fix Dockerfile .buildstamp for Linux compatibility

Closes #2049

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-26 13:38:43 +09:00

64 lines
1.5 KiB
HCL

/**
* VPC for Clawdbot ECS Fargate Deployment
* Discord bot requires outbound internet access for WebSocket connections
*/
# VPC (using 100.64.0.0/16 to avoid conflicts with default 10.0.0.0/8)
resource "aws_vpc" "clawdbot" {
cidr_block = "100.64.0.0/16"
enable_dns_hostnames = true
enable_dns_support = true
tags = {
Name = "${var.project_name}-vpc"
}
}
# Internet Gateway for outbound internet access
resource "aws_internet_gateway" "clawdbot" {
vpc_id = aws_vpc.clawdbot.id
tags = {
Name = "${var.project_name}-igw"
}
}
# Public Subnets (for Fargate tasks with public IP)
resource "aws_subnet" "public" {
count = 2
vpc_id = aws_vpc.clawdbot.id
cidr_block = cidrsubnet(aws_vpc.clawdbot.cidr_block, 8, count.index)
availability_zone = data.aws_availability_zones.available.names[count.index]
map_public_ip_on_launch = true
tags = {
Name = "${var.project_name}-public-${count.index + 1}"
}
}
# Route Table for public subnets
resource "aws_route_table" "public" {
vpc_id = aws_vpc.clawdbot.id
route {
cidr_block = "0.0.0.0/0"
gateway_id = aws_internet_gateway.clawdbot.id
}
tags = {
Name = "${var.project_name}-public-rt"
}
}
# Route Table Association for public subnets
resource "aws_route_table_association" "public" {
count = 2
subnet_id = aws_subnet.public[count.index].id
route_table_id = aws_route_table.public.id
}
# Data source for available AZs
data "aws_availability_zones" "available" {
state = "available"
}