https://pulumi.com logo
#general
Title
# general
a

ancient-memory-38025

10/30/2019, 4:03 PM
Copy code
const tvxClusterS = aws.ecs.Cluster.get(`${identifier}-clustera`, stackCluster.getOutput(config.require("clusterName")))
const tvxVpcIdS = awsx.ec2.Vpc.fromExistingIds(`${identifier}-networka`, {
    vpcId: stackCluster.getOutput(config.require("vpcId"))
})

// const tvxVpcIdS = aws.ec2.Vpc.get(`${identifier}-networka`, stackCluster.getOutput(config.require("vpcId")))

const tvxCluster = new awsx.ecs.Cluster(`${identifier}-clusterb`, {
    cluster: tvxClusterS,
    vpc: tvxVpcIdS
})

const ecsService = new awsx.ecs.EC2Service(`${identifier}-svc`, {
    cluster: tvxCluster,
    taskDefinitionArgs: {
        containers: {
            app: {
                image: awsx.ecs.Image.fromPath(`${identifier}-img`, "./app"),
                portMappings: [{
                    containerPort: 3000,
                    hostPort: 80,
                    protocol: "tcp"
                }]
            }  
        },
    },
    desiredCount: 2
})
const app = new Service(`${identifier}-svc-instance`, ecsService)
g

gentle-diamond-70147

10/30/2019, 4:36 PM
You're referring to the upstream cluster via the StackReference, but then also creating a new cluster with this bit of code:
Copy code
const tvxCluster = new awsx.ecs.Cluster(`${identifier}-clusterb`, {
    cluster: tvxClusterS,
    vpc: tvxVpcIdS
})
a

ancient-memory-38025

10/30/2019, 5:00 PM
Thanks for the feedback, but isn't that necessary in order to for
new awsx.ecs.EC2Service
to create a service in that cluster?
Is there another way of consuming the cluster? I was inspired by this: https://www.pulumi.com/docs/guides/crosswalk/aws/ecs/#using-an-existing-ecs-cluster