Class LifecyclePolicy
Manages an ECR repository lifecycle policy.
NOTE: Only one
aws.ecr.LifecyclePolicyresource can be used with the same ECR repository. To apply multiple rules, they must be combined in thepolicyJSON.
NOTE: The AWS ECR API seems to reorder rules based on
rulePriority. If you define multiple rules that are not sorted in ascendingrulePriorityorder 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,
});
}
}
Inherited Members
Namespace: Pulumi.Aws.Ecr
Assembly: Pulumi.Aws.dll
Syntax
public class LifecyclePolicy : CustomResource
Constructors
View SourceLifecyclePolicy(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 SourcePolicy
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> |
RegistryId
The registry ID where the repository was created.
Declaration
public Output<string> RegistryId { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Repository
Name of the repository to apply the policy.
Declaration
public Output<string> Repository { get; }
Property Value
| Type | Description |
|---|---|
| Output<System.String> |
Methods
View SourceGet(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 |