Use Pulumi Crosswalk to automate container image builds

Nathan Peck profile picture
Nathan Peck
Senior Developer Advocate at AWS

Pulumi is an infrastructure as code framework for software engineers. Instead of writing YAML to define your infrastructure you can use higher level SDK commands, in a familiar programming language, and Pulumi will create the necessary resources for you automatically.

Build a container image and push it to Elastic Container Registry

Pulumi can automate conatiner image builds so that you no longer have to run docker build and docker push manually as part of the deploy process. Instead Pulumi will automatically create a private Elastic Container Registry, build your container image, and push it to the registry.

Then you can use the built image in a load balanced service like this:

  • TypeScript
  • Python
  • Go
  • Java
  • YAML
  • C#
File: build-image.tsLanguage: ts
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
import * as awsx from "@pulumi/awsx";

const repository = new awsx.ecr.Repository("repository", {});
const image = new awsx.ecr.Image("image", {
  repositoryUrl: repository.url,
  path: "./app",
const cluster = new aws.ecs.Cluster("cluster", {});
const lb = new"lb", {});
const service = new awsx.ecs.FargateService("service", {
  cluster: cluster.arn,
  assignPublicIp: true,
  taskDefinitionArgs: {
    container: {
      image: image.imageUri,
      cpu: 512,
      memory: 128,
      essential: true,
      portMappings: [{
        targetGroup: lb.defaultTargetGroup,
export const url = lb.loadBalancer.dnsName;

See Also