updateLifecyclePolicy
abstract suspend fun updateLifecyclePolicy(input: UpdateLifecyclePolicyRequest): UpdateLifecyclePolicyResponse
Updates the specified lifecycle policy. The request replaces the existing policy configuration rather than merging changes, so re-specify every setting that you want to keep. The resourceType must match the existing policy's value.
Samples
// The following example updates a lifecycle policy to delete AMI images and their associated snapshots
// after 12 months, retaining the 3 most recent images.
val resp = imagebuilderClient.updateLifecyclePolicy {
lifecyclePolicyArn = "arn:aws:imagebuilder:us-west-2:111122223333:lifecycle-policy/my-example-policy"
description = "Deletes AMI images and their snapshots after 12 months, retaining the 3 most recent"
status = LifecyclePolicyStatus.fromValue("ENABLED")
executionRole = "arn:aws:iam::111122223333:role/my-example-lifecycle-role"
resourceType = LifecyclePolicyResourceType.fromValue("AMI_IMAGE")
policyDetails = listOf<LifecyclePolicyDetail>(
LifecyclePolicyDetail {
action = LifecyclePolicyDetailAction {
type = LifecyclePolicyDetailActionType.fromValue("DELETE")
includeResources = LifecyclePolicyDetailActionIncludeResources {
amis = true
snapshots = true
}
}
filter = LifecyclePolicyDetailFilter {
type = LifecyclePolicyDetailFilterType.fromValue("AGE")
value = 12
unit = LifecyclePolicyTimeUnit.fromValue("MONTHS")
retainAtLeast = 3
}
}
)
resourceSelection = LifecyclePolicyResourceSelection {
tagMap = mapOf<String, String>(
"environment" to "production"
)
}
clientToken = "a1b2c3d4-5678-90ab-cdef-EXAMPLEaaaaa"
}Content copied to clipboard