Skip to content

Commit 7f2f68b

Browse files
authored
Handle errors when checking CDK bootstrap (#2204)
1 parent 042f3a5 commit 7f2f68b

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

.changeset/eleven-numbers-hide.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@aws-amplify/backend-deployer': patch
3+
---
4+
5+
Handle errors when checking CDK bootstrap.

packages/backend-deployer/src/cdk_error_mapper.test.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,26 @@ const testErrorMappings = [
9696
errorName: 'BootstrapNotDetectedError',
9797
expectedDownstreamErrorMessage: 'Is this account bootstrapped',
9898
},
99+
{
100+
errorMessage:
101+
// eslint-disable-next-line spellcheck/spell-checker
102+
"This CDK deployment requires bootstrap stack version '6', but during the confirmation via SSM parameter /cdk-bootstrap/hnb659fds/version the following error occurred: AccessDeniedException",
103+
expectedTopLevelErrorMessage:
104+
'Unable to detect CDK bootstrap stack due to permission issues.',
105+
errorName: 'BootstrapDetectionError',
106+
expectedDownstreamErrorMessage:
107+
// eslint-disable-next-line spellcheck/spell-checker
108+
"This CDK deployment requires bootstrap stack version '6', but during the confirmation via SSM parameter /cdk-bootstrap/hnb659fds/version the following error occurred: AccessDeniedException",
109+
},
110+
{
111+
errorMessage:
112+
"This CDK deployment requires bootstrap stack version '6', found '5'. Please run 'cdk bootstrap'.",
113+
expectedTopLevelErrorMessage:
114+
'This AWS account and region has outdated CDK bootstrap stack.',
115+
errorName: 'BootstrapOutdatedError',
116+
expectedDownstreamErrorMessage:
117+
"This CDK deployment requires bootstrap stack version '6', found '5'. Please run 'cdk bootstrap'.",
118+
},
99119
{
100120
errorMessage: 'Amplify Backend not found in amplify/backend.ts',
101121
expectedTopLevelErrorMessage:

packages/backend-deployer/src/cdk_error_mapper.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,26 @@ export class CdkErrorMapper {
118118
errorName: 'BootstrapNotDetectedError',
119119
classification: 'ERROR',
120120
},
121+
{
122+
errorRegex:
123+
/This CDK deployment requires bootstrap stack version \S+, found \S+\. Please run 'cdk bootstrap'\./,
124+
humanReadableErrorMessage:
125+
'This AWS account and region has outdated CDK bootstrap stack.',
126+
resolutionMessage:
127+
'Run `cdk bootstrap aws://{YOUR_ACCOUNT_ID}/{YOUR_REGION}` locally to re-bootstrap.',
128+
errorName: 'BootstrapOutdatedError',
129+
classification: 'ERROR',
130+
},
131+
{
132+
errorRegex:
133+
/This CDK deployment requires bootstrap stack version \S+, but during the confirmation via SSM parameter \S+ the following error occurred: AccessDeniedException/,
134+
humanReadableErrorMessage:
135+
'Unable to detect CDK bootstrap stack due to permission issues.',
136+
resolutionMessage:
137+
"Ensure that AWS credentials have an IAM policy that grants read access to 'arn:aws:ssm:*:*:parameter/cdk-bootstrap/*' SSM parameters.",
138+
errorName: 'BootstrapDetectionError',
139+
classification: 'ERROR',
140+
},
121141
{
122142
errorRegex:
123143
/This CDK CLI is not compatible with the CDK library used by your application\. Please upgrade the CLI to the latest version\./,
@@ -326,6 +346,8 @@ export type CDKDeploymentError =
326346
| 'BackendBuildError'
327347
| 'BackendSynthError'
328348
| 'BootstrapNotDetectedError'
349+
| 'BootstrapDetectionError'
350+
| 'BootstrapOutdatedError'
329351
| 'CDKResolveAWSAccountError'
330352
| 'CDKVersionMismatchError'
331353
| 'CFNUpdateNotSupportedError'

0 commit comments

Comments
 (0)