Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

feat(stepfunctions): add support for EncryptionConfiguration #30959

Merged
merged 47 commits into from
Sep 20, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
3e29f48
Basic implementation for EncryptionConfiguration
Jul 15, 2024
4d63917
Merge branch 'aws:main' into main
VaidSaraswat Jul 18, 2024
f9b5d7a
Merge branch 'aws:main' into main
VaidSaraswat Jul 26, 2024
971290d
Adding support for KMS in StateMachine and Activity resources
Aug 1, 2024
a44a3e0
Update packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts
VaidSaraswat Aug 8, 2024
ec8865a
Update packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts
VaidSaraswat Aug 8, 2024
c1d25e9
Update packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts
VaidSaraswat Aug 8, 2024
61b69e1
Addressing second round of feedback
Aug 9, 2024
25521c4
Removed redunant optional chaining and created encryptionConfiguratio…
Aug 9, 2024
2373d5a
Adding integrations key policy & non-null assertion for kms key in util
Aug 9, 2024
8d605fe
Removing condition from KMS key policy for CWL encryption
Aug 11, 2024
b2dc0e9
Updating CWL encryption example to provide KMS key as prop
Aug 11, 2024
89a56ce
Adding back encryption context and updating CWL Log Group to use sepa…
Aug 12, 2024
5ab6f60
Adding ActivityProps type as accepted type for constructEncryptionCon…
Aug 13, 2024
ce62bb7
Update packages/aws-cdk-lib/aws-stepfunctions/lib/activity.ts
VaidSaraswat Aug 14, 2024
e57602a
Update packages/aws-cdk-lib/aws-stepfunctions/lib/util.ts
VaidSaraswat Aug 14, 2024
20bf8e5
Update packages/aws-cdk-lib/aws-stepfunctions/lib/util.ts
VaidSaraswat Aug 14, 2024
94a1783
Addressing third round of feedback
Aug 16, 2024
7f52d32
Adding assertions to snapshot tests
Aug 16, 2024
de3bbc4
Merge branch 'main' into feat-encryption-configuration
shivlaks Aug 17, 2024
d668d9b
LogGroup key uses narrower permissions in key policy && updating snap…
Aug 20, 2024
6042f32
Update packages/aws-cdk-lib/aws-stepfunctions/README.md
VaidSaraswat Aug 22, 2024
db31000
Update packages/aws-cdk-lib/aws-stepfunctions/README.md
VaidSaraswat Aug 22, 2024
1099973
- Add back unit tests for validating encryption configuration
Aug 26, 2024
1c3a816
Update packages/aws-cdk-lib/aws-stepfunctions/README.md
VaidSaraswat Aug 27, 2024
d6d5f0c
Update packages/aws-cdk-lib/aws-stepfunctions/README.md
VaidSaraswat Aug 27, 2024
aca062a
Update packages/aws-cdk-lib/aws-stepfunctions/README.md
VaidSaraswat Aug 27, 2024
e8c2808
Update packages/aws-cdk-lib/aws-stepfunctions/lib/activity.ts
VaidSaraswat Aug 27, 2024
e39dc89
- Updating README to include ts and fixed indentation
Aug 27, 2024
57483ac
Adding dependency imports for README examples
Aug 27, 2024
2aca3aa
- Fix indentation in code sample for README
Aug 27, 2024
8b3a07e
Rename aws-cdk-lib/kms to 'aws-cdk-lib/aws-kms'
Aug 28, 2024
b25b069
Removing unnecessary kms:Decrypt permissions for execution role when …
Aug 28, 2024
2868c02
Update packages/aws-cdk-lib/aws-stepfunctions/lib/util.ts
VaidSaraswat Aug 28, 2024
581739d
- Use stronger assertion Match.objectEquals
Aug 28, 2024
0a5b065
Removing unnecessary KMS:Decrypt permissions on Activity key for Send…
Aug 28, 2024
43d3dad
Update packages/aws-cdk-lib/aws-stepfunctions/README.md
VaidSaraswat Aug 29, 2024
b0b5674
- Use new EncryptionConfiguration object for customers who want to us…
Aug 30, 2024
fedf070
Adding missing comma
Aug 30, 2024
4c062d8
Update packages/aws-cdk-lib/aws-stepfunctions/README.md
VaidSaraswat Sep 2, 2024
f5f2396
Update packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts
VaidSaraswat Sep 2, 2024
130cd1f
- Created new abstract EncryptionConfiguration class which CustomerMa…
Sep 4, 2024
1ebeafe
Merge branch 'main' into feat-encryption-configuration
paulhcsun Sep 4, 2024
3d44c34
- Added new lines to files that didn't have them
Sep 6, 2024
74cd4fb
Update packages/aws-cdk-lib/aws-stepfunctions/README.md
VaidSaraswat Sep 19, 2024
339aa82
Update packages/aws-cdk-lib/aws-stepfunctions/README.md
VaidSaraswat Sep 19, 2024
17641e4
Merge branch 'main' into feat-encryption-configuration
paulhcsun Sep 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@ class KMSStateMachine extends cdk.Stack {

this.activity = new sfn.Activity(this, 'ActivityWithCMKEncryptionConfiguration', {
activityName: 'ActivityWithCMKEncryptionConfiguration',
kmsKey: this.activityKmsKey,
kmsDataKeyReusePeriodSeconds: cdk.Duration.seconds(75),
encryptionConfiguration: new sfn.EncryptionConfiguration(this.activityKmsKey, cdk.Duration.seconds(75)),
});

this.stateMachine = new sfn.StateMachine(this, 'StateMachineWithCMKEncryptionConfiguration', {
Expand All @@ -36,8 +35,7 @@ class KMSStateMachine extends cdk.Stack {
},
}))),
stateMachineType: sfn.StateMachineType.STANDARD,
kmsKey: this.stateMachineKmsKey,
kmsDataKeyReusePeriodSeconds: cdk.Duration.seconds(75),
encryptionConfiguration: new sfn.EncryptionConfiguration(this.stateMachineKmsKey, cdk.Duration.seconds(75)),
removalPolicy: cdk.RemovalPolicy.DESTROY,
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ class KMSStateMachine extends cdk.Stack {
result: sfn.Result.fromString(executionOutput),
}))),
stateMachineType: sfn.StateMachineType.STANDARD,
kmsKey: this.kmsKey,
kmsDataKeyReusePeriodSeconds: cdk.Duration.seconds(300),
encryptionConfiguration: new sfn.EncryptionConfiguration(this.kmsKey, cdk.Duration.seconds(300)),
logs: {
destination: this.logGroup,
level: sfn.LogLevel.ALL,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export class StepFunctionsInvokeActivity extends sfn.TaskStateBase {
constructor(scope: Construct, id: string, private readonly props: StepFunctionsInvokeActivityProps) {
super(scope, id, props);

if (this.props.activity.kmsKey) {
this.taskPolicies = this.createPolicyStatements(this.props.activity.kmsKey);
if (this.props.activity.encryptionConfiguration) {
this.taskPolicies = this.createPolicyStatements(this.props.activity.encryptionConfiguration.kmsKey);
}
this.taskMetrics = {
metricDimensions: { ActivityArn: this.props.activity.activityArn },
Expand Down
11 changes: 4 additions & 7 deletions packages/aws-cdk-lib/aws-stepfunctions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -976,7 +976,7 @@ new sfn.StateMachine(this, 'MyStateMachine', {
```

## Encryption
You can encrypt your data using a customer-managed key for AWS Step Functions state machines and activities. You can configure a symmetric AWS KMS key and data key reuse period when creating or updating a State Machine, and when creating an Activity. The execution history and state machine definition will be encrypted with the key applied to the State Machine. Activity inputs will be encrypted with the key applied to the Activity.
You can encrypt your data using a customer-managed key for AWS Step Functions state machines and activities. You can configure a symmetric AWS KMS key and data key reuse period when creating or updating a State Machine or when creating an Activity. The execution history and state machine definition will be encrypted with the key applied to the State Machine. Activity inputs will be encrypted with the key applied to the Activity.
VaidSaraswat marked this conversation as resolved.
Show resolved Hide resolved

### Encrypting state machines
You can provide a symmetric KMS key to encrypt the state machine definition and execution history:
Expand All @@ -989,8 +989,7 @@ const stateMachine = new sfn.StateMachine(this, 'StateMachineWithCMKEncryptionCo
stateMachineName: 'StateMachineWithCMKEncryptionConfiguration',
definitionBody: sfn.DefinitionBody.fromChainable(sfn.Chain.start(new sfn.Pass(this, 'Pass'))),
stateMachineType: sfn.StateMachineType.STANDARD,
kmsKey: kmsKey,
kmsDataKeyReusePeriodSeconds: cdk.Duration.seconds(60),
encryptionConfiguration: new sfn.EncryptionConfiguration(kmsKey, cdk.Duration.seconds(60)),
});
```

Expand Down Expand Up @@ -1032,8 +1031,7 @@ const stateMachine = new sfn.StateMachine(this, 'StateMachineWithCMKWithCWLEncry
result: sfn.Result.fromString('Hello World'),
}))),
stateMachineType: sfn.StateMachineType.STANDARD,
kmsKey: stateMachineKmsKey,
kmsDataKeyReusePeriodSeconds: cdk.Duration.seconds(300),
encryptionConfiguration: new sfn.EncryptionConfiguration(stateMachineKmsKey),
logs: {
destination: logGroup,
level: sfn.LogLevel.ALL,
Expand All @@ -1051,8 +1049,7 @@ import * as cdk from 'aws-cdk-lib';
const kmsKey = new kms.Key(this, 'Key');
const activity = new sfn.Activity(this, 'ActivityWithCMKEncryptionConfiguration', {
activityName: 'ActivityWithCMKEncryptionConfiguration',
kmsKey: kmsKey,
kmsDataKeyReusePeriodSeconds: cdk.Duration.seconds(75),
encryptionConfiguration: new sfn.EncryptionConfiguration(kmsKey, cdk.Duration.seconds(75))
});
```

Expand Down
36 changes: 11 additions & 25 deletions packages/aws-cdk-lib/aws-stepfunctions/lib/activity.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { Construct } from 'constructs';
import { EncryptionConfiguration } from './encryptionconfiguration';
import { StatesMetrics } from './stepfunctions-canned-metrics.generated';
import { CfnActivity } from './stepfunctions.generated';
import { constructEncryptionConfiguration } from './util';
import * as cloudwatch from '../../aws-cloudwatch';
import * as iam from '../../aws-iam';
import * as kms from '../../aws-kms';
import { ArnFormat, Duration, IResource, Lazy, Names, Resource, Stack } from '../../core';

import { ArnFormat, IResource, Lazy, Names, Resource, Stack } from '../../core';
/**
* Properties for defining a new Step Functions Activity
*/
Expand All @@ -19,24 +18,11 @@ export interface ActivityProps {
readonly activityName?: string;

/**
* Specifies a symmetric customer managed KMS key for server-side encryption of the activity inputs.
* Step Functions will reuse the key for a maximum of `kmsDataKeyReusePeriodSeconds`.
* The encryptionConfiguration object used for server-side encryption of the activity inputs.
*
* @default - data is transparently encrypted using an AWS owned key
*/
readonly kmsKey?: kms.IKey;

/**
* Maximum duration that Step Functions will reuse customer managed data keys.
* When the period expires, Step Functions will call GenerateDataKey.
*
* You can only provide a value if `kmsKey` is set.
*
* Must be between 60 and 900 seconds.
*
* @default Duration.seconds(300)
*/
readonly kmsDataKeyReusePeriodSeconds?: Duration;
readonly encryptionConfiguration?: EncryptionConfiguration;
}

/**
Expand Down Expand Up @@ -82,17 +68,17 @@ export class Activity extends Resource implements IActivity {
/**
* @attribute
*/
public readonly kmsKey?: kms.IKey;
public readonly encryptionConfiguration?: EncryptionConfiguration;

constructor(scope: Construct, id: string, props: ActivityProps = {}) {
super(scope, id, {
physicalName: props.activityName ||
Lazy.string({ produce: () => this.generateName() }),
});

if (props.kmsKey) {
this.kmsKey = props.kmsKey;
props.kmsKey.addToResourcePolicy(new iam.PolicyStatement({
if (props.encryptionConfiguration) {
this.encryptionConfiguration = props.encryptionConfiguration;
props.encryptionConfiguration.kmsKey.addToResourcePolicy(new iam.PolicyStatement({
resources: ['*'],
actions: ['kms:Decrypt', 'kms:GenerateDataKey'],
principals: [new iam.ServicePrincipal('states.amazonaws.com')],
Expand All @@ -111,7 +97,7 @@ export class Activity extends Resource implements IActivity {

const resource = new CfnActivity(this, 'Resource', {
name: this.physicalName!, // not null because of above call to `super`
encryptionConfiguration: constructEncryptionConfiguration(props.kmsKey, props.kmsDataKeyReusePeriodSeconds),
encryptionConfiguration: constructEncryptionConfiguration(props.encryptionConfiguration),
});

this.activityArn = this.getResourceArnAttribute(resource.ref, {
Expand Down Expand Up @@ -271,9 +257,9 @@ export interface IActivity extends IResource {
readonly activityName: string;

/**
* The symmetric customer managed KMS key for server-side encryption of the activity inputs.
* The encryptionConfiguration object used for server-side encryption of the activity inputs
*
* @attribute
*/
readonly kmsKey?: kms.IKey;
readonly encryptionConfiguration?: EncryptionConfiguration;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import * as kms from '../../aws-kms';
import * as cdk from '../../core';

/**
* Define a new EncryptionConfiguration
*/
export class EncryptionConfiguration {
/**
* The symmetric customer managed KMS key for server-side encryption of the state machine definition, and execution history or activity inputs.
* Step Functions will reuse the key for a maximum of `kmsDataKeyReusePeriodSeconds`.
*
* @default - data is transparently encrypted using an AWS owned key
*/
public readonly kmsKey: kms.IKey;
/**
* Maximum duration that Step Functions will reuse customer managed data keys.
* When the period expires, Step Functions will call GenerateDataKey.
*
* Must be between 60 and 900 seconds.
*
* @default Duration.seconds(300)
*/
public readonly kmsDataKeyReusePeriodSeconds?;
constructor(kmsKey: kms.IKey, kmsDataKeyReusePeriodSeconds?: cdk.Duration) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: new lines?

this.kmsKey = kmsKey;
this.validateKmsDataKeyReusePeriodSeconds(kmsDataKeyReusePeriodSeconds);
this.kmsDataKeyReusePeriodSeconds = kmsDataKeyReusePeriodSeconds;
}

private isInvalidKmsDataKeyReusePeriodSeconds(kmsDataKeyReusePeriodSeconds: cdk.Duration) {
return kmsDataKeyReusePeriodSeconds.toSeconds() < 60 || kmsDataKeyReusePeriodSeconds.toSeconds() > 900;
}

private validateKmsDataKeyReusePeriodSeconds(kmsDataKeyReusePeriodSeconds: cdk.Duration | undefined) {
if (kmsDataKeyReusePeriodSeconds && this.isInvalidKmsDataKeyReusePeriodSeconds(kmsDataKeyReusePeriodSeconds)) {
throw new Error('kmsDataKeyReusePeriodSeconds must have a value between 60 and 900 seconds');
}
}
}
1 change: 1 addition & 0 deletions packages/aws-cdk-lib/aws-stepfunctions/lib/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export * from './states/custom-state';
export * from './states/map-base';
export * from './states/task-base';
export * from './task-credentials';
export * from './encryptionconfiguration';

// AWS::StepFunctions CloudFormation Resources:
export * from './stepfunctions.generated';
31 changes: 8 additions & 23 deletions packages/aws-cdk-lib/aws-stepfunctions/lib/state-machine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import { IChainable } from './types';
import { constructEncryptionConfiguration } from './util';
import * as cloudwatch from '../../aws-cloudwatch';
import * as iam from '../../aws-iam';
import * as kms from '../../aws-kms';
import * as logs from '../../aws-logs';
import * as s3_assets from '../../aws-s3-assets';

import { Arn, ArnFormat, Duration, IResource, RemovalPolicy, Resource, Stack, Token } from '../../core';
import { EncryptionConfiguration } from '../lib/encryptionconfiguration';

/**
* Two types of state machines are available in AWS Step Functions: EXPRESS AND STANDARD.
Expand Down Expand Up @@ -158,25 +157,11 @@ export interface StateMachineProps {
readonly removalPolicy?: RemovalPolicy;

/**
* Specifies a symmetric customer managed KMS key for server-side encryption of the state machine definition and execution history.
* Step Functions will reuse the key for a maximum of `kmsDataKeyReusePeriodSeconds`.
* The encryptionConfiguration object used for server-side encryption of the state machine definition and execution history.
VaidSaraswat marked this conversation as resolved.
Show resolved Hide resolved
*
* @default - data is transparently encrypted using an AWS owned key
*/
readonly kmsKey?: kms.IKey;

/**
* Maximum duration that Step Functions will reuse customer managed data keys.
* When the period expires, Step Functions will call GenerateDataKey.
*
* You can only provide a value if `kmsKey` is set.
*
* Must be between 60 and 900 seconds.
*
* @default Duration.seconds(300)
*/
readonly kmsDataKeyReusePeriodSeconds?: Duration;

readonly encryptionConfiguration?: EncryptionConfiguration;
}

/**
Expand Down Expand Up @@ -476,13 +461,13 @@ export class StateMachine extends StateMachineBase {
}
}

if (props.kmsKey) {
if (props.encryptionConfiguration) {
this.role.addToPrincipalPolicy(new iam.PolicyStatement({
effect: iam.Effect.ALLOW,
actions: [
'kms:Decrypt', 'kms:GenerateDataKey',
],
resources: [`${props.kmsKey.keyArn}`],
resources: [`${props.encryptionConfiguration.kmsKey.keyArn}`],
conditions: {
VaidSaraswat marked this conversation as resolved.
Show resolved Hide resolved
StringEquals: {
'kms:EncryptionContext:aws:states:stateMachineArn': Stack.of(this).formatArn({
VaidSaraswat marked this conversation as resolved.
Show resolved Hide resolved
Expand All @@ -501,7 +486,7 @@ export class StateMachine extends StateMachineBase {
actions: [
'kms:GenerateDataKey',
],
resources: [`${props.kmsKey.keyArn}`],
resources: [`${props.encryptionConfiguration.kmsKey.keyArn}`],
conditions: {
StringEquals: {
'kms:EncryptionContext:SourceArn': Stack.of(this).formatArn({
Expand All @@ -512,7 +497,7 @@ export class StateMachine extends StateMachineBase {
},
},
}));
props.kmsKey.addToResourcePolicy(new iam.PolicyStatement({
props.encryptionConfiguration.kmsKey.addToResourcePolicy(new iam.PolicyStatement({
resources: ['*'],
actions: ['kms:Decrypt*'],
principals: [new iam.ServicePrincipal('delivery.logs.amazonaws.com')],
Expand All @@ -528,7 +513,7 @@ export class StateMachine extends StateMachineBase {
tracingConfiguration: this.buildTracingConfiguration(props.tracingEnabled),
...definitionBody.bind(this, this.role, props, graph),
definitionSubstitutions: props.definitionSubstitutions,
encryptionConfiguration: constructEncryptionConfiguration(props.kmsKey, props.kmsDataKeyReusePeriodSeconds),
encryptionConfiguration: constructEncryptionConfiguration(props.encryptionConfiguration),
});
resource.applyRemovalPolicy(props.removalPolicy, { default: RemovalPolicy.DESTROY });

Expand Down
28 changes: 6 additions & 22 deletions packages/aws-cdk-lib/aws-stepfunctions/lib/util.ts
VaidSaraswat marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,36 +1,20 @@
import { IKey } from '../../aws-kms';
import { Duration } from '../../core';
import { EncryptionConfiguration } from './encryptionconfiguration';

export function noEmptyObject<A>(o: Record<string, A>): Record<string, A> | undefined {
if (Object.keys(o).length === 0) { return undefined; }
return o;
}

function isInValidKmsDataKeyReusePeriodSeconds(kmsDataKeyReusePeriodSeconds: Duration) {
return kmsDataKeyReusePeriodSeconds.toSeconds() < 60 || kmsDataKeyReusePeriodSeconds.toSeconds() > 900;
}

function validateEncryptionConfiguration(kmsKey: IKey | undefined, kmsDataKeyReusePeriodSeconds: Duration | undefined) {
if (!kmsKey && kmsDataKeyReusePeriodSeconds) {
throw new Error('You cannot set kmsDataKeyReusePeriodSeconds without providing a value for kmsKey');
}
if (kmsKey && kmsDataKeyReusePeriodSeconds && isInValidKmsDataKeyReusePeriodSeconds(kmsDataKeyReusePeriodSeconds)) {
throw new Error('kmsDataKeyReusePeriodSeconds must have a value between 60 and 900 seconds');
}
}

export function constructEncryptionConfiguration(kmsKey: IKey | undefined, kmsDataKeyReusePeriodSeconds: Duration | undefined) {
validateEncryptionConfiguration(kmsKey, kmsDataKeyReusePeriodSeconds);

if (!kmsKey) {
export function constructEncryptionConfiguration(encryptionConfiguration? : EncryptionConfiguration) {
VaidSaraswat marked this conversation as resolved.
Show resolved Hide resolved
if (!encryptionConfiguration) {
return undefined;
}
VaidSaraswat marked this conversation as resolved.
Show resolved Hide resolved

// Default value for `kmsDataKeyReusePeriodSeconds`, see: https://docs.aws.amazon.com/step-functions/latest/dg/encryption-at-rest.html#cfn-resources-for-encryption-configuration
const DEFAULT_KMS_DATA_KEY_REUSE_PERIOD_SECONDS = 300;
return {
kmsKeyId: kmsKey.keyArn,
kmsDataKeyReusePeriodSeconds: kmsDataKeyReusePeriodSeconds ? kmsDataKeyReusePeriodSeconds.toSeconds() : DEFAULT_KMS_DATA_KEY_REUSE_PERIOD_SECONDS,
kmsKeyId: encryptionConfiguration.kmsKey.keyArn,
kmsDataKeyReusePeriodSeconds: encryptionConfiguration.kmsDataKeyReusePeriodSeconds ?
encryptionConfiguration.kmsDataKeyReusePeriodSeconds.toSeconds() : DEFAULT_KMS_DATA_KEY_REUSE_PERIOD_SECONDS,
type: 'CUSTOMER_MANAGED_KMS_KEY',
};

Expand Down
21 changes: 4 additions & 17 deletions packages/aws-cdk-lib/aws-stepfunctions/test/activity.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as iam from '../../aws-iam';
import * as kms from '../../aws-kms';
import * as cdk from '../../core';
import * as stepfunctions from '../lib';
import { EncryptionConfiguration } from '../lib/encryptionconfiguration';

describe('Activity', () => {
test('instantiate Activity', () => {
Expand Down Expand Up @@ -79,8 +80,7 @@ describe('Activity', () => {

// WHEN
new stepfunctions.Activity(stack, 'Activity', {
kmsKey: kmsKey,
kmsDataKeyReusePeriodSeconds: cdk.Duration.seconds(75),
encryptionConfiguration: new EncryptionConfiguration(kmsKey, cdk.Duration.seconds(75)),
});

// THEN
Expand Down Expand Up @@ -167,7 +167,7 @@ describe('Activity', () => {

// WHEN
new stepfunctions.Activity(stack, 'Activity', {
kmsKey: kmsKey,
encryptionConfiguration: new EncryptionConfiguration(kmsKey),
});

// THEN
Expand All @@ -190,21 +190,8 @@ describe('Activity', () => {
expect(() => {
// WHEN
new stepfunctions.Activity(stack, 'Activity', {
kmsKey: kmsKey,
kmsDataKeyReusePeriodSeconds: cdk.Duration.seconds(5),
encryptionConfiguration: new EncryptionConfiguration(kmsKey, cdk.Duration.seconds(5)),
});
}).toThrow('kmsDataKeyReusePeriodSeconds must have a value between 60 and 900 seconds');
});
});

test('Instantiate Activity with no kms key and kmsDataKeyReusePeriodSeconds throws error', () => {
// GIVEN
const stack = new cdk.Stack();
// FAIL
expect(() => {
// WHEN
new stepfunctions.Activity(stack, 'Activity', {
kmsDataKeyReusePeriodSeconds: cdk.Duration.seconds(75),
});
}).toThrow('You cannot set kmsDataKeyReusePeriodSeconds without providing a value for kmsKey');
});
Loading