AWS v6.60.0 published on Tuesday, Nov 19, 2024 by Pulumi
aws.ecr.getLifecyclePolicyDocument
Explore with Pulumi AI
Generates an ECR lifecycle policy document in JSON format. Can be used with resources such as the aws.ecr.LifecyclePolicy
resource.
For more information about building AWS ECR lifecycle policy documents, see the AWS ECR Lifecycle Policy Document Guide.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as aws from "@pulumi/aws";
const example = aws.ecr.getLifecyclePolicyDocument({
rules: [{
priority: 1,
description: "This is a test.",
selection: {
tagStatus: "tagged",
tagPrefixLists: ["prod"],
countType: "imageCountMoreThan",
countNumber: 100,
},
}],
});
const exampleLifecyclePolicy = new aws.ecr.LifecyclePolicy("example", {
repository: exampleAwsEcrRepository.name,
policy: example.then(example => example.json),
});
import pulumi
import pulumi_aws as aws
example = aws.ecr.get_lifecycle_policy_document(rules=[{
"priority": 1,
"description": "This is a test.",
"selection": {
"tag_status": "tagged",
"tag_prefix_lists": ["prod"],
"count_type": "imageCountMoreThan",
"count_number": 100,
},
}])
example_lifecycle_policy = aws.ecr.LifecyclePolicy("example",
repository=example_aws_ecr_repository["name"],
policy=example.json)
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 {
example, err := ecr.GetLifecyclePolicyDocument(ctx, &ecr.GetLifecyclePolicyDocumentArgs{
Rules: []ecr.GetLifecyclePolicyDocumentRule{
{
Priority: 1,
Description: pulumi.StringRef("This is a test."),
Selection: {
TagStatus: "tagged",
TagPrefixLists: []string{
"prod",
},
CountType: "imageCountMoreThan",
CountNumber: 100,
},
},
},
}, nil)
if err != nil {
return err
}
_, err = ecr.NewLifecyclePolicy(ctx, "example", &ecr.LifecyclePolicyArgs{
Repository: pulumi.Any(exampleAwsEcrRepository.Name),
Policy: pulumi.String(example.Json),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;
return await Deployment.RunAsync(() =>
{
var example = Aws.Ecr.GetLifecyclePolicyDocument.Invoke(new()
{
Rules = new[]
{
new Aws.Ecr.Inputs.GetLifecyclePolicyDocumentRuleInputArgs
{
Priority = 1,
Description = "This is a test.",
Selection = new Aws.Ecr.Inputs.GetLifecyclePolicyDocumentRuleSelectionInputArgs
{
TagStatus = "tagged",
TagPrefixLists = new[]
{
"prod",
},
CountType = "imageCountMoreThan",
CountNumber = 100,
},
},
},
});
var exampleLifecyclePolicy = new Aws.Ecr.LifecyclePolicy("example", new()
{
Repository = exampleAwsEcrRepository.Name,
Policy = example.Apply(getLifecyclePolicyDocumentResult => getLifecyclePolicyDocumentResult.Json),
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.aws.ecr.EcrFunctions;
import com.pulumi.aws.ecr.inputs.GetLifecyclePolicyDocumentArgs;
import com.pulumi.aws.ecr.LifecyclePolicy;
import com.pulumi.aws.ecr.LifecyclePolicyArgs;
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) {
final var example = EcrFunctions.getLifecyclePolicyDocument(GetLifecyclePolicyDocumentArgs.builder()
.rules(GetLifecyclePolicyDocumentRuleArgs.builder()
.priority(1)
.description("This is a test.")
.selection(GetLifecyclePolicyDocumentRuleSelectionArgs.builder()
.tagStatus("tagged")
.tagPrefixLists("prod")
.countType("imageCountMoreThan")
.countNumber(100)
.build())
.build())
.build());
var exampleLifecyclePolicy = new LifecyclePolicy("exampleLifecyclePolicy", LifecyclePolicyArgs.builder()
.repository(exampleAwsEcrRepository.name())
.policy(example.applyValue(getLifecyclePolicyDocumentResult -> getLifecyclePolicyDocumentResult.json()))
.build());
}
}
resources:
exampleLifecyclePolicy:
type: aws:ecr:LifecyclePolicy
name: example
properties:
repository: ${exampleAwsEcrRepository.name}
policy: ${example.json}
variables:
example:
fn::invoke:
Function: aws:ecr:getLifecyclePolicyDocument
Arguments:
rules:
- priority: 1
description: This is a test.
selection:
tagStatus: tagged
tagPrefixLists:
- prod
countType: imageCountMoreThan
countNumber: 100
Using getLifecyclePolicyDocument
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getLifecyclePolicyDocument(args: GetLifecyclePolicyDocumentArgs, opts?: InvokeOptions): Promise<GetLifecyclePolicyDocumentResult>
function getLifecyclePolicyDocumentOutput(args: GetLifecyclePolicyDocumentOutputArgs, opts?: InvokeOptions): Output<GetLifecyclePolicyDocumentResult>
def get_lifecycle_policy_document(rules: Optional[Sequence[GetLifecyclePolicyDocumentRule]] = None,
opts: Optional[InvokeOptions] = None) -> GetLifecyclePolicyDocumentResult
def get_lifecycle_policy_document_output(rules: Optional[pulumi.Input[Sequence[pulumi.Input[GetLifecyclePolicyDocumentRuleArgs]]]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetLifecyclePolicyDocumentResult]
func GetLifecyclePolicyDocument(ctx *Context, args *GetLifecyclePolicyDocumentArgs, opts ...InvokeOption) (*GetLifecyclePolicyDocumentResult, error)
func GetLifecyclePolicyDocumentOutput(ctx *Context, args *GetLifecyclePolicyDocumentOutputArgs, opts ...InvokeOption) GetLifecyclePolicyDocumentResultOutput
> Note: This function is named GetLifecyclePolicyDocument
in the Go SDK.
public static class GetLifecyclePolicyDocument
{
public static Task<GetLifecyclePolicyDocumentResult> InvokeAsync(GetLifecyclePolicyDocumentArgs args, InvokeOptions? opts = null)
public static Output<GetLifecyclePolicyDocumentResult> Invoke(GetLifecyclePolicyDocumentInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetLifecyclePolicyDocumentResult> getLifecyclePolicyDocument(GetLifecyclePolicyDocumentArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: aws:ecr/getLifecyclePolicyDocument:getLifecyclePolicyDocument
arguments:
# arguments dictionary
The following arguments are supported:
getLifecyclePolicyDocument Result
The following output properties are available:
- Id string
- The provider-assigned unique ID for this managed resource.
- Json string
- The above arguments serialized as a standard JSON policy document.
- Rules
List<Get
Lifecycle Policy Document Rule>
- Id string
- The provider-assigned unique ID for this managed resource.
- Json string
- The above arguments serialized as a standard JSON policy document.
- Rules
[]Get
Lifecycle Policy Document Rule
- id String
- The provider-assigned unique ID for this managed resource.
- json String
- The above arguments serialized as a standard JSON policy document.
- rules
List<Get
Lifecycle Policy Document Rule>
- id string
- The provider-assigned unique ID for this managed resource.
- json string
- The above arguments serialized as a standard JSON policy document.
- rules
Get
Lifecycle Policy Document Rule[]
- id str
- The provider-assigned unique ID for this managed resource.
- json str
- The above arguments serialized as a standard JSON policy document.
- rules
Sequence[Get
Lifecycle Policy Document Rule]
- id String
- The provider-assigned unique ID for this managed resource.
- json String
- The above arguments serialized as a standard JSON policy document.
- rules List<Property Map>
Supporting Types
GetLifecyclePolicyDocumentRule
- Priority int
- Sets the order in which rules are evaluated, lowest to highest. When you add rules to a lifecycle policy, you must give them each a unique value for
priority
. Values do not need to be sequential across rules in a policy. A rule with atag_status
value of "any" must have the highest value forpriority
and be evaluated last. - Action
Get
Lifecycle Policy Document Rule Action - Specifies the action type.
- Description string
- Describes the purpose of a rule within a lifecycle policy.
- Selection
Get
Lifecycle Policy Document Rule Selection - Collects parameters describing the selection criteria for the ECR lifecycle policy:
- Priority int
- Sets the order in which rules are evaluated, lowest to highest. When you add rules to a lifecycle policy, you must give them each a unique value for
priority
. Values do not need to be sequential across rules in a policy. A rule with atag_status
value of "any" must have the highest value forpriority
and be evaluated last. - Action
Get
Lifecycle Policy Document Rule Action - Specifies the action type.
- Description string
- Describes the purpose of a rule within a lifecycle policy.
- Selection
Get
Lifecycle Policy Document Rule Selection - Collects parameters describing the selection criteria for the ECR lifecycle policy:
- priority Integer
- Sets the order in which rules are evaluated, lowest to highest. When you add rules to a lifecycle policy, you must give them each a unique value for
priority
. Values do not need to be sequential across rules in a policy. A rule with atag_status
value of "any" must have the highest value forpriority
and be evaluated last. - action
Get
Lifecycle Policy Document Rule Action - Specifies the action type.
- description String
- Describes the purpose of a rule within a lifecycle policy.
- selection
Get
Lifecycle Policy Document Rule Selection - Collects parameters describing the selection criteria for the ECR lifecycle policy:
- priority number
- Sets the order in which rules are evaluated, lowest to highest. When you add rules to a lifecycle policy, you must give them each a unique value for
priority
. Values do not need to be sequential across rules in a policy. A rule with atag_status
value of "any" must have the highest value forpriority
and be evaluated last. - action
Get
Lifecycle Policy Document Rule Action - Specifies the action type.
- description string
- Describes the purpose of a rule within a lifecycle policy.
- selection
Get
Lifecycle Policy Document Rule Selection - Collects parameters describing the selection criteria for the ECR lifecycle policy:
- priority int
- Sets the order in which rules are evaluated, lowest to highest. When you add rules to a lifecycle policy, you must give them each a unique value for
priority
. Values do not need to be sequential across rules in a policy. A rule with atag_status
value of "any" must have the highest value forpriority
and be evaluated last. - action
Get
Lifecycle Policy Document Rule Action - Specifies the action type.
- description str
- Describes the purpose of a rule within a lifecycle policy.
- selection
Get
Lifecycle Policy Document Rule Selection - Collects parameters describing the selection criteria for the ECR lifecycle policy:
- priority Number
- Sets the order in which rules are evaluated, lowest to highest. When you add rules to a lifecycle policy, you must give them each a unique value for
priority
. Values do not need to be sequential across rules in a policy. A rule with atag_status
value of "any" must have the highest value forpriority
and be evaluated last. - action Property Map
- Specifies the action type.
- description String
- Describes the purpose of a rule within a lifecycle policy.
- selection Property Map
- Collects parameters describing the selection criteria for the ECR lifecycle policy:
GetLifecyclePolicyDocumentRuleAction
- Type string
- The supported value is
expire
.
- Type string
- The supported value is
expire
.
- type String
- The supported value is
expire
.
- type string
- The supported value is
expire
.
- type str
- The supported value is
expire
.
- type String
- The supported value is
expire
.
GetLifecyclePolicyDocumentRuleSelection
- Count
Number int - Specify a count number. If the
count_type
used is "imageCountMoreThan", then the value is the maximum number of images that you want to retain in your repository. If thecount_type
used is "sinceImagePushed", then the value is the maximum age limit for your images. - Count
Type string - Specify a count type to apply to the images. If
count_type
is set to "imageCountMoreThan", you also specifycount_number
to create a rule that sets a limit on the number of images that exist in your repository. Ifcount_type
is set to "sinceImagePushed", you also specifycount_unit
andcount_number
to specify a time limit on the images that exist in your repository. - string
- Determines whether the lifecycle policy rule that you are adding specifies a tag for an image. Acceptable options are "tagged", "untagged", or "any". If you specify "any", then all images have the rule applied to them. If you specify "tagged", then you must also specify a
tag_prefix_list
value. If you specify "untagged", then you must omittag_prefix_list
. - Count
Unit string - Specify a count unit of days to indicate that as the unit of time, in addition to
count_number
, which is the number of days. - Tag
Pattern List<string>Lists - You must specify a comma-separated list of image tag patterns that may contain wildcards (*) on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag pattern list["prod\*"]
to specify all of them. If you specify multiple tags, only the images with all specified tags are selected. There is a maximum limit of four wildcards (*) per string. For example,["*test*1*2*3", "test*1*2*3*"]
is valid but["test*1*2*3*4*5*6"]
is invalid. - Tag
Prefix List<string>Lists - You must specify a comma-separated list of image tag prefixes on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag prefix "prod" to specify all of them. If you specify multiple tags, only images with all specified tags are selected.
- Count
Number int - Specify a count number. If the
count_type
used is "imageCountMoreThan", then the value is the maximum number of images that you want to retain in your repository. If thecount_type
used is "sinceImagePushed", then the value is the maximum age limit for your images. - Count
Type string - Specify a count type to apply to the images. If
count_type
is set to "imageCountMoreThan", you also specifycount_number
to create a rule that sets a limit on the number of images that exist in your repository. Ifcount_type
is set to "sinceImagePushed", you also specifycount_unit
andcount_number
to specify a time limit on the images that exist in your repository. - string
- Determines whether the lifecycle policy rule that you are adding specifies a tag for an image. Acceptable options are "tagged", "untagged", or "any". If you specify "any", then all images have the rule applied to them. If you specify "tagged", then you must also specify a
tag_prefix_list
value. If you specify "untagged", then you must omittag_prefix_list
. - Count
Unit string - Specify a count unit of days to indicate that as the unit of time, in addition to
count_number
, which is the number of days. - Tag
Pattern []stringLists - You must specify a comma-separated list of image tag patterns that may contain wildcards (*) on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag pattern list["prod\*"]
to specify all of them. If you specify multiple tags, only the images with all specified tags are selected. There is a maximum limit of four wildcards (*) per string. For example,["*test*1*2*3", "test*1*2*3*"]
is valid but["test*1*2*3*4*5*6"]
is invalid. - Tag
Prefix []stringLists - You must specify a comma-separated list of image tag prefixes on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag prefix "prod" to specify all of them. If you specify multiple tags, only images with all specified tags are selected.
- count
Number Integer - Specify a count number. If the
count_type
used is "imageCountMoreThan", then the value is the maximum number of images that you want to retain in your repository. If thecount_type
used is "sinceImagePushed", then the value is the maximum age limit for your images. - count
Type String - Specify a count type to apply to the images. If
count_type
is set to "imageCountMoreThan", you also specifycount_number
to create a rule that sets a limit on the number of images that exist in your repository. Ifcount_type
is set to "sinceImagePushed", you also specifycount_unit
andcount_number
to specify a time limit on the images that exist in your repository. - String
- Determines whether the lifecycle policy rule that you are adding specifies a tag for an image. Acceptable options are "tagged", "untagged", or "any". If you specify "any", then all images have the rule applied to them. If you specify "tagged", then you must also specify a
tag_prefix_list
value. If you specify "untagged", then you must omittag_prefix_list
. - count
Unit String - Specify a count unit of days to indicate that as the unit of time, in addition to
count_number
, which is the number of days. - tag
Pattern List<String>Lists - You must specify a comma-separated list of image tag patterns that may contain wildcards (*) on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag pattern list["prod\*"]
to specify all of them. If you specify multiple tags, only the images with all specified tags are selected. There is a maximum limit of four wildcards (*) per string. For example,["*test*1*2*3", "test*1*2*3*"]
is valid but["test*1*2*3*4*5*6"]
is invalid. - tag
Prefix List<String>Lists - You must specify a comma-separated list of image tag prefixes on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag prefix "prod" to specify all of them. If you specify multiple tags, only images with all specified tags are selected.
- count
Number number - Specify a count number. If the
count_type
used is "imageCountMoreThan", then the value is the maximum number of images that you want to retain in your repository. If thecount_type
used is "sinceImagePushed", then the value is the maximum age limit for your images. - count
Type string - Specify a count type to apply to the images. If
count_type
is set to "imageCountMoreThan", you also specifycount_number
to create a rule that sets a limit on the number of images that exist in your repository. Ifcount_type
is set to "sinceImagePushed", you also specifycount_unit
andcount_number
to specify a time limit on the images that exist in your repository. - string
- Determines whether the lifecycle policy rule that you are adding specifies a tag for an image. Acceptable options are "tagged", "untagged", or "any". If you specify "any", then all images have the rule applied to them. If you specify "tagged", then you must also specify a
tag_prefix_list
value. If you specify "untagged", then you must omittag_prefix_list
. - count
Unit string - Specify a count unit of days to indicate that as the unit of time, in addition to
count_number
, which is the number of days. - tag
Pattern string[]Lists - You must specify a comma-separated list of image tag patterns that may contain wildcards (*) on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag pattern list["prod\*"]
to specify all of them. If you specify multiple tags, only the images with all specified tags are selected. There is a maximum limit of four wildcards (*) per string. For example,["*test*1*2*3", "test*1*2*3*"]
is valid but["test*1*2*3*4*5*6"]
is invalid. - tag
Prefix string[]Lists - You must specify a comma-separated list of image tag prefixes on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag prefix "prod" to specify all of them. If you specify multiple tags, only images with all specified tags are selected.
- count_
number int - Specify a count number. If the
count_type
used is "imageCountMoreThan", then the value is the maximum number of images that you want to retain in your repository. If thecount_type
used is "sinceImagePushed", then the value is the maximum age limit for your images. - count_
type str - Specify a count type to apply to the images. If
count_type
is set to "imageCountMoreThan", you also specifycount_number
to create a rule that sets a limit on the number of images that exist in your repository. Ifcount_type
is set to "sinceImagePushed", you also specifycount_unit
andcount_number
to specify a time limit on the images that exist in your repository. - tag_
status str - Determines whether the lifecycle policy rule that you are adding specifies a tag for an image. Acceptable options are "tagged", "untagged", or "any". If you specify "any", then all images have the rule applied to them. If you specify "tagged", then you must also specify a
tag_prefix_list
value. If you specify "untagged", then you must omittag_prefix_list
. - count_
unit str - Specify a count unit of days to indicate that as the unit of time, in addition to
count_number
, which is the number of days. - tag_
pattern_ Sequence[str]lists - You must specify a comma-separated list of image tag patterns that may contain wildcards (*) on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag pattern list["prod\*"]
to specify all of them. If you specify multiple tags, only the images with all specified tags are selected. There is a maximum limit of four wildcards (*) per string. For example,["*test*1*2*3", "test*1*2*3*"]
is valid but["test*1*2*3*4*5*6"]
is invalid. - tag_
prefix_ Sequence[str]lists - You must specify a comma-separated list of image tag prefixes on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag prefix "prod" to specify all of them. If you specify multiple tags, only images with all specified tags are selected.
- count
Number Number - Specify a count number. If the
count_type
used is "imageCountMoreThan", then the value is the maximum number of images that you want to retain in your repository. If thecount_type
used is "sinceImagePushed", then the value is the maximum age limit for your images. - count
Type String - Specify a count type to apply to the images. If
count_type
is set to "imageCountMoreThan", you also specifycount_number
to create a rule that sets a limit on the number of images that exist in your repository. Ifcount_type
is set to "sinceImagePushed", you also specifycount_unit
andcount_number
to specify a time limit on the images that exist in your repository. - String
- Determines whether the lifecycle policy rule that you are adding specifies a tag for an image. Acceptable options are "tagged", "untagged", or "any". If you specify "any", then all images have the rule applied to them. If you specify "tagged", then you must also specify a
tag_prefix_list
value. If you specify "untagged", then you must omittag_prefix_list
. - count
Unit String - Specify a count unit of days to indicate that as the unit of time, in addition to
count_number
, which is the number of days. - tag
Pattern List<String>Lists - You must specify a comma-separated list of image tag patterns that may contain wildcards (*) on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag pattern list["prod\*"]
to specify all of them. If you specify multiple tags, only the images with all specified tags are selected. There is a maximum limit of four wildcards (*) per string. For example,["*test*1*2*3", "test*1*2*3*"]
is valid but["test*1*2*3*4*5*6"]
is invalid. - tag
Prefix List<String>Lists - You must specify a comma-separated list of image tag prefixes on which to take action with your lifecycle policy. For example, if your images are tagged as
prod
,prod1
,prod2
, and so on, you would use the tag prefix "prod" to specify all of them. If you specify multiple tags, only images with all specified tags are selected.
Package Details
- Repository
- AWS Classic pulumi/pulumi-aws
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
aws
Terraform Provider.