AWS::ImageBuilder::LifecyclePolicy - AWS CloudFormation
Services or capabilities described in AWS documentation might vary by Region. To see the differences applicable to the AWS European Sovereign Cloud Region, see the AWS European Sovereign Cloud User Guide.

This is the new CloudFormation Template Reference Guide. Please update your bookmarks and links. For help getting started with CloudFormation, see the AWS CloudFormation User Guide.

AWS::ImageBuilder::LifecyclePolicy

Create a lifecycle policy resource.

Syntax

To declare this entity in your CloudFormation template, use the following syntax:

JSON

{ "Type" : "AWS::ImageBuilder::LifecyclePolicy", "Properties" : { "Description" : String, "ExecutionRole" : String, "Name" : String, "PolicyDetails" : [ PolicyDetail, ... ], "ResourceSelection" : ResourceSelection, "ResourceType" : String, "Status" : String, "Tags" : {Key: Value, ...} } }

YAML

Type: AWS::ImageBuilder::LifecyclePolicy Properties: Description: String ExecutionRole: String Name: String PolicyDetails: - PolicyDetail ResourceSelection: ResourceSelection ResourceType: String Status: String Tags: Key: Value

Properties

Description

Optional description for the lifecycle policy.

Required: No

Type: String

Minimum: 1

Maximum: 1024

Update requires: No interruption

ExecutionRole

The name or Amazon Resource Name (ARN) for the IAM role you create that grants Image Builder access to run lifecycle actions.

Required: Yes

Type: String

Pattern: ^(?:arn:aws(?:-[a-z]+)*:iam::[0-9]{12}:role/)?[a-zA-Z_0-9+=,.@\-_/]+$

Minimum: 1

Maximum: 2048

Update requires: No interruption

Name

The name of the lifecycle policy to create.

Required: Yes

Type: String

Pattern: ^[-_A-Za-z-0-9][-_A-Za-z0-9 ]{1,126}[-_A-Za-z-0-9]$

Update requires: Replacement

PolicyDetails

Configuration details for the lifecycle policy rules.

Required: Yes

Type: Array of PolicyDetail

Minimum: 1

Maximum: 3

Update requires: No interruption

ResourceSelection

Selection criteria for the resources that the lifecycle policy applies to.

Required: Yes

Type: ResourceSelection

Update requires: No interruption

ResourceType

The type of Image Builder resource that the lifecycle policy applies to.

Required: Yes

Type: String

Allowed values: AMI_IMAGE | CONTAINER_IMAGE

Update requires: No interruption

Status

Indicates whether the lifecycle policy resource is enabled.

Required: No

Type: String

Allowed values: DISABLED | ENABLED

Update requires: No interruption

Tags

Tags to apply to the lifecycle policy resource.

Required: No

Type: Object of String

Pattern: .{1,}

Update requires: No interruption

Return values

Ref

When you pass the logical ID of this resource to the intrinsic Ref function, Ref returns the resource ARN, such as arn:aws:imagebuilder:us-west-2:111122223333:lifecycle-policy/my-example-policy.

For more information about using the Ref function, see Ref.

Fn::GetAtt

The Fn::GetAtt intrinsic function returns a value for a specified attribute of this type. The following are the available attributes and sample return values.

For more information about using the Fn::GetAtt intrinsic function, see Fn::GetAtt.

Arn

The Amazon Resource Name (ARN) of the lifecycle policy resource.

Examples

Create a lifecycle policy that deletes AMIs older than 90 days

The following example creates a lifecycle policy that deletes AMIs older than 90 days, while retaining the three most recent images. The policy applies to images produced by a specific image recipe.

YAML

Resources: LifecyclePolicyExample: Type: AWS::ImageBuilder::LifecyclePolicy Properties: Name: delete-old-amis-policy Description: Delete AMIs older than 90 days Status: ENABLED ResourceType: AMI_IMAGE ExecutionRole: !GetAtt LifecyclePolicyRole.Arn PolicyDetails: - Action: Type: DELETE IncludeResources: Amis: true Snapshots: true Filter: Type: AGE Value: 90 Unit: DAYS RetainAtLeast: 3 ExclusionRules: Amis: IsPublic: true TagMap: DoNotDelete: 'true' ResourceSelection: Recipes: - Name: my-image-recipe SemanticVersion: '1.0.0' Tags: Purpose: cleanup

JSON

{ "Resources": { "LifecyclePolicyExample": { "Type": "AWS::ImageBuilder::LifecyclePolicy", "Properties": { "Name": "delete-old-amis-policy", "Description": "Delete AMIs older than 90 days", "Status": "ENABLED", "ResourceType": "AMI_IMAGE", "ExecutionRole": { "Fn::GetAtt": ["LifecyclePolicyRole", "Arn"] }, "PolicyDetails": [ { "Action": { "Type": "DELETE", "IncludeResources": { "Amis": true, "Snapshots": true } }, "Filter": { "Type": "AGE", "Value": 90, "Unit": "DAYS", "RetainAtLeast": 3 }, "ExclusionRules": { "Amis": { "IsPublic": true, "TagMap": { "DoNotDelete": "true" } } } } ], "ResourceSelection": { "Recipes": [ { "Name": "my-image-recipe", "SemanticVersion": "1.0.0" } ] }, "Tags": { "Purpose": "cleanup" } } } } }

See also