# CreateRuleProperty

*[Custom snapshot and AMI policies only]* Specifies when the policy should create snapshots or AMIs.

> - You must specify either *CronExpression* , or *Interval* , *IntervalUnit* , and *Times* .
> - If you need to specify an [ArchiveRule](https://docs.aws.amazon.com/dlm/latest/APIReference/API_ArchiveRule.html) for the schedule, then you must specify a creation frequency of at least 28 days.

- Source: Generated at build time
- Type last changed: v2.109.0 · 16 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_dlm as dlm } from 'aws-cdk-lib';
const createRuleProperty: dlm.CfnLifecyclePolicy.CreateRuleProperty = {
  cronExpression: 'cronExpression',
  interval: 123,
  intervalUnit: 'intervalUnit',
  location: 'location',
  scripts: [{
    executeOperationOnScriptFailure: false,
    executionHandler: 'executionHandler',
    executionHandlerService: 'executionHandlerService',
    executionTimeout: 123,
    maximumRetryCount: 123,
    stages: ['stages'],
  }],
  times: ['times'],
};
```

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_dlm as dlm

create_rule_property = dlm.CfnLifecyclePolicy.CreateRuleProperty(
    cron_expression="cronExpression",
    interval=123,
    interval_unit="intervalUnit",
    location="location",
    scripts=[dlm.CfnLifecyclePolicy.ScriptProperty(
        execute_operation_on_script_failure=False,
        execution_handler="executionHandler",
        execution_handler_service="executionHandlerService",
        execution_timeout=123,
        maximum_retry_count=123,
        stages=["stages"]
    )],
    times=["times"]
)
```

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.dlm.*;

CreateRuleProperty createRuleProperty = CreateRuleProperty.builder()
        .cronExpression("cronExpression")
        .interval(123)
        .intervalUnit("intervalUnit")
        .location("location")
        .scripts(List.of(ScriptProperty.builder()
                .executeOperationOnScriptFailure(false)
                .executionHandler("executionHandler")
                .executionHandlerService("executionHandlerService")
                .executionTimeout(123)
                .maximumRetryCount(123)
                .stages(List.of("stages"))
                .build()))
        .times(List.of("times"))
        .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.DLM;

var createRuleProperty = new CreateRuleProperty {
    CronExpression = "cronExpression",
    Interval = 123,
    IntervalUnit = "intervalUnit",
    Location = "location",
    Scripts = new [] { new ScriptProperty {
        ExecuteOperationOnScriptFailure = false,
        ExecutionHandler = "executionHandler",
        ExecutionHandlerService = "executionHandlerService",
        ExecutionTimeout = 123,
        MaximumRetryCount = 123,
        Stages = new [] { "stages" }
    } },
    Times = new [] { "times" }
};
```

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"

createRuleProperty := &CreateRuleProperty{
	CronExpression: jsii.String("cronExpression"),
	Interval: jsii.Number(123),
	IntervalUnit: jsii.String("intervalUnit"),
	Location: jsii.String("location"),
	Scripts: []interface{}{
		&ScriptProperty{
			ExecuteOperationOnScriptFailure: jsii.Boolean(false),
			ExecutionHandler: jsii.String("executionHandler"),
			ExecutionHandlerService: jsii.String("executionHandlerService"),
			ExecutionTimeout: jsii.Number(123),
			MaximumRetryCount: jsii.Number(123),
			Stages: []*string{
				jsii.String("stages"),
			},
		},
	},
	Times: []*string{
		jsii.String("times"),
	},
}
```

## Properties

- `cronExpression`: string — The schedule, as a Cron expression.

  The schedule interval must be between 1 hour and 1 year. For more information, see the [Cron and rate expressions](https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-scheduled-rule-pattern.html) in the *Amazon EventBridge User Guide* .

- `interval`: number — The interval between snapshots.

  The supported values are 1, 2, 3, 4, 6, 8, 12, and 24.

- `intervalUnit`: string — The interval unit.

- `location`: string — *[Custom snapshot policies only]* Specifies the destination for snapshots created by the policy.

  The allowed destinations depend on the location of the targeted resources.

  - If the policy targets resources in a Region, then you must create snapshots in the same Region as the source resource.
  - If the policy targets resources in a Local Zone, you can create snapshots in the same Local Zone or in its parent Region.
  - If the policy targets resources on an Outpost, then you can create snapshots on the same Outpost or in its parent Region.

  Specify one of the following values:

  - To create snapshots in the same Region as the source resource, specify `CLOUD` .
  - To create snapshots in the same Local Zone as the source resource, specify `LOCAL_ZONE` .
  - To create snapshots on the same Outpost as the source resource, specify `OUTPOST_LOCAL` .

  Default: `CLOUD`

- `scripts`: [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [IResolvable](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.IResolvable.html) | [CfnLifecyclePolicy.ScriptProperty](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_dlm.CfnLifecyclePolicy.ScriptProperty.html)[] — *[Custom snapshot policies that target instances only]* Specifies pre and/or post scripts for a snapshot lifecycle policy that targets instances.

  This is useful for creating application-consistent snapshots, or for performing specific administrative tasks before or after Amazon Data Lifecycle Manager initiates snapshot creation.

  For more information, see [Automating application-consistent snapshots with pre and post scripts](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/automate-app-consistent-backups.html) .

- `times`: string[] — The time, in UTC, to start the operation. The supported format is hh:mm.

  The operation occurs within a one-hour window following the specified time. If you do not specify a time, Amazon Data Lifecycle Manager selects a time within the next 24 hours.
