1. Packages
  2. AWS
  3. API Docs
  4. ecr
  5. PullThroughCacheRule
AWS v6.77.0 published on Wednesday, Apr 9, 2025 by Pulumi

aws.ecr.PullThroughCacheRule

Explore with Pulumi AI

Provides an Elastic Container Registry Pull Through Cache Rule.

More information about pull through cache rules, including the set of supported upstream repositories, see Using pull through cache rules.

Example Usage

import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";

const example = new aws.ecr.PullThroughCacheRule("example", {
    ecrRepositoryPrefix: "ecr-public",
    upstreamRegistryUrl: "public.ecr.aws",
    credentialArn: "arn:aws:secretsmanager:us-east-1:123456789:secret:ecr-pullthroughcache/ecrpublic",
});
Copy
import pulumi
import pulumi_aws as aws

example = aws.ecr.PullThroughCacheRule("example",
    ecr_repository_prefix="ecr-public",
    upstream_registry_url="public.ecr.aws",
    credential_arn="arn:aws:secretsmanager:us-east-1:123456789:secret:ecr-pullthroughcache/ecrpublic")
Copy
package main

import (
	"github.com/pulumi/pulumi-aws/sdk/v6/go/aws/ecr"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := ecr.NewPullThroughCacheRule(ctx, "example", &ecr.PullThroughCacheRuleArgs{
			EcrRepositoryPrefix: pulumi.String("ecr-public"),
			UpstreamRegistryUrl: pulumi.String("public.ecr.aws"),
			CredentialArn:       pulumi.String("arn:aws:secretsmanager:us-east-1:123456789:secret:ecr-pullthroughcache/ecrpublic"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var example = new Aws.Ecr.PullThroughCacheRule("example", new()
    {
        EcrRepositoryPrefix = "ecr-public",
        UpstreamRegistryUrl = "public.ecr.aws",
        CredentialArn = "arn:aws:secretsmanager:us-east-1:123456789:secret:ecr-pullthroughcache/ecrpublic",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ecr.PullThroughCacheRule;
import com.pulumi.aws.ecr.PullThroughCacheRuleArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var example = new PullThroughCacheRule("example", PullThroughCacheRuleArgs.builder()
            .ecrRepositoryPrefix("ecr-public")
            .upstreamRegistryUrl("public.ecr.aws")
            .credentialArn("arn:aws:secretsmanager:us-east-1:123456789:secret:ecr-pullthroughcache/ecrpublic")
            .build());

    }
}
Copy
resources:
  example:
    type: aws:ecr:PullThroughCacheRule
    properties:
      ecrRepositoryPrefix: ecr-public
      upstreamRegistryUrl: public.ecr.aws
      credentialArn: arn:aws:secretsmanager:us-east-1:123456789:secret:ecr-pullthroughcache/ecrpublic
Copy

Create PullThroughCacheRule Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new PullThroughCacheRule(name: string, args: PullThroughCacheRuleArgs, opts?: CustomResourceOptions);
@overload
def PullThroughCacheRule(resource_name: str,
                         args: PullThroughCacheRuleArgs,
                         opts: Optional[ResourceOptions] = None)

@overload
def PullThroughCacheRule(resource_name: str,
                         opts: Optional[ResourceOptions] = None,
                         ecr_repository_prefix: Optional[str] = None,
                         upstream_registry_url: Optional[str] = None,
                         credential_arn: Optional[str] = None,
                         custom_role_arn: Optional[str] = None,
                         upstream_repository_prefix: Optional[str] = None)
func NewPullThroughCacheRule(ctx *Context, name string, args PullThroughCacheRuleArgs, opts ...ResourceOption) (*PullThroughCacheRule, error)
public PullThroughCacheRule(string name, PullThroughCacheRuleArgs args, CustomResourceOptions? opts = null)
public PullThroughCacheRule(String name, PullThroughCacheRuleArgs args)
public PullThroughCacheRule(String name, PullThroughCacheRuleArgs args, CustomResourceOptions options)
type: aws:ecr:PullThroughCacheRule
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. PullThroughCacheRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. PullThroughCacheRuleArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. PullThroughCacheRuleArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. PullThroughCacheRuleArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. PullThroughCacheRuleArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var pullThroughCacheRuleResource = new Aws.Ecr.PullThroughCacheRule("pullThroughCacheRuleResource", new()
{
    EcrRepositoryPrefix = "string",
    UpstreamRegistryUrl = "string",
    CredentialArn = "string",
    CustomRoleArn = "string",
    UpstreamRepositoryPrefix = "string",
});
Copy
example, err := ecr.NewPullThroughCacheRule(ctx, "pullThroughCacheRuleResource", &ecr.PullThroughCacheRuleArgs{
	EcrRepositoryPrefix:      pulumi.String("string"),
	UpstreamRegistryUrl:      pulumi.String("string"),
	CredentialArn:            pulumi.String("string"),
	CustomRoleArn:            pulumi.String("string"),
	UpstreamRepositoryPrefix: pulumi.String("string"),
})
Copy
var pullThroughCacheRuleResource = new PullThroughCacheRule("pullThroughCacheRuleResource", PullThroughCacheRuleArgs.builder()
    .ecrRepositoryPrefix("string")
    .upstreamRegistryUrl("string")
    .credentialArn("string")
    .customRoleArn("string")
    .upstreamRepositoryPrefix("string")
    .build());
Copy
pull_through_cache_rule_resource = aws.ecr.PullThroughCacheRule("pullThroughCacheRuleResource",
    ecr_repository_prefix="string",
    upstream_registry_url="string",
    credential_arn="string",
    custom_role_arn="string",
    upstream_repository_prefix="string")
Copy
const pullThroughCacheRuleResource = new aws.ecr.PullThroughCacheRule("pullThroughCacheRuleResource", {
    ecrRepositoryPrefix: "string",
    upstreamRegistryUrl: "string",
    credentialArn: "string",
    customRoleArn: "string",
    upstreamRepositoryPrefix: "string",
});
Copy
type: aws:ecr:PullThroughCacheRule
properties:
    credentialArn: string
    customRoleArn: string
    ecrRepositoryPrefix: string
    upstreamRegistryUrl: string
    upstreamRepositoryPrefix: string
Copy

PullThroughCacheRule Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The PullThroughCacheRule resource accepts the following input properties:

EcrRepositoryPrefix
This property is required.
Changes to this property will trigger replacement.
string
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
UpstreamRegistryUrl
This property is required.
Changes to this property will trigger replacement.
string
The registry URL of the upstream registry to use as the source.
CredentialArn string
ARN of the Secret which will be used to authenticate against the registry.
CustomRoleArn string
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
UpstreamRepositoryPrefix Changes to this property will trigger replacement. string
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
EcrRepositoryPrefix
This property is required.
Changes to this property will trigger replacement.
string
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
UpstreamRegistryUrl
This property is required.
Changes to this property will trigger replacement.
string
The registry URL of the upstream registry to use as the source.
CredentialArn string
ARN of the Secret which will be used to authenticate against the registry.
CustomRoleArn string
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
UpstreamRepositoryPrefix Changes to this property will trigger replacement. string
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
ecrRepositoryPrefix
This property is required.
Changes to this property will trigger replacement.
String
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
upstreamRegistryUrl
This property is required.
Changes to this property will trigger replacement.
String
The registry URL of the upstream registry to use as the source.
credentialArn String
ARN of the Secret which will be used to authenticate against the registry.
customRoleArn String
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
upstreamRepositoryPrefix Changes to this property will trigger replacement. String
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
ecrRepositoryPrefix
This property is required.
Changes to this property will trigger replacement.
string
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
upstreamRegistryUrl
This property is required.
Changes to this property will trigger replacement.
string
The registry URL of the upstream registry to use as the source.
credentialArn string
ARN of the Secret which will be used to authenticate against the registry.
customRoleArn string
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
upstreamRepositoryPrefix Changes to this property will trigger replacement. string
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
ecr_repository_prefix
This property is required.
Changes to this property will trigger replacement.
str
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
upstream_registry_url
This property is required.
Changes to this property will trigger replacement.
str
The registry URL of the upstream registry to use as the source.
credential_arn str
ARN of the Secret which will be used to authenticate against the registry.
custom_role_arn str
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
upstream_repository_prefix Changes to this property will trigger replacement. str
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
ecrRepositoryPrefix
This property is required.
Changes to this property will trigger replacement.
String
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
upstreamRegistryUrl
This property is required.
Changes to this property will trigger replacement.
String
The registry URL of the upstream registry to use as the source.
credentialArn String
ARN of the Secret which will be used to authenticate against the registry.
customRoleArn String
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
upstreamRepositoryPrefix Changes to this property will trigger replacement. String
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.

Outputs

All input properties are implicitly available as output properties. Additionally, the PullThroughCacheRule resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
RegistryId string
The registry ID where the repository was created.
Id string
The provider-assigned unique ID for this managed resource.
RegistryId string
The registry ID where the repository was created.
id String
The provider-assigned unique ID for this managed resource.
registryId String
The registry ID where the repository was created.
id string
The provider-assigned unique ID for this managed resource.
registryId string
The registry ID where the repository was created.
id str
The provider-assigned unique ID for this managed resource.
registry_id str
The registry ID where the repository was created.
id String
The provider-assigned unique ID for this managed resource.
registryId String
The registry ID where the repository was created.

Look up Existing PullThroughCacheRule Resource

Get an existing PullThroughCacheRule resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: PullThroughCacheRuleState, opts?: CustomResourceOptions): PullThroughCacheRule
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        credential_arn: Optional[str] = None,
        custom_role_arn: Optional[str] = None,
        ecr_repository_prefix: Optional[str] = None,
        registry_id: Optional[str] = None,
        upstream_registry_url: Optional[str] = None,
        upstream_repository_prefix: Optional[str] = None) -> PullThroughCacheRule
func GetPullThroughCacheRule(ctx *Context, name string, id IDInput, state *PullThroughCacheRuleState, opts ...ResourceOption) (*PullThroughCacheRule, error)
public static PullThroughCacheRule Get(string name, Input<string> id, PullThroughCacheRuleState? state, CustomResourceOptions? opts = null)
public static PullThroughCacheRule get(String name, Output<String> id, PullThroughCacheRuleState state, CustomResourceOptions options)
resources:  _:    type: aws:ecr:PullThroughCacheRule    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
CredentialArn string
ARN of the Secret which will be used to authenticate against the registry.
CustomRoleArn string
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
EcrRepositoryPrefix Changes to this property will trigger replacement. string
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
RegistryId string
The registry ID where the repository was created.
UpstreamRegistryUrl Changes to this property will trigger replacement. string
The registry URL of the upstream registry to use as the source.
UpstreamRepositoryPrefix Changes to this property will trigger replacement. string
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
CredentialArn string
ARN of the Secret which will be used to authenticate against the registry.
CustomRoleArn string
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
EcrRepositoryPrefix Changes to this property will trigger replacement. string
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
RegistryId string
The registry ID where the repository was created.
UpstreamRegistryUrl Changes to this property will trigger replacement. string
The registry URL of the upstream registry to use as the source.
UpstreamRepositoryPrefix Changes to this property will trigger replacement. string
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
credentialArn String
ARN of the Secret which will be used to authenticate against the registry.
customRoleArn String
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
ecrRepositoryPrefix Changes to this property will trigger replacement. String
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
registryId String
The registry ID where the repository was created.
upstreamRegistryUrl Changes to this property will trigger replacement. String
The registry URL of the upstream registry to use as the source.
upstreamRepositoryPrefix Changes to this property will trigger replacement. String
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
credentialArn string
ARN of the Secret which will be used to authenticate against the registry.
customRoleArn string
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
ecrRepositoryPrefix Changes to this property will trigger replacement. string
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
registryId string
The registry ID where the repository was created.
upstreamRegistryUrl Changes to this property will trigger replacement. string
The registry URL of the upstream registry to use as the source.
upstreamRepositoryPrefix Changes to this property will trigger replacement. string
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
credential_arn str
ARN of the Secret which will be used to authenticate against the registry.
custom_role_arn str
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
ecr_repository_prefix Changes to this property will trigger replacement. str
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
registry_id str
The registry ID where the repository was created.
upstream_registry_url Changes to this property will trigger replacement. str
The registry URL of the upstream registry to use as the source.
upstream_repository_prefix Changes to this property will trigger replacement. str
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.
credentialArn String
ARN of the Secret which will be used to authenticate against the registry.
customRoleArn String
The ARN of the IAM role associated with the pull through cache rule. Must be specified if the upstream registry is a cross-account ECR private registry. See AWS Document - Setting up permissions for cross-account ECR to ECR PTC.
ecrRepositoryPrefix Changes to this property will trigger replacement. String
The repository name prefix to use when caching images from the source registry. Use ROOT as the prefix to apply a template to all repositories in your registry that don't have an associated pull through cache rule.
registryId String
The registry ID where the repository was created.
upstreamRegistryUrl Changes to this property will trigger replacement. String
The registry URL of the upstream registry to use as the source.
upstreamRepositoryPrefix Changes to this property will trigger replacement. String
The upstream repository prefix associated with the pull through cache rule. Used if the upstream registry is an ECR private registry. If not specified, it's set to ROOT, which allows matching with any upstream repository. See AWS Document - Customizing repository prefixes for ECR to ECR pull through cache.

Import

Using pulumi import, import a pull-through cache rule using the ecr_repository_prefix. For example:

$ pulumi import aws:ecr/pullThroughCacheRule:PullThroughCacheRule example ecr-public
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
AWS Classic pulumi/pulumi-aws
License
Apache-2.0
Notes
This Pulumi package is based on the aws Terraform Provider.