Skip to content

daytrader-go: infra - #3

Open
devin-ai-integration[bot] wants to merge 1 commit into
migration/daytrader-gofrom
devin/1794800000-go-infra
Open

devin-ai-integration[bot] wants to merge 1 commit into
migration/daytrader-gofrom
devin/1794800000-go-infra

Conversation

@devin-ai-integration

Copy link
Copy Markdown

Summary

Infra workstream for the Go + PostgreSQL target: container image, a compose override that runs it next to PostgreSQL, and Terraform for ECS Fargate. No Go code and no shared scaffold file is touched.

Container

  • daytrader-go/Dockerfile: golang:1.27-alpine build stage (matches go.mod), CGO_ENABLED=0 static binary; runtime gcr.io/distroless/static-debian12:nonroot, USER 65532:65532, EXPOSE 8080, ENTRYPOINT ["/daytrader"], CMD ["serve"].
  • daytrader-go/compose.app.yaml: adds app (built from the Dockerfile, DATABASE_URL pointing at postgres:5432, 8080:8080, depends_on postgres healthy).
docker compose -f daytrader-go/compose.yaml -f daytrader-go/compose.app.yaml up -d --build --wait
curl 'http://localhost:8080/daytrader/config?action=buildDBTables'
curl 'http://localhost:8080/daytrader/config?action=buildDB'

Terraform (infra/terraform/, thin root + network, alb, ecs, rds)

  • network: VPC, public and private subnets over 2 AZs, one NAT gateway, three security groups chained internet -> alb -> app (8080) -> database (5432). The database group has no egress; the default group is emptied.
  • alb: target group (ip targets) with health check /daytrader/health and lb_cookie stickiness (sessions are in process memory). HTTP on 80 by default; setting certificateArn switches to HTTPS on 443 with an HTTP redirect.
  • ecs: ECR repository, Fargate cluster, task definition (port 8080, awslogs, user = 65532:65532, read-only root filesystem), service in private subnets. DATABASE_URL is a task secret from Secrets Manager; every TradeConfig variable in daytrader-go/README.md is an SSM parameter injected through secrets. SQS queue plus dead-letter queue for ORDER_QUEUE_URL; ORDER_PROCESSING_MODE defaults to sync.
  • rds: Aurora PostgreSQL Serverless v2 in private subnets, encrypted, and the Secrets Manager secret holding the full DATABASE_URL.
  • IAM: the execution role is scoped to this ECR repository, log group, secret and parameters (not the managed AmazonECSTaskExecutionRolePolicy); the task role only reaches the order queue.

Observed

Gate Result
docker compose ... up -d --build --wait image built, app healthy
GET /daytrader/health on the container 200 {"database":"UP","orderProcessingMode":"sync","status":"UP"}
Non-root docker inspect: User=65532:65532; docker top: process uid 65532
Seed through the container buildDBTables 200, buildDB 200; 15000 accounts, 10000 quotes
terraform fmt -check -recursive, init -backend=false, validate all exit 0, output in docs/TERRAFORM_VALIDATE.txt
gofmt -l ., go vet ./..., go test ./... (in golang:1.27-alpine) clean; no test files exist on this branch

Parity scenarios that PASS: none. This workstream has no target scenarios. make parity against the container built from this branch alone (scaffold, no feature handlers) printed DIFF or ERROR for all 13, as expected. It was not run combined with sibling branches, and the Liberty baseline was not started.

Nothing was planned or applied, and no AWS credentials or backend were used.

Differences on purpose and things to review

  • Layout follows docs/TARGET_STATE.md: modules sit at infra/terraform/{network,alb,ecs,rds}, not under modules/.
  • Terraform variables, locals and outputs are camelCase (organization convention), not the usual snake_case.
  • The Aurora master password is a random_password, so it and the composed DATABASE_URL live in Terraform state. An encrypted remote backend is needed before any real use. RDS-managed master credentials were not used because that secret is JSON and the binary reads a single URL.
  • No service autoscaling: desiredCount defaults to 1 because sessions are in memory.
  • .terraform.lock.hcl is committed (aws 5.100.0, random 3.9.1).

Scaffold requests

None.

Link to Devin session: https://partner-workshops.devinenterprise.com/sessions/b9c6d6fd68b84392b4833e57d2645532
Open in Devin Desktop: https://partner-workshops.devinenterprise.com/desktop/session/b9c6d6fd68b84392b4833e57d2645532?variant=devin
Requested by: @sumitshatwara

@devin-ai-integration

Copy link
Copy Markdown
Author

I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".

  • Disable automatic comment, CI, and merge conflict monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant