Creating an AWS ECS Cluster

Install the AWSX package, if you haven’t already:

npm install @pulumi/awsx

Import the AWSX and Pulumi packages in an empty index.ts file:

import * as awsx from "@pulumi/awsx";
import * as pulumi from "@pulumi/pulumi";

And now create a new ECS cluster. You will use the default values, so doing so is very concise:

const cluster = new awsx.ecs.Cluster("cluster");

The index.ts file should now have the following contents:

import * as pulumi from "@pulumi/pulumi";
import * as awsx from "@pulumi/awsx";

const cluster = new awsx.ecs.Cluster("cluster");

To provision the ECS Cluster, run:

pulumi up

After confirming, you will see output like the following:

Updating (dev):

     Type                                          Name                  Status
 +   pulumi:pulumi:Stack                           ecs-workshop-dev      created
 +   ├─ awsx❌ecs:Cluster                         cluster               created
 +   │  ├─ awsx❌ec2:SecurityGroup                cluster               created
 +   │  │  ├─ awsx❌ec2:EgressSecurityGroupRule   cluster-egress        created
 +   │  │  │  └─ aws:ec2:SecurityGroupRule         cluster-egress        created
 +   │  │  ├─ awsx❌ec2:IngressSecurityGroupRule  cluster-containers    created
 +   │  │  │  └─ aws:ec2:SecurityGroupRule         cluster-containers    created
 +   │  │  ├─ awsx❌ec2:IngressSecurityGroupRule  cluster-ssh           created
 +   │  │  │  └─ aws:ec2:SecurityGroupRule         cluster-ssh           created
 +   │  │  └─ aws:ec2:SecurityGroup                cluster               created
 +   │  └─ aws:ecs:Cluster                         cluster               created
 +   └─ awsx❌ec2:Vpc                             default-vpc           created
 +      ├─ awsx❌ec2:Subnet                       default-vpc-public-0  created
 +      └─ awsx❌ec2:Subnet                       default-vpc-public-1  created

Resources:
    + 14 created

Duration: 40s

Permalink: https://app.pulumi.com/workshops/ecs-workshop/dev/updates/1