And as suspected, if I just hardcode the ARN, it w...
# general
c
And as suspected, if I just hardcode the ARN, it works. Little but stuck on where to go debugging the Output from here.
b
@cool-flower-46371 can you share your code? If you're building an a task definition you just need to build it inside an
apply
You already did that by logging the arn in a previous post, you just now need to build the JSON for the task definition
c
Hey Jaxx, I can share the code
Copy code
const taskDef = new aws.ecs.TaskDefinition(`${publicConfig.service_name}-task-definition`, {
    family: `${publicConfig.service_name}-family`,
    requiresCompatibilities: ["FARGATE"],
    memory: "1024",
    cpu: "512",
    networkMode: "awsvpc",
    executionRoleArn: "arn:aws:iam::************:role/ecsTaskExecutionRole",
    taskRoleArn: "arn:aws:iam::************:role/ecsInstanceRole",
    containerDefinitions: image.imageName.apply((image) => {
        return JSON.stringify([
            {
                name: publicConfig.service_name,
                image,
                essential: true,
                environment: [
                    { name: "AWS_REGION", value: "us-east-1" },
                ],
                secrets: [
                    { name: "CONNECTION_STRING", valueFrom: connectionString.arn },
                ],
                portMappings: [
                    {
                        containerPort: 80,
                        hostPort: 80,
                    },
                ],
            },
        ]);
    }),
});
I suspect I'm running into issues because I'm referencing
connectionString.arn
without using it in an Apply somewhere.
Like, maybe I need this?
Copy code
const taskDef = new aws.ecs.TaskDefinition(`${publicConfig.service_name}-task-definition`, {
    family: `${publicConfig.service_name}-family`,
    requiresCompatibilities: ["FARGATE"],
    memory: "1024",
    cpu: "512",
    networkMode: "awsvpc",
    executionRoleArn: "arn:aws:iam::************:role/ecsTaskExecutionRole",
    taskRoleArn: "arn:aws:iam::************:role/ecsInstanceRole",
    containerDefinitions: pulumi.all([image.imageName, connectionString.arn]).apply([image, connectionString] => {
        return JSON.stringify([
            {
                name: publicConfig.service_name,
                image,
                essential: true,
                environment: [
                    { name: "AWS_REGION", value: "us-east-1" },
                ],
                secrets: [
                    { name: "CONNECTION_STRING", valueFrom: connectionString },
                ],
                portMappings: [
                    {
                        containerPort: 80,
                        hostPort: 80,
                    },
                ],
            },
        ]);
    }),
});
@billowy-army-68599 Thanks for taking a look, at any rate
b
@cool-flower-46371 yes thats right, in the first example you're referencing an output
connectionString.arn
without resolving it inside the apply. Once you use
pulumi.all
it'll work
c
I totally think I get it now. You explained it well
Luckily I had an existing value (image) that we were already doing that way.
So It was easy enough to add. The build just worked
Big headache saved. Thank you!
❤️ 1
b
@cool-flower-46371 I have been told this explanation of
apply
is helpful: https://leebriggs.co.uk/blog/2021/05/09/pulumi-apply
c
I did see that, and I was trying to use apply, the problem is that I was doing it inline next to
valueFrom
instead of taking advantage of the fact that we were already using one (and just converting it to pulumi.all)
☝️ 1
that was a big disconnect for me
b
great feedback, I'll try think how to improve that experience
c
Yea, I think it was just a misunderstanding of the scoping on my part. Looking back it's very clear