diff --git a/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts b/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts index 088e40b28f3b4..a3d416aaadc3d 100644 --- a/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts +++ b/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts @@ -504,6 +504,7 @@ const RESOURCE_TYPE_ATTRIBUTES_FORMATS: { [type: string]: { [attribute: string]: 'AWS::AppSync::GraphQLApi': { ApiId: appsyncGraphQlApiApiIdFmt }, 'AWS::AppSync::FunctionConfiguration': { FunctionId: appsyncGraphQlFunctionIDFmt }, 'AWS::AppSync::DataSource': { Name: appsyncGraphQlDataSourceNameFmt }, + 'AWS::KMS::Key': { Arn: stdSlashResourceArnFmt }, }; function iamArnFmt(parts: ArnParts): string { diff --git a/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts b/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts index 663542c84c48b..053e490502412 100644 --- a/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts +++ b/packages/aws-cdk/test/api/hotswap/state-machine-hotswap-deployments.test.ts @@ -677,6 +677,69 @@ describe.each([HotswapMode.FALL_BACK, HotswapMode.HOTSWAP_ONLY])('%p mode', (hot }); }); + test('knows how to handle attributes of the AWS::KMS::Key resource', async () => { + // GIVEN + setup.setCurrentCfnStackTemplate({ + Resources: { + Key: { + Type: 'AWS::KMS::Key', + Properties: { + Description: 'magic-key', + }, + }, + Machine: { + Type: 'AWS::StepFunctions::StateMachine', + Properties: { + DefinitionString: '{}', + StateMachineName: 'my-machine', + }, + }, + }, + }); + setup.pushStackResourceSummaries( + setup.stackSummaryOf('Key', 'AWS::KMS::Key', 'a-key'), + ); + const cdkStackArtifact = setup.cdkStackArtifactOf({ + template: { + Resources: { + Key: { + Type: 'AWS::KMS::Key', + Properties: { + Description: 'magic-key', + }, + }, + Machine: { + Type: 'AWS::StepFunctions::StateMachine', + Properties: { + DefinitionString: { + 'Fn::Join': ['', [ + '{"KeyId":"', + { Ref: 'Key' }, + '","KeyArn":"', + { 'Fn::GetAtt': ['Key', 'Arn'] }, + '"}', + ]], + }, + StateMachineName: 'my-machine', + }, + }, + }, + }, + }); + + // THEN + const result = await hotswapMockSdkProvider.tryHotswapDeployment(hotswapMode, cdkStackArtifact); + + expect(result).not.toBeUndefined(); + expect(mockUpdateMachineDefinition).toHaveBeenCalledWith({ + stateMachineArn: 'arn:aws:states:here:123456789012:stateMachine:my-machine', + definition: JSON.stringify({ + KeyId: 'a-key', + KeyArn: 'arn:aws:kms:here:123456789012:key/a-key', + }), + }); + }); + test('does not explode if the DependsOn changes', async () => { // GIVEN setup.setCurrentCfnStackTemplate({