pulumi / examples

Infrastructure, containers, and serverless apps to AWS, Azure, GCP, and Kubernetes... all deployed with Pulumi
https://www.pulumi.com
Apache License 2.0
2.33k stars 874 forks source link

AWS TS Containers code missing required "name" argument #1486

Closed toriancrane closed 10 months ago

toriancrane commented 11 months ago

What happened?

When following the steps to deploy this example, I ran into the following error:

  pulumi:pulumi:Stack (troubleshoot-dev):
    error: Running program '/workspaces/.devcontainer/ecs-fargate/index.ts' failed with an unhandled exception:
    TSError: ⨯ Unable to compile TypeScript:
    index.ts(29,9): error TS2741: Property 'name' is missing in type '{ image: pulumi.Output<string>; cpu: number; memory: number; essential: boolean; portMappings: { containerPort: number; targetGroup: pulumi.Output<TargetGroup>; }[]; }' but required in type 'TaskDefinitionContainerDefinitionArgs'.

Expected Behavior

Expected the ECS resources to deploy successfully.

Steps to reproduce

Follow the steps in this guide up until pulumi up.

Output of pulumi about

CLI          
Version      3.79.0
Go Version   go1.21.0
Go Compiler  gc

Plugins
NAME    VERSION
aws     5.42.0
awsx    1.0.5
docker  3.6.1
nodejs  unknown

Host     
OS       debian
Version  11.7
Arch     x86_64

This project is written in nodejs: executable='/usr/bin/node' version='v16.20.2'

Current Stack: v-torian-pulumi-corp/troubleshoot/dev

Found no resources associated with dev

Found no pending operations associated with dev

Backend        
Name           pulumi.com
URL            https://app.pulumi.com/v-torian-pulumi-corp
User           v-torian-pulumi-corp
Organizations  v-torian-pulumi-corp, pulumi

Dependencies:
NAME            VERSION
@pulumi/aws     5.42.0
@pulumi/awsx    1.0.5
@pulumi/pulumi  3.79.0
@types/node     16.18.46

Pulumi locates its logs in /tmp by default

Additional context

Can be resolved by adding the name argument to the FargateService container definition. Ex:

// Deploy an ECS Service on Fargate to host the application container.
const service = new awsx.ecs.FargateService("service", {
    cluster: cluster.arn,
    assignPublicIp: true,
    taskDefinitionArgs: {
        container: {
            name: "awsx-ecs", // added this
            image: image.imageUri,
            cpu: 128,
            memory: 512,
            essential: true,
            portMappings: [{
                containerPort: 80,
                targetGroup: loadbalancer.defaultTargetGroup,
            }],
        },
    },
});

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).