# CfnLifecyclePolicyProps

Properties for defining a `CfnLifecyclePolicy`.

Used as props by: [CfnLifecyclePolicy](/cdk/api/v2/docs/aws-cdk-lib.aws_imagebuilder.CfnLifecyclePolicy.html)

- Source: Generated at build time
- Type last changed: v2.110.0 · 17 Nov 2023

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_imagebuilder as imagebuilder } from 'aws-cdk-lib';
const cfnLifecyclePolicyProps: imagebuilder.CfnLifecyclePolicyProps = {
  executionRole: 'executionRole',
  name: 'name',
  policyDetails: [{
    action: {
      type: 'type',

      // the properties below are optional
      includeResources: {
        amis: false,
        containers: false,
        snapshots: false,
      },
    },
    filter: {
      type: 'type',
      value: 123,

      // the properties below are optional
      retainAtLeast: 123,
      unit: 'unit',
    },

    // the properties below are optional
    exclusionRules: {
      amis: {
        isPublic: false,
        lastLaunched: {
          unit: 'unit',
          value: 123,
        },
        regions: ['regions'],
        sharedAccounts: ['sharedAccounts'],
        tagMap: {
          tagMapKey: 'tagMap',
        },
      },
      tagMap: {
        tagMapKey: 'tagMap',
      },
    },
  }],
  resourceSelection: {
    recipes: [{
      name: 'name',
      semanticVersion: 'semanticVersion',
    }],
    tagMap: {
      tagMapKey: 'tagMap',
    },
  },
  resourceType: 'resourceType',

  // the properties below are optional
  description: 'description',
  status: 'status',
  tags: {
    tagsKey: 'tags',
  },
};
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_imagebuilder as imagebuilder

