Closed
Description
Describe the feature
Expose the repository domain/hostname as a prop.
Use Case
The Docker credentials helper (e.g. docker-credential-ecr-login
) expects a hostname in the configuration.
{
"credHelpers": {
"public.ecr.aws": "ecr-login",
"<aws_account_id>.dkr.ecr.<region>.amazonaws.com": "ecr-login"
}
}
Docs: https://github.com/awslabs/amazon-ecr-credential-helper?tab=readme-ov-file#docker
Proposed Solution
Extract the hostname part from this method:
aws-cdk/packages/aws-cdk-lib/aws-ecr/lib/repository.ts
Lines 234 to 242 in 0c753c3
And make it public:
/**
* Returns the domain of the repository. Can be used in Docker credentials helper.
*
* ACCOUNT.dkr.ecr.REGION.amazonaws.com
*
* @param tagOrDigest Optional image tag or digest (digests must start with `sha256:`)
*/
public get repositoryDomain(): string {
return "";
}
Other Information
This helper already ships with some CodeBuild images:
aws/aws-codebuild-docker-images#743
Acknowledgements
- I may be able to implement this feature requestThis feature might incur a breaking change
CDK version used
2.x
Environment details (OS name and version, etc.)
N/A
Activity
ashishdhingra commentedon Oct 3, 2024
If we examine Push commands for an ECR repository, the 1st step is to
Retrieve an authentication token and authenticate your Docker client to your registry. Use the AWS CLI:
So it is useful to expose a property, let's say
registryUri
, in IRepository interface (similar torepositoryUri
):Then introduce property below in RepositoryBase class:
moltar commentedon Oct 3, 2024
@ashishdhingra Good point. Luckily, that command seems to work with the full
repositoryUri
value, too!moltar commentedon Oct 3, 2024
Altho I'd be careful with the
registryUri
nomenclature, as URI implies that there must be a scheme. What we have is truly just a domain or a hostname. But if we forget the implementation detail, it might just be a name. 🤷🏼https://en.wikipedia.org/wiki/Uniform_Resource_Identifier
6 remaining items