Skip to content
GitHubXDiscord

PullThroughCacheRule

The PullThroughCacheRule resource allows you to manage AWS ECR PullThroughCacheRules which enable you to cache images from an upstream registry in your Amazon Elastic Container Registry (ECR).

Create a basic PullThroughCacheRule with required properties to cache images from an upstream registry.

import AWS from "alchemy/aws/control";
const pullThroughCacheRule = await AWS.ECR.PullThroughCacheRule("myPullThroughCacheRule", {
UpstreamRegistryUrl: "https://registry-1.example.com",
UpstreamRepositoryPrefix: "myapp",
EcrRepositoryPrefix: "myapp-cache"
});

Configure a PullThroughCacheRule with a custom role ARN and credentials for accessing the upstream registry.

const advancedPullThroughCacheRule = await AWS.ECR.PullThroughCacheRule("advancedPullThroughCacheRule", {
UpstreamRegistryUrl: "https://registry-2.example.com",
UpstreamRepositoryPrefix: "myapp",
EcrRepositoryPrefix: "myapp-cache",
CustomRoleArn: "arn:aws:iam::123456789012:role/MyCustomRole",
CredentialArn: "arn:aws:iam::123456789012:role/MyCredentials"
});

Use the adopt feature to avoid failure if a PullThroughCacheRule already exists.

const adoptedPullThroughCacheRule = await AWS.ECR.PullThroughCacheRule("adoptedPullThroughCacheRule", {
UpstreamRegistryUrl: "https://registry-3.example.com",
UpstreamRepositoryPrefix: "myapp",
EcrRepositoryPrefix: "myapp-cache",
adopt: true
});