-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ecr.RegistryImage resource for pushing existing images to ECR #1464
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
Curious about this as I don't have a good intuition on our Docker support. My one question is adding new resources creates apparent complexity for the user, no? The matrix of possibilities is:
Does this matrix have very different Pulumi resources involved depending on what you are doing, and does this new resource make it even more complicated? https://www.pulumi.com/registry/packages/docker-build/#example seems to be able to push to ECR, can it push a prebuilt image to ECR? I think yes? |
The only resource that can push prebuilt images is docker.RegistryImage. (docker-build cannot) Right now users would need to handle the auth bit and re-triggering the image push when the source image changes. This is what this PR addresses. Given that the feature request has 14 upvotes I’d argue that users have an appetite for this. |
const creds = pulumi | ||
.output(args.repositoryUrl) | ||
.apply((url) => getDockerCredentials({ registryUrl: url }, { parent: this })); | ||
const provider = new docker.Provider(name, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no way for the user to customize https://www.pulumi.com/registry/packages/docker/#remote-hosts or anything else about this provider. Possibly OK for now just noting.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point, I can quickly expose those. I don't think those are gonna be useful for most users (e.g. remote host) as part of pushing a local image, but it doesn't hurt to export them to support future use cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Users can still reach this code with transforms possibly, if really needed.
awsx/schema-types.ts
Outdated
@@ -118,6 +119,20 @@ export interface ImageArgs { | |||
readonly repositoryUrl: pulumi.Input<string>; | |||
readonly target?: pulumi.Input<string>; | |||
} | |||
export abstract class RegistryImage<TData = any> extends (pulumi.ComponentResource)<TData> { | |||
public image!: unknown | pulumi.Output<unknown>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is unknown
here exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uh that's interesting, good catch!
Seems like the script for generating provider internal types has a bug or cannot properly handle references to docker??
The SDK and schema look good, but I'm gonna dig into this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, the type-gen for provider internal types was only configured to handle aws. I've added docker as well now
@@ -0,0 +1,5 @@ | |||
# Pushing a local image to an ECR registry | |||
|
|||
This example demonstrates how to push a local image to an ECR registry using the `awsx.ecr.RegistryImage` component. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice
{{% example %}} | ||
### Pushing an image to an ECR repository | ||
|
||
```typescript |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be cool to source from examples but that's for another time :)
Does the PR have any schema changes?Looking good! No breaking changes found. New resources:
Maintainer note: consult the runbook for dealing with any breaking changes. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1464 +/- ##
======================================
Coverage 0.00% 0.00%
======================================
Files 10 10
Lines 2345 2398 +53
======================================
- Misses 2345 2398 +53 ☔ View full report in Codecov by Sentry. |
This PR has been shipped in release v2.21.0. |
The current
awsx.ecr.Image
resource is limited to building and pushing new images to ECR. However, many CI/CD workflows need to push pre-built images that may come from separate build processes or workflows.This PR introduces a new
awsx.ecr.RegistryImage
component that enables pushing existing Docker images to ECR. The component extends the functionality of `docker.RegistryImage, automatically configures the provider with ECR credentials and detects changes to images to trigger pushes.The component handles scenarios where the source image tag remains constant (e.g.,
my-image:latest
) but the underlying image content has changed. Instead of relying solely on the image name for change detection, it uses the image's unique ID to determine when updates are needed. This ensures proper triggering of infrastructure updates when the source image was rebuilt.Resolves #1203