cdk.lambda.DockerImageFunction: add ability to set image tag as parameter #26987
Labels
@aws-cdk/aws-lambda
Related to AWS Lambda
effort/medium
Medium work item – several days of effort
feature-request
A feature should be added or improved.
p2
Describe the feature
On the lambda DockerImageFunction construct, it would be sweet if there was an ability to set the image tag.
for example:
Use Case
When running several docker lambda functions in a stack or set of stacks, the amount of images starts to pile up in ECR because each image gets automatically tagged with a unique id.
Now I am aware that ECR retention policies can be created to automatically clear out old images but since these containers are tagged with unique IDs, it is difficult to create a policy that would, for example: clear out all images without a tag that are greater than 14 days old.
Proposed Solution
Add the ability to set the imageTag as a parameter of the dockerImageFunction construct to something static/developer-defined. During deployment, set the image tag to the parameter defined in the construct.
From my knowledge of ECR, I believe this is how the workflow would play out:
I think that doing this would enable the ability to set a more straightforward ECR retention policy. Or hey honestly, it might just be easier/ better to just remove the old image if the new one builds successfully so this pile-up of images doesn't happen.
Other Information
Definitely just taking a stab here at something I found a little annoying when working on some projects so I'm not sure if this was abstracted away or done for a reason someone much smarter than myself has a solid design decision around but either way wanted to throw it out there to see if we could get this on the map.
Thanks!
Acknowledgements
CDK version used
latest
Environment details (OS name and version, etc.)
macOS 13.0
The text was updated successfully, but these errors were encountered: