RepositoryCreationTemplate class
Provides an Elastic Container Registry Repository Creation Template.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.iam.getPolicyDocument({
statements: [{
principals: [{
type: "AWS",
identifiers: ["123456789012"],
}],
sid: "new policy",
effect: "Allow",
actions: [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:DescribeRepositories",
"ecr:GetRepositoryPolicy",
"ecr:ListImages",
"ecr:DeleteRepository",
"ecr:BatchDeleteImage",
"ecr:SetRepositoryPolicy",
"ecr:DeleteRepositoryPolicy",
],
}],
});
const exampleRepositoryCreationTemplate = new aws.ecr.RepositoryCreationTemplate("example", {
encryptionConfigurations: [{
encryptionType: "AES256",
}],
prefix: "example",
description: "An example template",
imageTagMutability: "IMMUTABLE",
customRoleArn: "arn:aws:iam::123456789012:role/example",
appliedFors: ["PULL_THROUGH_CACHE"],
repositoryPolicy: example.then(example => example.json),
lifecyclePolicy: `{
\\"rules\\": [
{
\\"rulePriority\\": 1,
\\"description\\": \\"Expire images older than 14 days\\",
\\"selection\\": {
\\"tagStatus\\": \\"untagged\\",
\\"countType\\": \\"sinceImagePushed\\",
\\"countUnit\\": \\"days\\",
\\"countNumber\\": 14
},
\\"action\\": {
\\"type\\": \\"expire\\"
}
}
]
}
`,
resourceTags: {
Foo: "Bar",
},
});
import pulumi
import pulumi_aws as aws
example = aws.iam.get_policy_document(statements=[{
"principals": [{
"type": "AWS",
"identifiers": ["123456789012"],
}],
"sid": "new policy",
"effect": "Allow",
"actions": [
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:DescribeRepositories",
"ecr:GetRepositoryPolicy",
"ecr:ListImages",
"ecr:DeleteRepository",
"ecr:BatchDeleteImage",
"ecr:SetRepositoryPolicy",
"ecr:DeleteRepositoryPolicy",
],
}])
example_repository_creation_template = aws.ecr.RepositoryCreationTemplate("example",
encryption_configurations=[{
"encryption_type": "AES256",
}],
prefix="example",
description="An example template",
image_tag_mutability="IMMUTABLE",
custom_role_arn="arn:aws:iam::123456789012:role/example",
applied_fors=["PULL_THROUGH_CACHE"],
repository_policy=example.json,
lifecycle_policy="""{
\"rules\": [
{
\"rulePriority\": 1,
\"description\": \"Expire images older than 14 days\",
\"selection\": {
\"tagStatus\": \"untagged\",
\"countType\": \"sinceImagePushed\",
\"countUnit\": \"days\",
\"countNumber\": 14
},
\"action\": {
\"type\": \"expire\"
}
}
]
}
""",
resource_tags={
"Foo": "Bar",
})
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = Aws.Iam.GetPolicyDocument.Invoke(new()
{
Statements = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementInputArgs
{
Principals = new[]
{
new Aws.Iam.Inputs.GetPolicyDocumentStatementPrincipalInputArgs
{
Type = "AWS",
Identifiers = new[]
{
"123456789012",
},
},
},
Sid = "new policy",
Effect = "Allow",
Actions = new[]
{
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:DescribeRepositories",
"ecr:GetRepositoryPolicy",
"ecr:ListImages",
"ecr:DeleteRepository",
"ecr:BatchDeleteImage",
"ecr:SetRepositoryPolicy",
"ecr:DeleteRepositoryPolicy",
},
},
},
});
var exampleRepositoryCreationTemplate = new Aws.Ecr.RepositoryCreationTemplate("example", new()
{
EncryptionConfigurations = new[]
{
new Aws.Ecr.Inputs.RepositoryCreationTemplateEncryptionConfigurationArgs
{
EncryptionType = "AES256",
},
},
Prefix = "example",
Description = "An example template",
ImageTagMutability = "IMMUTABLE",
CustomRoleArn = "arn:aws:iam::123456789012:role/example",
AppliedFors = new[]
{
"PULL_THROUGH_CACHE",
},
RepositoryPolicy = example.Apply(getPolicyDocumentResult => getPolicyDocumentResult.Json),
LifecyclePolicy = @"{
\""rules\"": [
{
\""rulePriority\"": 1,
\""description\"": \""Expire images older than 14 days\"",
\""selection\"": {
\""tagStatus\"": \""untagged\"",
\""countType\"": \""sinceImagePushed\"",
\""countUnit\"": \""days\"",
\""countNumber\"": 14
},
\""action\"": {
\""type\"": \""expire\""
}
}
]
}
",
ResourceTags =
{
{ "Foo", "Bar" },
},
});
});
package main
import (
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/ecr"
"github.com/pulumi/pulumi-aws/sdk/v7/go/aws/iam"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
example, err := iam.GetPolicyDocument(ctx, &iam.GetPolicyDocumentArgs{
Statements: []iam.GetPolicyDocumentStatement{
{
Principals: []iam.GetPolicyDocumentStatementPrincipal{
{
Type: "AWS",
Identifiers: []string{
"123456789012",
},
},
},
Sid: pulumi.StringRef("new policy"),
Effect: pulumi.StringRef("Allow"),
Actions: []string{
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:DescribeRepositories",
"ecr:GetRepositoryPolicy",
"ecr:ListImages",
"ecr:DeleteRepository",
"ecr:BatchDeleteImage",
"ecr:SetRepositoryPolicy",
"ecr:DeleteRepositoryPolicy",
},
},
},
}, nil)
if err != nil {
return err
}
_, err = ecr.NewRepositoryCreationTemplate(ctx, "example", &ecr.RepositoryCreationTemplateArgs{
EncryptionConfigurations: ecr.RepositoryCreationTemplateEncryptionConfigurationArray{
&ecr.RepositoryCreationTemplateEncryptionConfigurationArgs{
EncryptionType: pulumi.String("AES256"),
},
},
Prefix: pulumi.String("example"),
Description: pulumi.String("An example template"),
ImageTagMutability: pulumi.String("IMMUTABLE"),
CustomRoleArn: pulumi.String("arn:aws:iam::123456789012:role/example"),
AppliedFors: pulumi.StringArray{
pulumi.String("PULL_THROUGH_CACHE"),
},
RepositoryPolicy: pulumi.String(example.Json),
LifecyclePolicy: pulumi.String(`{
\"rules\": [
{
\"rulePriority\": 1,
\"description\": \"Expire images older than 14 days\",
\"selection\": {
\"tagStatus\": \"untagged\",
\"countType\": \"sinceImagePushed\",
\"countUnit\": \"days\",
\"countNumber\": 14
},
\"action\": {
\"type\": \"expire\"
}
}
]
}
`),
ResourceTags: pulumi.StringMap{
"Foo": pulumi.String("Bar"),
},
})
if err != nil {
return err
}
return nil
})
}
pulumi {
required_providers {
aws = {
source = "pulumi/aws"
}
}
}
data "aws_iam_getpolicydocument" "example" {
statements {
principals {
type = "AWS"
identifiers = ["123456789012"]
}
sid = "new policy"
effect = "Allow"
actions = ["ecr:GetDownloadUrlForLayer", "ecr:BatchGetImage", "ecr:BatchCheckLayerAvailability", "ecr:PutImage", "ecr:InitiateLayerUpload", "ecr:UploadLayerPart", "ecr:CompleteLayerUpload", "ecr:DescribeRepositories", "ecr:GetRepositoryPolicy", "ecr:ListImages", "ecr:DeleteRepository", "ecr:BatchDeleteImage", "ecr:SetRepositoryPolicy", "ecr:DeleteRepositoryPolicy"]
}
}
resource "aws_ecr_repositorycreationtemplate" "example" {
encryption_configurations {
encryption_type = "AES256"
}
prefix = "example"
description = "An example template"
image_tag_mutability = "IMMUTABLE"
custom_role_arn = "arn:aws:iam::123456789012:role/example"
applied_fors = ["PULL_THROUGH_CACHE"]
repository_policy = data.aws_iam_getpolicydocument.example.json
lifecycle_policy = "{\n \\\"rules\\\": [\n {\n \\\"rulePriority\\\": 1,\n \\\"description\\\": \\\"Expire images older than 14 days\\\",\n \\\"selection\\\": {\n \\\"tagStatus\\\": \\\"untagged\\\",\n \\\"countType\\\": \\\"sinceImagePushed\\\",\n \\\"countUnit\\\": \\\"days\\\",\n \\\"countNumber\\\": 14\n },\n \\\"action\\\": {\n \\\"type\\\": \\\"expire\\\"\n }\n }\n ]\n}\n"
resource_tags = {
"Foo" = "Bar"
}
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.iam.IamFunctions;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementPrincipalArgs;
import com.pulumi.aws.ecr.RepositoryCreationTemplate;
import com.pulumi.aws.ecr.RepositoryCreationTemplateArgs;
import com.pulumi.aws.ecr.inputs.RepositoryCreationTemplateEncryptionConfigurationArgs;
import java.util.ArrayList;
import java.util.Arrays;
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) {
final var example = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
.statements(GetPolicyDocumentStatementArgs.builder()
.principals(GetPolicyDocumentStatementPrincipalArgs.builder()
.type("AWS")
.identifiers("123456789012")
.build())
.sid("new policy")
.effect("Allow")
.actions(
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage",
"ecr:BatchCheckLayerAvailability",
"ecr:PutImage",
"ecr:InitiateLayerUpload",
"ecr:UploadLayerPart",
"ecr:CompleteLayerUpload",
"ecr:DescribeRepositories",
"ecr:GetRepositoryPolicy",
"ecr:ListImages",
"ecr:DeleteRepository",
"ecr:BatchDeleteImage",
"ecr:SetRepositoryPolicy",
"ecr:DeleteRepositoryPolicy")
.build())
.build());
var exampleRepositoryCreationTemplate = new RepositoryCreationTemplate("exampleRepositoryCreationTemplate", RepositoryCreationTemplateArgs.builder()
.encryptionConfigurations(RepositoryCreationTemplateEncryptionConfigurationArgs.builder()
.encryptionType("AES256")
.build())
.prefix("example")
.description("An example template")
.imageTagMutability("IMMUTABLE")
.customRoleArn("arn:aws:iam::123456789012:role/example")
.appliedFors("PULL_THROUGH_CACHE")
.repositoryPolicy(example.json())
.lifecyclePolicy("""
{
\"rules\": [
{
\"rulePriority\": 1,
\"description\": \"Expire images older than 14 days\",
\"selection\": {
\"tagStatus\": \"untagged\",
\"countType\": \"sinceImagePushed\",
\"countUnit\": \"days\",
\"countNumber\": 14
},
\"action\": {
\"type\": \"expire\"
}
}
]
}
""")
.resourceTags(Map.of("Foo", "Bar"))
.build());
}
}
resources:
exampleRepositoryCreationTemplate:
type: aws:ecr:RepositoryCreationTemplate
name: example
properties:
encryptionConfigurations:
- encryptionType: AES256
prefix: example
description: An example template
imageTagMutability: IMMUTABLE
customRoleArn: arn:aws:iam::123456789012:role/example
appliedFors:
- PULL_THROUGH_CACHE
repositoryPolicy: ${example.json}
lifecyclePolicy: |
{
\"rules\": [
{
\"rulePriority\": 1,
\"description\": \"Expire images older than 14 days\",
\"selection\": {
\"tagStatus\": \"untagged\",
\"countType\": \"sinceImagePushed\",
\"countUnit\": \"days\",
\"countNumber\": 14
},
\"action\": {
\"type\": \"expire\"
}
}
]
}
resourceTags:
Foo: Bar
variables:
example:
fn::invoke:
function: aws:iam:getPolicyDocument
arguments:
statements:
- principals:
- type: AWS
identifiers:
- '123456789012'
sid: new policy
effect: Allow
actions:
- ecr:GetDownloadUrlForLayer
- ecr:BatchGetImage
- ecr:BatchCheckLayerAvailability
- ecr:PutImage
- ecr:InitiateLayerUpload
- ecr:UploadLayerPart
- ecr:CompleteLayerUpload
- ecr:DescribeRepositories
- ecr:GetRepositoryPolicy
- ecr:ListImages
- ecr:DeleteRepository
- ecr:BatchDeleteImage
- ecr:SetRepositoryPolicy
- ecr:DeleteRepositoryPolicy
Import
Using pulumi import, import the ECR Repository Creating Templates using the prefix. For example:
$ pulumi import aws:ecr/repositoryCreationTemplate:RepositoryCreationTemplate example example
Constructors
- RepositoryCreationTemplate(String name, {RepositoryCreationTemplateArgs? args, CustomResourceOptions? options})
-
Creates a new RepositoryCreationTemplate.
nameThe Pulumi resource name.argsArguments used to configure this RepositoryCreationTemplate. The set of arguments for RepositoryCreationTemplate.optionsResource options controlling this resource's behavior. - RepositoryCreationTemplate.reference(String urn)
- Creates a typed reference to an existing RepositoryCreationTemplate resource.
Properties
-
appliedFors
↔ Output<
List< String> > -
Which features this template applies to. Must contain one or more of
CREATE_ON_PUSH,PULL_THROUGH_CACHE, orREPLICATION.latefinal -
childResources
→ Set<
Resource> -
finalinherited
-
completionSources
↔ Map<
String, IOutputCompletionSource> -
latefinalinherited
-
customRoleArn
↔ Output<
String?> -
A custom IAM role to use for repository creation. Required if using repository tags or KMS encryption.
latefinal
-
description
↔ Output<
String?> -
The description for this template.
latefinal
-
encryptionConfigurations
↔ Output<
List< RepositoryCreationTemplateEncryptionConfiguration> ?> -
Encryption configuration for any created repositories. See below for schema.
latefinal
- hashCode → int
-
The hash code for this object.
no setterinherited
-
id
↔ Output<
String> -
getter/setter pairinherited
-
imageTagMutability
↔ Output<
String?> -
The tag mutability setting for any created repositories. Must be one of:
MUTABLE,IMMUTABLE,IMMUTABLE_WITH_EXCLUSION, orMUTABLE_WITH_EXCLUSION. Defaults toMUTABLE.latefinal -
imageTagMutabilityExclusionFilters
↔ Output<
List< RepositoryCreationTemplateImageTagMutabilityExclusionFilter> ?> -
Configuration block that defines filters to specify which image tags can override the default tag mutability setting. Only applicable when
imageTagMutabilityis set toIMMUTABLE_WITH_EXCLUSIONorMUTABLE_WITH_EXCLUSION. See below for schema.latefinal - isCustom → bool
-
Returns whether this resource is provider-managed.
no setterinherited
- isProtected → bool
-
Returns whether this resource is protected from deletion.
no setterinherited
- isRemote → bool
-
Whether this resource is registered as remote.
no setterinherited
- isResourceReference → bool
-
Whether this instance represents a resource value returned over RPC.
finalinherited
-
lifecyclePolicy
↔ Output<
String?> -
The lifecycle policy document to apply to any created repositories. See more details about Policy Parameters in the official AWS docs. Consider using the
aws.ecr.getLifecyclePolicyDocumentdataSource to generate/manage the JSON document used for thelifecyclePolicyargument.latefinal -
prefix
↔ Output<
String> -
The repository name prefix to match against. Use
ROOTto match any prefix that doesn't explicitly match another template.latefinal -
region
↔ Output<
String> -
Region where this resource will be managed. Defaults to the Region set in the provider configuration.
latefinal
-
registryId
↔ Output<
String> -
The registry ID the repository creation template applies to.
latefinal
-
repositoryPolicy
↔ Output<
String?> -
The registry policy document to apply to any created repositories. This is a JSON formatted string. For more information about building IAM policy documents with Terraform, see the AWS IAM Policy Document Guide.
latefinal
-
resourceTags
↔ Output<
Map< String, String> ?> -
A map of tags to assign to any created repositories.
latefinal
-
resourceTransforms
→ List<
ResourceTransform> -
Inherited/explicit async transforms.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
transformations
→ List<
ResourceTransformation> -
Inherited/explicit legacy transformations.
no setterinherited
-
urn
↔ Output<
String> -
latefinalinherited
Methods
-
failId(
Object error) → void -
Completes this resource ID with an error when registration fails.
inherited
-
failOutputs(
Object error) → void -
Completes all output properties with
error.inherited -
failUrn(
Object error) → void -
Completes this resource URN with an error when registration fails.
inherited
-
getProvider(
String moduleMember) → ProviderResource? -
Returns provider for
moduleMember's package, if configured.inherited -
getResourceName(
) → String -
Returns this resource's logical name.
inherited
-
getResourceType(
) → String -
Returns this resource's Pulumi type token.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
registerOutput<
T> (String propertyName, {Object? decoder(Object?)?, bool isSecret = false}) → Output< T> -
Registers a dynamic output property for this resource.
inherited
-
resolveId(
String? value, {required bool isKnown}) → void -
Resolves the provider-assigned ID for this resource.
inherited
-
resolveOutputs(
Struct outputs) → void -
Resolves all output properties from a monitor response payload.
inherited
-
resolveUrn(
String value) → void -
Resolves this resource's URN once assigned by the engine.
inherited
-
serializeProperties(
Map< String, dynamic> properties) → Future<Struct> -
Serializes resource properties for RPC transmission.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
get(
String name, Input< String> id, {RepositoryCreationTemplateState? state, CustomResourceOptions? options}) → RepositoryCreationTemplate -
Gets an existing RepositoryCreationTemplate resource's state with the given
nameandid.