pulumi / pulumi-awsx

AWS infrastructure best practices in component form!
https://www.pulumi.com/docs/guides/crosswalk/aws/
Apache License 2.0
221 stars 104 forks source link

imageName option is confusing #1381

Open t0yv0 opened 1 week ago

t0yv0 commented 1 week ago

What happened?


Mitch Gerdisch
  Thursday at 5:58 PM

Given the following (awsx) code, I would expect the image tag in the ecr to be latest. Instead it is set to the imageName value (i.e. “mitch-image”).

Am I mistaken about how this should work? Or is this a bug?

const image = new awsx.ecr.Image("my-image", {
    imageName: "mitch-image",
    repositoryUrl: repository.url,
    context: "./app", // Path to your Dockerfile and application directory
    imageTag: "latest",
});

Checking up on this, https://github.com/pulumi/pulumi-awsx/issues/1171 introduced the imageName option but it's behaviorally identical to imageTag option at the moment, we probably only want one of those, not two. We should consider retracting 1171.

Example

See above.

Output of pulumi about

N/A

Additional context

No response

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).

flostadler commented 1 week ago

Ideally we should remove imageName and keep only imageTag.

Image name usually refers to the part before the tag (see docker docs), but here the imageName is used like a tag.

For ECR, the image name is set when creating the repository. So if users want different image names, they need to create different repos. If they just want different tags, then they can set the imageTag property on awsx.ecr.Image

flostadler commented 1 week ago

If we're touching this, we should also try to fix the resource name of the Image. I just saw that's it's using the TAG as the resource name: https://github.com/pulumi/pulumi-awsx/blob/0cbb50c6c06a988fa319dd4afbe1a1d6ee1dcfa0/awsx/ecr/image.ts#L40-L44 https://github.com/pulumi/pulumi-awsx/blob/0cbb50c6c06a988fa319dd4afbe1a1d6ee1dcfa0/awsx/ecr/image.ts#L89

But you can have the same tag (e.g. latest) across many different images, which would lead to duplicate URN errors right now if they're in the same stack.