Skip to main content

Deploy a container with a Docker Build image on AWS Fargate

An example that builds a Docker image and deploys a container to AWS Fargate.

This example lives in the pulumi/examples repository. Check out just this directory to use it:

Get started with this example
git clone --filter=blob:none --sparse https://github.com/pulumi/examples pulumi-examples
git -C pulumi-examples sparse-checkout set aws-ts-containers-dockerbuild
cd pulumi-examples/aws-ts-containers-dockerbuild

Deploys an AWS Fargate service. The service uses a Docker image that is built with the Docker Build provider. The image is pushed to AWS ECR.

Last revision: July 2024.

This Pulumi example is also written as a template. If you prefer, you can copy it with pulumi new instead of cloning the repo:

Terminal window
pulumi new https://github.com/pulumi/examples/tree/master/aws-ts-containers-dockerbuild

Prerequisites#

  1. Install Pulumi
  2. Configure AWS credentials
  3. Install Node.js
  4. Install Docker with a default builder
  5. Recommended: a Pulumi Cloud account

Deploying the example#

  1. Create a new stack:

    Terminal window
    pulumi stack init dev
  2. Set the AWS region to deploy into:

    Terminal window
    pulumi config set aws:region us-west-2
  3. Install dependencies:

    Terminal window
    npm install
  4. Deploy the stack:

    Terminal window
    pulumi up
  5. Confirm the service is up and running:

    Terminal window
    curl $(pulumi stack output url)

Cleaning up#

Once you’re finished experimenting, destroy your stack and remove it to avoid incurring further charges:

Terminal window
pulumi destroy
pulumi stack rm

Related

The infrastructure as code platform for any cloud.