Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix(cli): handle attributes of AWS::KMS::Key when hotswapping #30112

Merged
merged 2 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
Loading