LifecyclePolicyAmiExclusionRules

class aws_cdk.aws_imagebuilder_alpha.LifecyclePolicyAmiExclusionRules(*, is_public=None, last_launched=None, regions=None, shared_accounts=None, tags=None)

Bases: object

(experimental) The rules to apply for excluding AMIs from the lifecycle policy rule.

Parameters:
  • is_public (Optional[bool]) – (experimental) Excludes public AMIs from the lifecycle policy rule if true. Default: false

  • last_launched (Optional[Duration]) – (experimental) Excludes AMIs which were launched from within the provided duration. Default: None

  • regions (Optional[Sequence[str]]) – (experimental) Excludes AMIs which reside in any of the provided regions. Default: None

  • shared_accounts (Optional[Sequence[str]]) – (experimental) Excludes AMIs which are shared with any of the provided shared accounts. Default: None

  • tags (Optional[Mapping[str, str]]) – (experimental) Excludes AMIs which have any of the provided tags applied to it. Default: None

Stability:

experimental

ExampleMetadata:

infused

Example:

exclude_amis_policy = imagebuilder.LifecyclePolicy(self, "ExcludeAmisPolicy",
    resource_type=imagebuilder.LifecyclePolicyResourceType.AMI_IMAGE,
    details=[imagebuilder.LifecyclePolicyDetail(
        action=imagebuilder.LifecyclePolicyAction(type=imagebuilder.LifecyclePolicyActionType.DELETE),
        filter=imagebuilder.LifecyclePolicyFilter(age_filter=imagebuilder.LifecyclePolicyAgeFilter(age=Duration.days(30))),
        exclusion_rules=imagebuilder.LifecyclePolicyExclusionRules(
            ami_exclusion_rules=imagebuilder.LifecyclePolicyAmiExclusionRules(
                is_public=True,  # Exclude public AMIs
                last_launched=Duration.days(7),  # Exclude AMIs launched in last 7 days
                regions=["us-west-2", "eu-west-1"],  # Exclude AMIs in specific regions
                shared_accounts=["123456789012"],  # Exclude AMIs shared with specific accounts
                tags={
                    "Protected": "true",
                    "Environment": "production"
                }
            )
        )
    )
    ],
    resource_selection=imagebuilder.LifecyclePolicyResourceSelection(
        tags={"Team": "infrastructure"}
    )
)

Attributes

is_public

(experimental) Excludes public AMIs from the lifecycle policy rule if true.

Default:

false

Stability:

experimental

last_launched

(experimental) Excludes AMIs which were launched from within the provided duration.

Default:

None

Stability:

experimental

regions

(experimental) Excludes AMIs which reside in any of the provided regions.

Default:

None

Stability:

experimental

shared_accounts

(experimental) Excludes AMIs which are shared with any of the provided shared accounts.

Default:

None

Stability:

experimental

tags

(experimental) Excludes AMIs which have any of the provided tags applied to it.

Default:

None

Stability:

experimental