Skip to content

Wire AWS ECS Staging Deployment for Buyer Agent - #113

Open
Sirajmx wants to merge 4 commits into
mainfrom
infra/wire-ecs-staging
Open

Wire AWS ECS Staging Deployment for Buyer Agent#113
Sirajmx wants to merge 4 commits into
mainfrom
infra/wire-ecs-staging

Conversation

@Sirajmx

@Sirajmx Sirajmx commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Deploy workflow fixed: Corrected ECS cluster/service/ECR naming to match Terraform-provisioned resource names
    (ad-buyer-system/{environment} pattern). Deployment now triggers on push to main only.
  • Private dependency support: Updated Dockerfile to install git in the builder stage and use a BuildKit
    --mount=type=secret,id=github_token to authenticate private iab-agentic-primitives git dependency without baking credentials
    into any image layer.
  • GitHub OIDC auth: Added infra/aws/terraform/github_oidc.tf — creates the GitHub Actions OIDC provider and a scoped IAM deploy
    role (ad-buyer-system-github-deploy) with least-privilege ECR push + ECS update permissions. No static AWS credentials stored in
    GitHub.
  • Terraform S3 backend: Replaced deprecated dynamodb_table lock with use_lockfile = true on the S3 backend block. Added
    ecr_repository_arn and ecs_cluster_arn outputs to wire the OIDC role's IAM conditions.

Infrastructure provisioned (Terraform apply, 54 resources)

  • VPC + public/private subnets + NAT Gateway (us-east-1)
  • ECS Fargate cluster + service (256 CPU / 512 MB, 1 task)
  • Application Load Balancer
  • ElastiCache Redis (cache.t3.micro)
  • EFS (encrypted, bursting — SQLite persistence)
  • ECR repository: ad-buyer-system/staging
  • CloudWatch log group (30-day retention, Container Insights enabled)
  • SSM Parameter Store: ANTHROPIC_API_KEY

GitHub secrets required

Test plan

  • Push to main triggers the deploy workflow
  • Docker build succeeds (private dep resolved via BuildKit secret)
  • Image pushed to ECR ad-buyer-system/staging:latest
  • ECS service stabilizes (aws ecs wait services-stable)
  • ALB health check returns 200 on /health

Sirajmx added 4 commits July 22, 2026 23:38
…rfile

deploy.yml:
- Fix ECR_REPOSITORY, ECS_CLUSTER, ECS_SERVICE to match Terraform resource
  names (add missing 'system-' prefix and env-scoped ECR path)
- Pass GH_PAT secret to docker build for private iab-agentic-primitives dep

Dockerfile:
- Add git to builder apt deps (needed for VCS pip install)
- Use BuildKit --mount=type=secret for GitHub token; token never written
  to any image layer (GIT_CONFIG_COUNT env-var approach, no gitconfig file)
- Runtime stage: --no-deps on pip install avoids re-cloning git deps
  (all deps already resolved in the copied venv from builder)

Terraform:
- Add github_oidc.tf: OIDC provider + scoped IAM deploy role for GitHub
  Actions (ECR push + ECS update-service); after apply, set output
  github_deploy_role_arn as AWS_DEPLOY_ROLE_ARN in repo secrets
- Expose ecr_repository_arn and ecs_cluster_arn from compute module
  so the OIDC policy can reference them without hardcoding ARN strings
@Sirajmx
Sirajmx requested review from atc964 and therevoltingx July 22, 2026 20:32
@atc964

atc964 commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Deploy verified working — thanks @Sirajmx. Holding the merge on an internal hosting decision (which environment the official staging instance lives in); being handled off-thread. Code-wise this is ready.

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.

2 participants