cfn_lifecycle_policy_props = imagebuilder.CfnLifecyclePolicyProps(
    execution_role="executionRole",
    name="name",
    policy_details=[imagebuilder.CfnLifecyclePolicy.PolicyDetailProperty(
        action=imagebuilder.CfnLifecyclePolicy.ActionProperty(
            type="type",

            # the properties below are optional
            include_resources=imagebuilder.CfnLifecyclePolicy.IncludeResourcesProperty(
                amis=False,
                containers=False,
                snapshots=False
            )
        ),
        filter=imagebuilder.CfnLifecyclePolicy.FilterProperty(
            type="type",
            value=123,

            # the properties below are optional
            retain_at_least=123,
            unit="unit"
        ),

        # the properties below are optional
        exclusion_rules=imagebuilder.CfnLifecyclePolicy.ExclusionRulesProperty(
            amis=imagebuilder.CfnLifecyclePolicy.AmiExclusionRulesProperty(
                is_public=False,
                last_launched=imagebuilder.CfnLifecyclePolicy.LastLaunchedProperty(
                    unit="unit",
                    value=123
                ),
                regions=["regions"],
                shared_accounts=["sharedAccounts"],
                tag_map={
                    "tag_map_key": "tagMap"
                }
            ),
            tag_map={
                "tag_map_key": "tagMap"
            }
        )
    )],
    resource_selection=imagebuilder.CfnLifecyclePolicy.ResourceSelectionProperty(
        recipes=[imagebuilder.CfnLifecyclePolicy.RecipeSelectionProperty(
            name="name",
            semantic_version="semanticVersion"
        )],
        tag_map={
            "tag_map_key": "tagMap"
        }
    ),
    resource_type="resourceType",

    # the properties below are optional
    description="description",
    status="status",
    tags={
        "tags_key": "tags"
    }
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.imagebuilder.*;

CfnLifecyclePolicyProps cfnLifecyclePolicyProps = CfnLifecyclePolicyProps.builder()
        .executionRole("executionRole")
        .name("name")
        .policyDetails(List.of(PolicyDetailProperty.builder()
                .action(ActionProperty.builder()
                        .type("type")

                        // the properties below are optional
                        .includeResources(IncludeResourcesProperty.builder()
                                .amis(false)
                                .containers(false)
                                .snapshots(false)
                                .build())
                        .build())
                .filter(FilterProperty.builder()
                        .type("type")
                        .value(123)

                        // the properties below are optional
                        .retainAtLeast(123)
                        .unit("unit")
                        .build())

                // the properties below are optional
                .exclusionRules(ExclusionRulesProperty.builder()
                        .amis(AmiExclusionRulesProperty.builder()
                                .isPublic(false)
                                .lastLaunched(LastLaunchedProperty.builder()
                                        .unit("unit")
                                        .value(123)
                                        .build())
                                .regions(List.of("regions"))
                                .sharedAccounts(List.of("sharedAccounts"))
                                .tagMap(Map.of(
                                        "tagMapKey", "tagMap"))
                                .build())
                        .tagMap(Map.of(
                                "tagMapKey", "tagMap"))
                        .build())
                .build()))
        .resourceSelection(ResourceSelectionProperty.builder()
                .recipes(List.of(RecipeSelectionProperty.builder()
                        .name("name")
                        .semanticVersion("semanticVersion")
                        .build()))
                .tagMap(Map.of(
                        "tagMapKey", "tagMap"))
                .build())
        .resourceType("resourceType")

        // the properties below are optional
        .description("description")
        .status("status")
        .tags(Map.of(
                "tagsKey", "tags"))
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.ImageBuilder;

var cfnLifecyclePolicyProps = new CfnLifecyclePolicyProps {
    ExecutionRole = "executionRole",
    Name = "name",
    PolicyDetails = new [] { new PolicyDetailProperty {
        Action = new ActionProperty {
            Type = "type",

            // the properties below are optional
            IncludeResources = new IncludeResourcesProperty {
                Amis = false,
                Containers = false,
                Snapshots = false
            }
        },
        Filter = new FilterProperty {
            Type = "type",
            Value = 123,

            // the properties below are optional
            RetainAtLeast = 123,
            Unit = "unit"
        },

        // the properties below are optional
        ExclusionRules = new ExclusionRulesProperty {
            Amis = new AmiExclusionRulesProperty {
                IsPublic = false,
                LastLaunched = new LastLaunchedProperty {
                    Unit = "unit",
                    Value = 123
                },
                Regions = new [] { "regions" },
                SharedAccounts = new [] { "sharedAccounts" },
                TagMap = new Dictionary<string, string> {
                    { "tagMapKey", "tagMap" }
                }
            },
            TagMap = new Dictionary<string, string> {
                { "tagMapKey", "tagMap" }
            }
        }
    } },
    ResourceSelection = new ResourceSelectionProperty {
        Recipes = new [] { new RecipeSelectionProperty {
            Name = "name",
            SemanticVersion = "semanticVersion"
        } },
        TagMap = new Dictionary<string, string> {
            { "tagMapKey", "tagMap" }
        }
    },
    ResourceType = "resourceType",

    // the properties below are optional
    Description = "description",
    Status = "status",
    Tags = new Dictionary<string, string> {
        { "tagsKey", "tags" }
    }
};
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"

cfnLifecyclePolicyProps := &CfnLifecyclePolicyProps{
	ExecutionRole: jsii.String("executionRole"),
	Name: jsii.String("name"),
	PolicyDetails: []interface{}{
		&PolicyDetailProperty{
			Action: &ActionProperty{
				Type: jsii.String("type"),

				// the properties below are optional
				IncludeResources: &IncludeResourcesProperty{
					Amis: jsii.Boolean(false),
					Containers: jsii.Boolean(false),
					Snapshots: jsii.Boolean(false),
				},
			},
			Filter: &FilterProperty{
				Type: jsii.String("type"),
				Value: jsii.Number(123),

				// the properties below are optional
				RetainAtLeast: jsii.Number(123),
				Unit: jsii.String("unit"),
			},

			// the properties below are optional
			ExclusionRules: &ExclusionRulesProperty{
				Amis: &AmiExclusionRulesProperty{
					IsPublic: jsii.Boolean(false),
					LastLaunched: &LastLaunchedProperty{
						Unit: jsii.String("unit"),
						Value: jsii.Number(123),
					},
					Regions: []*string{
						jsii.String("regions"),
					},
					SharedAccounts: []*string{
						jsii.String("sharedAccounts"),
					},
					TagMap: map[string]*string{
						"tagMapKey": jsii.String("tagMap"),
					},
				},
				TagMap: map[string]*string{
					"tagMapKey": jsii.String("tagMap"),
				},
			},
		},
	},
	ResourceSelection: &ResourceSelectionProperty{
		Recipes: []interface{}{
			&RecipeSelectionProperty{
				Name: jsii.String("name"),
				SemanticVersion: jsii.String("semanticVersion"),
			},
		},
		TagMap: map[string]*string{
			"tagMapKey": jsii.String("tagMap"),
		},
	},
	ResourceType: jsii.String("resourceType"),

	// the properties below are optional
	Description: jsii.String("description"),
	Status: jsii.String("status"),
	Tags: map[string]*string{
		"tagsKey": jsii.String("tags"),
	},
}
```

## Properties

- `description`: string — Optional description for the lifecycle policy.

- `executionRole`: string (required) — The name or Amazon Resource Name (ARN) for the IAM role you create that grants Image Builder access to run lifecycle actions.

- `name`: string (required) — The name of the lifecycle policy to create.

- `policyDetails`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnLifecyclePolicy.PolicyDetailProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_imagebuilder.CfnLifecyclePolicy.PolicyDetailProperty.html)[] (required) — Configuration details for the lifecycle policy rules.

- `resourceSelection`: [IResolvable](/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnLifecyclePolicy.ResourceSelectionProperty](/cdk/api/v2/docs/aws-cdk-lib.aws_imagebuilder.CfnLifecyclePolicy.ResourceSelectionProperty.html) (required) — Selection criteria for the resources that the lifecycle policy applies to.

- `resourceType`: string (required) — The type of Image Builder resource that the lifecycle policy applies to.

- `status`: string — Indicates whether the lifecycle policy resource is enabled.

- `tags`: { [key: string]: string } — Tags to apply to the lifecycle policy resource.
