@pulumi/aws
Version:
A Pulumi package for creating and managing Amazon Web Services (AWS) cloud resources.
171 lines (170 loc) • 7.05 kB
TypeScript
import * as pulumi from "@pulumi/pulumi";
import * as inputs from "../types/input";
/**
* 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
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.ecr.Repository("example", {name: "example-repo"});
* const exampleLifecyclePolicy = new aws.ecr.LifecyclePolicy("example", {
* repository: example.name,
* policy: `{
* \\"rules\\": [
* {
* \\"rulePriority\\": 1,
* \\"description\\": \\"Expire images older than 14 days\\",
* \\"selection\\": {
* \\"tagStatus\\": \\"untagged\\",
* \\"countType\\": \\"sinceImagePushed\\",
* \\"countUnit\\": \\"days\\",
* \\"countNumber\\": 14
* },
* \\"action\\": {
* \\"type\\": \\"expire\\"
* }
* }
* ]
* }
* `,
* });
* ```
*
* ### Policy on tagged image
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as aws from "@pulumi/aws";
*
* const example = new aws.ecr.Repository("example", {name: "example-repo"});
* const exampleLifecyclePolicy = new aws.ecr.LifecyclePolicy("example", {
* repository: example.name,
* policy: `{
* \\"rules\\": [
* {
* \\"rulePriority\\": 1,
* \\"description\\": \\"Keep last 30 images\\",
* \\"selection\\": {
* \\"tagStatus\\": \\"tagged\\",
* \\"tagPrefixList\\": [\\"v\\"],
* \\"countType\\": \\"imageCountMoreThan\\",
* \\"countNumber\\": 30
* },
* \\"action\\": {
* \\"type\\": \\"expire\\"
* }
* }
* ]
* }
* `,
* });
* ```
*
* ## Import
*
* ### Identity Schema
*
* #### Required
*
* * `repository` - (String) Name of the ECR repository.
*
* #### Optional
*
* * `account_id` (String) AWS Account where this resource is managed.
*
* * `region` (String) Region where this resource is managed.
*
* Using `pulumi import`, import ECR Lifecycle Policy using the name of the repository. For example:
*
* console
*
* % pulumi import aws_ecr_lifecycle_policy.example tf-example
*/
export declare class LifecyclePolicy extends pulumi.CustomResource {
/**
* Get an existing LifecyclePolicy resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name: string, id: pulumi.Input<pulumi.ID>, state?: LifecyclePolicyState, opts?: pulumi.CustomResourceOptions): LifecyclePolicy;
/**
* Returns true if the given object is an instance of LifecyclePolicy. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj: any): obj is LifecyclePolicy;
/**
* The policy document. This is a JSON formatted string. See more details about [Policy Parameters](http://docs.aws.amazon.com/AmazonECR/latest/userguide/LifecyclePolicies.html#lifecycle_policy_parameters) in the official AWS docs. Consider using the `aws.ecr.getLifecyclePolicyDocument` dataSource to generate/manage the JSON document used for the `policy` argument.
*/
readonly policy: pulumi.Output<string>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
readonly region: pulumi.Output<string>;
/**
* The registry ID where the repository was created.
*/
readonly registryId: pulumi.Output<string>;
/**
* Name of the repository to apply the policy.
*/
readonly repository: pulumi.Output<string>;
/**
* Create a LifecyclePolicy resource with the given unique name, arguments, and options.
*
* @param name The _unique_ name of the resource.
* @param args The arguments to use to populate this resource's properties.
* @param opts A bag of options that control this resource's behavior.
*/
constructor(name: string, args: LifecyclePolicyArgs, opts?: pulumi.CustomResourceOptions);
}
/**
* Input properties used for looking up and filtering LifecyclePolicy resources.
*/
export interface LifecyclePolicyState {
/**
* The policy document. This is a JSON formatted string. See more details about [Policy Parameters](http://docs.aws.amazon.com/AmazonECR/latest/userguide/LifecyclePolicies.html#lifecycle_policy_parameters) in the official AWS docs. Consider using the `aws.ecr.getLifecyclePolicyDocument` dataSource to generate/manage the JSON document used for the `policy` argument.
*/
policy?: pulumi.Input<string | inputs.ecr.LifecyclePolicyDocument>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
region?: pulumi.Input<string>;
/**
* The registry ID where the repository was created.
*/
registryId?: pulumi.Input<string>;
/**
* Name of the repository to apply the policy.
*/
repository?: pulumi.Input<string>;
}
/**
* The set of arguments for constructing a LifecyclePolicy resource.
*/
export interface LifecyclePolicyArgs {
/**
* The policy document. This is a JSON formatted string. See more details about [Policy Parameters](http://docs.aws.amazon.com/AmazonECR/latest/userguide/LifecyclePolicies.html#lifecycle_policy_parameters) in the official AWS docs. Consider using the `aws.ecr.getLifecyclePolicyDocument` dataSource to generate/manage the JSON document used for the `policy` argument.
*/
policy: pulumi.Input<string | inputs.ecr.LifecyclePolicyDocument>;
/**
* Region where this resource will be [managed](https://docs.aws.amazon.com/general/latest/gr/rande.html#regional-endpoints). Defaults to the Region set in the provider configuration.
*/
region?: pulumi.Input<string>;
/**
* Name of the repository to apply the policy.
*/
repository: pulumi.Input<string>;
}