Show / Hide Table of Contents

Class LifecyclePolicy

Manages an ECR repository lifecycle policy.

NOTE: Only one aws.ecr.LifecyclePolicy resource can be used with the same ECR repository. To apply multiple rules, they must be combined in the policy JSON.

NOTE: The AWS ECR API seems to reorder rules based on rulePriority. If you define multiple rules that are not sorted in ascending rulePriority order in the this provider code, the resource will be flagged for recreation every deployment.

Example Usage

Policy on untagged image

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var foo = new Aws.Ecr.Repository("foo", new Aws.Ecr.RepositoryArgs
    {
    });
    var foopolicy = new Aws.Ecr.LifecyclePolicy("foopolicy", new Aws.Ecr.LifecyclePolicyArgs
    {
        Policy = @"{
""rules"": [
    {
        ""rulePriority"": 1,
        ""description"": ""Expire images older than 14 days"",
        ""selection"": {
            ""tagStatus"": ""untagged"",
            ""countType"": ""sinceImagePushed"",
            ""countUnit"": ""days"",
            ""countNumber"": 14
        },
        ""action"": {
            ""type"": ""expire""
        }
    }
]
}

",
        Repository = foo.Name,
    });
}

}

Policy on tagged image

using Pulumi;
using Aws = Pulumi.Aws;

class MyStack : Stack
{
public MyStack()
{
    var foo = new Aws.Ecr.Repository("foo", new Aws.Ecr.RepositoryArgs
    {
    });
    var foopolicy = new Aws.Ecr.LifecyclePolicy("foopolicy", new Aws.Ecr.LifecyclePolicyArgs
    {
        Policy = @"{
""rules"": [
    {
        ""rulePriority"": 1,
        ""description"": ""Keep last 30 images"",
        ""selection"": {
            ""tagStatus"": ""tagged"",
            ""tagPrefixList"": [""v""],
            ""countType"": ""imageCountMoreThan"",
            ""countNumber"": 30
        },
        ""action"": {
            ""type"": ""expire""
        }
    }
]
}

",
        Repository = foo.Name,
    });
}

}
Inheritance
System.Object
Resource
CustomResource
LifecyclePolicy
Inherited Members
CustomResource.Id
Resource.GetResourceType()
Resource.GetResourceName()
Resource.Urn
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Pulumi.Aws.Ecr
Assembly: Pulumi.Aws.dll
Syntax
public class LifecyclePolicy : CustomResource

Constructors

View Source

LifecyclePolicy(String, LifecyclePolicyArgs, CustomResourceOptions)

Create a LifecyclePolicy resource with the given unique name, arguments, and options.

Declaration
public LifecyclePolicy(string name, LifecyclePolicyArgs args, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resource

LifecyclePolicyArgs args

The arguments used to populate this resource's properties

CustomResourceOptions options

A bag of options that control this resource's behavior

Properties

View Source

Policy

The policy document. This is a JSON formatted string. See more details about Policy Parameters in the official AWS docs.

Declaration
public Output<string> Policy { get; }
Property Value
Type Description
Output<System.String>
View Source

RegistryId

The registry ID where the repository was created.

Declaration
public Output<string> RegistryId { get; }
Property Value
Type Description
Output<System.String>
View Source

Repository

Name of the repository to apply the policy.

Declaration
public Output<string> Repository { get; }
Property Value
Type Description
Output<System.String>

Methods

View Source

Get(String, Input<String>, LifecyclePolicyState, CustomResourceOptions)

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

Declaration
public static LifecyclePolicy Get(string name, Input<string> id, LifecyclePolicyState state = null, CustomResourceOptions options = null)
Parameters
Type Name Description
System.String name

The unique name of the resulting resource.

Input<System.String> id

The unique provider ID of the resource to lookup.

LifecyclePolicyState state

Any extra arguments used during the lookup.

CustomResourceOptions options

A bag of options that control this resource's behavior

Returns
Type Description
LifecyclePolicy
  • View Source
Back to top Copyright 2016-2020, Pulumi Corporation.