(ecs): TagParameterContainerImage does not support digest
- Dominant language
- TypeScript
- Stars
- 12.9k
- Forks
- 4.6k
- Avg merge
- 2d 3h
- Merged PRs (30d)
- 83
Description
### Describe the bug
[TagParameterContainerImage ](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ecs/lib/images/tag-parameter-container-image.ts) uses CloudFormation parameter as the provider for the tag, but unlike [EcrImage](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ecs/lib/images/ecr.ts) which correctly uses [repositoryUriForTagOrDigest](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ecs/lib/images/ecr.ts#L26) to support both tag (`latest`) or digest (`sha256:...`), TagParameterContainerImage uses [repositoryUriForTag](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ecs/lib/images/tag-parameter-container-image.ts#L32) instead.
I will create the PR shortly for this bug/issue.
### Regression Issue
- [ ] Select this option if this issue appears to be a regression.
### Last Known Working CDK Library Version
_No response_
### Expected Behavior
I expect `TagParameterContainerImage` to support both tag or digest. I'd rather not create a new class `TagOrDigestParameterContainerImage`; I'd rather modify the existing `TagParameterContainerImage` to make it work with either, similar to how [EcrImage](https://github.com/aws/aws-cdk/blob/main/packages/aws-cdk-lib/aws-ecs/lib/images/ecr.ts) currently supports both.
### Current Behavior
`TagParameterContainerImage` does not support digest. It will suffix the `imageName` like this: `dkr.ecr.us-west-2.amazonaws.com/repo:sha256:1af7227` while the correct value should be `dkr.ecr.us-west-2.amazonaws.com/repo@sha256:1af7227`.
### Reproduction Steps
Unfortunately I can't use unit test to show this since unit test only synths, not deploy with parameters.
### Possible Solution
_No response_
### Additional Information/Context
_No response_
### AWS CDK Library version (aws-cdk-lib)
aws-cdk-lib@2.248.0
### AWS CDK CLI version
2.1119.0 (build 820ac02)
### Node.js Version
v24.15.0
### OS
6.6.87.2-microsoft-standard-WSL2
### Language
TypeScript
### Language Version
_No response_
### Other information
_No response_
Contributor guide
Research direction
Start with packages/aws-cdk-lib/aws-ecs/lib/images/tag-parameter-container-image.ts and compare its repository URI handling with EcrImage in packages/aws-cdk-lib/aws-ecs/lib/images/ecr.ts. Check how the CloudFormation parameter is incorporated, then verify that tag values retain the tag form and digest values use the digest form; the issue notes that unit tests only synthesize and do not deploy parameters.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- aws, typescript
- Domain
- cloud, infrastructure
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100