createPullThroughCacheRule method
Creates a pull through cache rule. A pull through cache rule provides a way to cache images from an upstream registry source in your Amazon ECR private registry. For more information, see Using pull through cache rules in the Amazon Elastic Container Registry User Guide.
May throw InvalidParameterException.
May throw LimitExceededException.
May throw PullThroughCacheRuleAlreadyExistsException.
May throw SecretNotFoundException.
May throw ServerException.
May throw UnableToAccessSecretException.
May throw UnableToDecryptSecretValueException.
May throw UnsupportedUpstreamRegistryException.
May throw ValidationException.
Parameter ecrRepositoryPrefix :
The repository name prefix to use when caching images from the source
registry.
Parameter upstreamRegistryUrl :
The registry URL of the upstream public registry to use as the source for
the pull through cache rule. The following is the syntax to use for each
supported upstream registry.
-
Amazon ECR (
ecr) – -
Amazon ECR Public (
ecr-public) –public.ecr.aws -
Docker Hub (
docker-hub) –registry-1.docker.io -
GitHub Container Registry (
github-container-registry) –ghcr.io -
GitLab Container Registry (
gitlab-container-registry) –registry.gitlab.com -
Kubernetes (
k8s) –registry.k8s.io -
Microsoft Azure Container Registry (
azure-container-registry) – -
Quay (
quay) –quay.io
Parameter credentialArn :
The Amazon Resource Name (ARN) of the Amazon Web Services Secrets Manager
secret that identifies the credentials to authenticate to the upstream
registry.
Parameter customRoleArn :
Amazon Resource Name (ARN) of the IAM role to be assumed by Amazon ECR to
authenticate to the ECR upstream registry. This role must be in the same
account as the registry that you are configuring.
Parameter registryId :
The Amazon Web Services account ID associated with the registry to create
the pull through cache rule for. If you do not specify a registry, the
default registry is assumed.
Parameter upstreamRegistry :
The name of the upstream registry.
Parameter upstreamRepositoryPrefix :
The repository name prefix of the upstream registry to match with the
upstream repository name. When this field isn't specified, Amazon ECR will
use the ROOT.
Implementation
Future<CreatePullThroughCacheRuleResponse> createPullThroughCacheRule({
required String ecrRepositoryPrefix,
required String upstreamRegistryUrl,
String? credentialArn,
String? customRoleArn,
String? registryId,
UpstreamRegistry? upstreamRegistry,
String? upstreamRepositoryPrefix,
}) async {
final headers = <String, String>{
'Content-Type': 'application/x-amz-json-1.1',
'X-Amz-Target':
'AmazonEC2ContainerRegistry_V20150921.CreatePullThroughCacheRule'
};
final jsonResponse = await _protocol.send(
method: 'POST',
requestUri: '/',
exceptionFnMap: _exceptionFns,
// TODO queryParams
headers: headers,
payload: {
'ecrRepositoryPrefix': ecrRepositoryPrefix,
'upstreamRegistryUrl': upstreamRegistryUrl,
if (credentialArn != null) 'credentialArn': credentialArn,
if (customRoleArn != null) 'customRoleArn': customRoleArn,
if (registryId != null) 'registryId': registryId,
if (upstreamRegistry != null)
'upstreamRegistry': upstreamRegistry.value,
if (upstreamRepositoryPrefix != null)
'upstreamRepositoryPrefix': upstreamRepositoryPrefix,
},
);
return CreatePullThroughCacheRuleResponse.fromJson(jsonResponse.body);
}