Posted in `pulumi-deployments` but no response and...
# typescript
i
Posted in
pulumi-deployments
but no response and still stuck on this. Any help would be really appreciated! Hello, has anyone else encountered this issue when trying to deploy from the github action
pulumi/actions@v3
I create an ECR image like this
Copy code
const imageWebDev = new awsx.ecr.Image(
  `web-${env}-image`,
  {
    repositoryUrl: ecrRepo.repositoryUrl,
    dockerfile: `Dockerfile`,
    path: "../../"
  },
  { protect: true }
);
And then pass it to my ec2 task definiton like this
Copy code
const taskDefinition = new awsx.ecs.EC2TaskDefinition(
  `web-${env}`,
  {
    containers: {
      app: {
        name: "app",
        image: imageWebDev.imageUri,
        cpu: 0,
        portMappings: [
          {
            containerPort: 3000,
            hostPort: 0,
            protocol: "tcp",
          },
        ],
.
.
.
This runs fine locally but when running in the Github action I get the following error:
Copy code
error: 1 error occurred:
    	* failed creating ECS Task Definition (web-production): ClientException: Container.image should not be null or empty.
I have tried the following • creating a whole new stack • using promises to ensure the task does not begin it's update before the image is finished • added in waiting to give things time to update • assigned the uri to a new variable and passed that to the task definition • hard coded in the
latest
image uri This is my pulumi action
Copy code
- name: Pulumi Update
              uses: pulumi/actions@v3
              with:
                command: up
                stack-name: prod
                comment-on-pr: true
                work-dir: ${{ env.WORKDIR }}
                upsert: true
              env:
                PULUMI_ACCESS_TOKEN: ${{ secrets.PULUMI_ACCESS_TOKEN }}
m
It looks like you're using
@pulumi/awsx
version 1 -- is that right?
You shouldn't have to "wait" for the image to be created -- the
immage: imggWebDev.imageUri
should take care of that. 🤔
i
I am I’ll try update my awsx version! And yes I read that passing the uri as I have should wait for it to be available and complete
m
@incalculable-plastic-17510 did you ever manage to solve this? I'm getting a similar error
Container.image repository should be 255 characters or less
which i believe is because it's passing in the whole
OutputImpl { __pulumiOutput: true, ...
object as a string instead of waiting for it to resolve to a value. so i've tried the various things you've tried. hard coding the full imageUri works for me though so it has to be not resolving the string as expected
i
@miniature-arm-21874 hello, apologies I moved job and have only come back to the community now. I did by upgrading the awsx version to > 2.* which had its own challenges of breaking some classes but once I solved them it began to work again.
But I did try a few other options before, such as ensuring the promise resolved before the image was used, hardcoding etc but that didn’t solve my issue
m
hi thanks for getting back to me!
interesting. i'm already on awsx 2.* so that's not it i don't think
I don't suppose you still have the code you could look at to see if anything obvious jumps out at you do you?
i
Unfortunately I do not as I’m not longer at that company but leave it with me and I’ll see if I can’t find anything else I did, try get back to you tomorrow
m
thanks very much. i really appreciate it
I have finally cracked it 😓
I had
Copy code
containerDefinitions: pulumi
      .all([image])
      .apply(([image]) => { ...
instead of
Copy code
containerDefinitions: pulumi
      .all([image.imageUri])
      .apply(([image]) => { ...
which immediately resolved obviously because image existed and it didn't wait for the imageUri property to exist 🤦‍♂️
thanks offering to look into it for me, much appreciated
i
Oh yeah I have done the same! Can be a pain to spot so good job catching it! Happy to help!
m
Thank you @miniature-arm-21874 for mentioning this! It’s a super subtle thing and easy to miss, and I’ve definitely hit this myself before too. We’re in the process of refreshing our input/output docs and I’ve shared this with the team so we can get it better documented.