class LifecyclePolicy (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.ImageBuilder.Alpha.LifecyclePolicy |
Go | github.com/aws/aws-cdk-go/awsimagebuilderalpha/v2#LifecyclePolicy |
Java | software.amazon.awscdk.services.imagebuilder.alpha.LifecyclePolicy |
Python | aws_cdk.aws_imagebuilder_alpha.LifecyclePolicy |
TypeScript (source) | @aws-cdk/aws-imagebuilder-alpha ยป LifecyclePolicy |
Implements
IConstruct, IDependable, IResource, IEnvironment, ILifecycle
Represents an EC2 Image Builder Lifecycle Policy.
Example
const disabledPolicy = new imagebuilder.LifecyclePolicy(this, 'DisabledPolicy', {
lifecyclePolicyName: 'my-disabled-policy',
description: 'A lifecycle policy that is temporarily disabled',
status: imagebuilder.LifecyclePolicyStatus.DISABLED,
resourceType: imagebuilder.LifecyclePolicyResourceType.AMI_IMAGE,
details: [
{
action: { type: imagebuilder.LifecyclePolicyActionType.DELETE },
filter: { ageFilter: { age: Duration.days(30) } }
}
],
resourceSelection: {
tags: { Environment: 'testing' }
},
tags: {
Owner: 'DevOps',
CostCenter: 'Engineering'
}
});
Initializer
new LifecyclePolicy(scope: Construct, id: string, props: LifecyclePolicyProps)
Parameters
- scope
Construct - id
string - props
LifecyclePolicy Props
Construct Props
| Name | Type | Description |
|---|---|---|
| details | Lifecycle[] | Configuration details for the lifecycle policy rules. |
| resource | Lifecycle | Selection criteria for the resources that the lifecycle policy applies to. |
| resource | Lifecycle | The type of Image Builder resource that the lifecycle policy applies to. |
| description? | string | The description of the lifecycle policy. |
| execution | IRole | The execution role that grants Image Builder access to run lifecycle actions. |
| lifecycle | string | The name of the lifecycle policy. |
| status? | Lifecycle | The status of the lifecycle policy. |
| tags? | { [string]: string } | The tags to apply to the lifecycle policy. |
details
Type:
Lifecycle[]
Configuration details for the lifecycle policy rules.
resourceSelection
Type:
Lifecycle
Selection criteria for the resources that the lifecycle policy applies to.
resourceType
Type:
Lifecycle
The type of Image Builder resource that the lifecycle policy applies to.
description?
Type:
string
(optional, default: None)
The description of the lifecycle policy.
executionRole?
Type:
IRole
(optional, default: an execution role will be generated)
The execution role that grants Image Builder access to run lifecycle actions.
By default, an execution role will be created with the minimal permissions needed to execute the lifecycle policy actions.
lifecyclePolicyName?
Type:
string
(optional, default: a name is generated)
The name of the lifecycle policy.
status?
Type:
Lifecycle
(optional, default: LifecyclePolicyStatus.ENABLED)
The status of the lifecycle policy.
tags?
Type:
{ [string]: string }
(optional, default: none)
The tags to apply to the lifecycle policy.
Properties
| Name | Type | Description |
|---|---|---|
| env | Resource | The environment this resource belongs to. |
| execution | IRole | The execution role used for lifecycle policy executions. |
| lifecycle | string | The ARN of the lifecycle policy. |
| lifecycle | string | The name of the lifecycle policy. |
| node | Node | The tree node. |
| stack | Stack | The stack in which this resource is defined. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
env
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
executionRole
Type:
IRole
The execution role used for lifecycle policy executions.
lifecyclePolicyArn
Type:
string
The ARN of the lifecycle policy.
lifecyclePolicyName
Type:
string
The name of the lifecycle policy.
node
Type:
Node
The tree node.
stack
Type:
Stack
The stack in which this resource is defined.
static PROPERTY_INJECTION_ID
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| apply | Apply the given removal policy to this resource. |
| grant(grantee, ...actions) | Grant custom actions to the given grantee for the lifecycle policy. |
| grant | Grant read permissions to the given grantee for the lifecycle policy. |
| to | Returns a string representation of this construct. |
| static from | Import an existing lifecycle policy given its ARN. |
| static from | Import an existing lifecycle policy given its name. |
| static is | Return whether the given object is a LifecyclePolicy. |
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
grant(grantee, ...actions)
public grant(grantee: IGrantable, ...actions: string[]): Grant
Parameters
- grantee
IGrantable - actions
string
Returns
Grant custom actions to the given grantee for the lifecycle policy.
grantRead(grantee)
public grantRead(grantee: IGrantable): Grant
Parameters
- grantee
IGrantable
Returns
Grant read permissions to the given grantee for the lifecycle policy.
toString()
public toString(): string
Returns
string
Returns a string representation of this construct.
static fromLifecyclePolicyArn(scope, id, lifecyclePolicyArn)
public static fromLifecyclePolicyArn(scope: Construct, id: string, lifecyclePolicyArn: string): ILifecyclePolicy
Parameters
- scope
Construct - id
string - lifecyclePolicyArn
string
Returns
Import an existing lifecycle policy given its ARN.
static fromLifecyclePolicyName(scope, id, lifecyclePolicyName)
public static fromLifecyclePolicyName(scope: Construct, id: string, lifecyclePolicyName: string): ILifecyclePolicy
Parameters
- scope
Construct - id
string - lifecyclePolicyName
string
Returns
Import an existing lifecycle policy given its name.
If the name is a token representing a dynamic CloudFormation expression, you must ensure all alphabetic characters in the expression are already lowercased
static isLifecyclePolicy(x)
public static isLifecyclePolicy(x: any): boolean
Parameters
- x
any
Returns
boolean
Return whether the given object is a LifecyclePolicy.

.NET
Go
Java
Python
TypeScript (