12/06/2021, 8:55 PM
hello! I'm trying out pulumi and im trying to change one of the fargate awsx tutorials to use ec2. but im getting stumped 😢
import * as awsx from "@pulumi/awsx";

const lb = new"loadbalancer", { port: 80 });

// Need explicit cluster bc we have to define ec2 autoscaling group
const cluster = new awsx.ecs.Cluster("ec2-cluster");

cluster.createAutoScalingGroup("ec2-cluster-asg", {
  templateParameters: { minSize: 2 },
  launchConfigurationArgs: { instanceType: "t2.nano" },

// Will build our app image and push to ECR
const appImage = awsx.ecs.Image.fromPath("app-docker-image", "./app");

const appService = new awsx.ecs.EC2Service("app", {
  taskDefinitionArgs: {
    containers: {
      app: {
        image: appImage,
        portMappings: [lb],
        memoryReservation: 256,
  desiredCount: 2,

export const url = lb.endpoint;
When I go to
pulumi up
I get an error creating the autoscale group cloudformation stack
error waiting for CloudFormation Stack creation: failed to create CloudFormation stack, rollback requested (ROLLBACK_COMPLETE): ["The following resource(s) failed to create: [Instances]. Rollback requested by user." "Property AvailabilityZones cannot be empty."]
I'm under the impression auto scaling would be using the clusters azs? Not seeing a good place to specify the az either, so I think I'm missing something? Any help would be much appreciated!


12/06/2021, 9:19 PM
this doesn't look to be supported with awsx at the moment. You'd need ro construct the ec2 instances manually, there's an example of that here:
actually, I think I'm wrong - you'd need to specify the subnets which would scheduled across AZs


12/06/2021, 9:47 PM
Thank you. I will try these after work and follow up. first one looks promising since im seeing asg role doesn't have cloudwatch perms