Skip to content
Public template

About

Easily Deploy to ECS with Atmos and Terraform

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

atmos-native-ci

Latest Release Last Updated Slack Community

Example application deployed to AWS ECS using Atmos and OpenTofu.

This repository demonstrates an elegant, self-contained approach to deploying containerized applications on ECS Fargate with automated CI/CD pipelines.

Introduction

Application

A simple Go web server designed to demonstrate container deployment strategies. Each request increments a counter, and the background color is configurable - making it easy to visualize blue/green deployments and load balancing. The /dashboard endpoint displays a grid of auto-refreshing iframes to show traffic distribution across instances. See app/ for details.

Infrastructure

graph TB
    subgraph "AWS Account"
        subgraph "VPC"
            subgraph "Private Subnets"
                ECS[ECS Fargate Service]
                EFS[(EFS Volume)]
            end
            subgraph "Public Subnets"
                ALB[Application Load Balancer]
            end
        end
        ECR[ECR Registry]
        R53[Route 53]
    end

    Internet((Internet)) --> R53
    R53 --> ALB
    ALB --> ECS
    ECS --> EFS
    ECR -.-> ECS

    subgraph "Dependencies (Pre-existing)"
        VPC_DEP[VPC Component]
        ECS_DEP[ECS Cluster Component]
        EFS_DEP[EFS Component]
    end

    VPC_DEP -.->|vpc_id, subnet_ids| ECS
    ECS_DEP -.->|cluster_arn, alb_listener_arn| ECS
    EFS_DEP -.->|efs_id| EFS
Loading

This project uses:

  • Atmos - Configuration orchestration and stack management
  • OpenTofu - Infrastructure as Code (Terraform-compatible)
  • AWS ECS Fargate - Serverless container orchestration
  • AWS ECR - Container image registry
  • AWS EFS - Persistent file storage (optional)

Atmos Features Demonstrated

This repository dogfoods the Atmos 1.225 native runtime path end to end:

Usage

Local Development

Run the application locally using Atmos native containers:

# Start the app locally (builds and runs on http://localhost:8080)
atmos up

# Stop the app
atmos down

CI/CD Workflows

See .github/workflows/ for detailed workflow diagrams.

Workflow Trigger Action
feature-branch.yml PR, merge queue Build image, run tests, deploy preview (PR with deploy label), deploy dev (merge queue gate)
validate.yml PR, merge queue Lint CODEOWNERS
main-branch.yaml Push to main Update draft release notes
release.yaml Published release, manual dispatch Promote image, deploy to staging and/or prod
preview-cleanup.yml PR closed Destroy preview environment

Deployment

Prerequisites

Infrastructure Dependencies

Before deploying, you must have the following infrastructure deployed:

  1. VPC - With public/private subnets
  2. ECS Cluster - With an Application Load Balancer (ALB) and DNS records configured
  3. EFS (optional) - For persistent storage volumes

Then configure the dependencies in terraform/stacks/. You have two options:

Option 1: Use !terraform.state (recommended)

Update the dependency configurations in terraform/stacks/deps/ to point to your infrastructure's remote state:

  • deps/vpc.yaml - VPC component remote state location
  • deps/ecs.yaml - ECS cluster component remote state location
  • deps/efs.yaml - EFS component remote state location (if using volumes)

Option 2: Hardcode values (brownfield)

Replace the !terraform.state lookups in terraform/stacks/defaults/app.yaml with hardcoded values for your infrastructure. See terraform/stacks/defaults/README.md for required variables and a complete example.

Local Deployment

# Deploy to dev environment
atmos terraform deploy app -s dev

# Deploy to staging
atmos terraform deploy app -s staging

# Deploy to production
atmos terraform deploy app -s prod

CI/CD Deployment

  1. Open a PR → CI runs build and tests; add the deploy label to deploy a preview environment.
  2. Approve and click "Merge when ready" → the merge queue runs build, tests, and atmos terraform deploy app -s dev before fast-forwarding main to the queue commit.
  3. Publish a GitHub release → automatically deploys to staging, then prod.
  4. Manually dispatch the release workflow with a tag and environment → redeploy a previous version (rollback or hotfix) without cutting a new release.

See .github/workflows/README.md for design rationale and detailed sequence diagrams.

Configuration

Stack configurations are in terraform/stacks/. Each environment imports shared defaults and specifies environment-specific settings:

# terraform/stacks/dev.yaml
import:
  - _default.yaml
  - defaults/app.yaml
  - deps/*

vars:
  stage: dev

Container configuration is defined in terraform/stacks/defaults/app.yaml and can be customized per environment.

Repository Structure

.
├── app/                       # Go application
│   ├── main.go                # Web server
│   ├── Dockerfile             # Multi-stage container build
│   ├── public/                # Static HTML assets
│   ├── rootfs/                # Container filesystem overlay
│   └── test/                  # Local test harness
├── atmos.yaml                 # Atmos configuration
├── .atmos.d/                  # Atmos custom commands
├── terraform/
│   ├── components/            # Terraform/OpenTofu modules
│   │   └── ecs-task/          # ECS task definition component
│   └── stacks/                # Environment configurations
│       ├── defaults/          # Shared component config
│       ├── deps/              # Dependency references
│       ├── dev.yaml
│       ├── staging.yaml
│       ├── prod.yaml
│       └── preview.yaml
└── .github/
    ├── workflows/             # CI/CD pipelines
    ├── README.yaml            # README source
    └── README.md              # Generated README

Building Documentation

To regenerate the README from this file, run:

atmos docs generate readme

Related Projects

Check out these related projects.

  • Atmos - Universal Tool for DevOps and Cloud Automation
  • aws-vpc component - Cloud Posse Terraform component for provisioning VPCs and subnets

Slack Community

Join our Open Source Community on Slack. It's FREE for everyone! Our "SweetOps" community is where you get to talk with others who share a similar vision for how to rollout and manage infrastructure. This is the best place to talk shop, ask questions, solicit feedback, and work together as a community to build totally sweet infrastructure.

Newsletter

Sign up for our newsletter and join 3,000+ DevOps engineers, CTOs, and founders who get insider access to the latest DevOps trends, so you can always stay in the know. Dropped straight into your Inbox every week — and usually a 5-minute read.

Office Hours

Join us every Wednesday via Zoom for your weekly dose of insider DevOps trends, AWS news and Terraform insights, all sourced from our SweetOps community, plus a live Q&A that you can't find anywhere else. It's FREE for everyone!

License

License

Licensed under the Apache License, Version 2.0. See LICENSE for full details.

Trademarks

All other trademarks referenced herein are the property of their respective owners.


Copyright © 2017-2026 Cloud Posse, LLC

About

Easily Deploy to ECS with Atmos and Terraform

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages