Skip to content

Commit

Permalink
cdk-from-cfn version bump and improve error messages
Browse files Browse the repository at this point in the history
Signed-off-by: Francis <colifran@amazon.com>
  • Loading branch information
colifran committed Mar 7, 2024
1 parent 79b6fcc commit e4b7de6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
5 changes: 4 additions & 1 deletion packages/aws-cdk/lib/commands/migrate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,10 @@ export function generateStack(template: string, stackName: string, language: str
try {
return cdk_from_cfn.transmute(template, language, formattedStackName);
} catch (e) {
throw new Error(`${formattedStackName} could not be generated because ${(e as Error).message}`);
const errorMessage = (e as Error).message === 'unreachable'
? 'template and/or language inputs caused the source code to panic'
: (e as Error).message.replace('TransmuteError: ', '');
throw new Error(`${formattedStackName} could not be generated because ${errorMessage}`);
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/aws-cdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
"aws-sdk": "^2.1562.0",
"camelcase": "^6.3.0",
"cdk-assets": "0.0.0",
"cdk-from-cfn": "^0.133.0",
"cdk-from-cfn": "^0.140.0",
"chalk": "^4",
"chokidar": "^3.6.0",
"decamelize": "^5.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/aws-cdk/test/commands/migrate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ describe('Migrate Function Tests', () => {
});

test('generateStack throws error when called for other language', () => {
expect(() => generateStack(validTemplate, 'BadBadBad', 'php')).toThrowError('BadBadBadStack could not be generated because unreachable');
expect(() => generateStack(validTemplate, 'BadBadBad', 'php')).toThrowError('BadBadBadStack could not be generated because template and/or language inputs caused the source code to panic');
});

test('generateStack throws error for invalid resource property', () => {
expect(() => generateStack(invalidTemplate, 'VeryBad', 'typescript')).toThrow('VeryBadStack could not be generated because unreachable');
expect(() => generateStack(invalidTemplate, 'VeryBad', 'typescript')).toThrow('VeryBadStack could not be generated because ReadEndpoint is not a valid property for resource RDSCluster of type AWS::RDS::DBCluster');
});

cliTest('generateCdkApp generates the expected cdk app when called for typescript', async (workDir) => {
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6307,10 +6307,10 @@ case@1.6.3, case@^1.6.3:
resolved "https://registry.npmjs.org/case/-/case-1.6.3.tgz#0a4386e3e9825351ca2e6216c60467ff5f1ea1c9"
integrity sha512-mzDSXIPaFwVDvZAHqZ9VlbyF4yyXRuX6IvB06WvPYkqJVO24kX1PPhv9bfpKNFZyxYFmmgo03HUiD8iklmJYRQ==

cdk-from-cfn@^0.133.0:
version "0.133.0"
resolved "https://registry.npmjs.org/cdk-from-cfn/-/cdk-from-cfn-0.133.0.tgz#a18dd2c505c8fc0b7f4947f6d6afb3e7fea5b391"
integrity sha512-Yj0kE+GixlSGLNTodCaZEcIeyxzNQonZAykmsSP7wRSm3yYNfg/2XX1tRWi9hzUGMwqYuQr5GsCBymukU0GKsA==
cdk-from-cfn@^0.140.0:
version "0.140.0"
resolved "https://registry.npmjs.org/cdk-from-cfn/-/cdk-from-cfn-0.140.0.tgz#c9cbd96f0f559adfbd1874c03f2ac623427ef6b3"
integrity sha512-i9RjfOeEZDyKqI2FLbZgxuV5FwDkipv/3AqiSSw3TtLaIWi3qQ17GPrVOekINLqC4OgT7tCiMWawswwrM/sAaQ==

cdk-generate-synthetic-examples@^0.1.304:
version "0.1.304"
Expand Down

0 comments on commit e4b7de6

Please # to comment.