-
Notifications
You must be signed in to change notification settings - Fork 4k
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(toolkit): 'cdk deploy' support updates to Outputs #2029
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,32 +86,53 @@ async function waitFor<T>(valueProvider: () => Promise<T | null | undefined>, ti | |
/** | ||
* Waits for a ChangeSet to be available for triggering a StackUpdate. | ||
* | ||
* Will return a changeset that is either ready to be executed or has no changes. | ||
* Will throw in other cases. | ||
* | ||
* @param cfn a CloudFormation client | ||
* @param stackName the name of the Stack that the ChangeSet belongs to | ||
* @param changeSetName the name of the ChangeSet | ||
* | ||
* @returns the CloudFormation description of the ChangeSet | ||
*/ | ||
// tslint:disable-next-line:max-line-length | ||
export async function waitForChangeSet(cfn: CloudFormation, stackName: string, changeSetName: string): Promise<CloudFormation.DescribeChangeSetOutput | undefined> { | ||
export async function waitForChangeSet(cfn: CloudFormation, stackName: string, changeSetName: string): Promise<CloudFormation.DescribeChangeSetOutput> { | ||
debug('Waiting for changeset %s on stack %s to finish creating...', changeSetName, stackName); | ||
return waitFor(async () => { | ||
const ret = await waitFor(async () => { | ||
const description = await describeChangeSet(cfn, stackName, changeSetName); | ||
// The following doesn't use a switch because tsc will not allow fall-through, UNLESS it is allows | ||
// EVERYWHERE that uses this library directly or indirectly, which is undesirable. | ||
if (description.Status === 'CREATE_PENDING' || description.Status === 'CREATE_IN_PROGRESS') { | ||
debug('Changeset %s on stack %s is still creating', changeSetName, stackName); | ||
return undefined; | ||
} else if (description.Status === 'CREATE_COMPLETE') { | ||
} | ||
|
||
if (description.Status === 'CREATE_COMPLETE' || changeSetHasNoChanges(description)) { | ||
return description; | ||
} else if (description.Status === 'FAILED') { | ||
if (description.StatusReason && description.StatusReason.startsWith('The submitted information didn\'t contain changes.')) { | ||
return description; | ||
} | ||
} | ||
|
||
// tslint:disable-next-line:max-line-length | ||
throw new Error(`Failed to create ChangeSet ${changeSetName} on ${stackName}: ${description.Status || 'NO_STATUS'}, ${description.StatusReason || 'no reason provided'}`); | ||
}); | ||
|
||
if (!ret) { | ||
throw new Error('Change set took too long to be created; aborting'); | ||
} | ||
|
||
return ret; | ||
} | ||
|
||
/** | ||
* Return true if the given change set has no changes | ||
* | ||
* This must be determined from the status, not the 'Changes' array on the | ||
* object; the latter can be empty because no resources were changed, but if | ||
* there are changes to Outputs, the change set can still be executed. | ||
*/ | ||
export function changeSetHasNoChanges(description: CloudFormation.DescribeChangeSetOutput) { | ||
return description.Status === 'FAILED' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this 4-space indented? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It might be. |
||
&& description.StatusReason | ||
&& description.StatusReason.startsWith('The submitted information didn\'t contain changes.'); | ||
} | ||
|
||
/** | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this really a failure mode here? Like... some kind of a timeout?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the question? Can this really happen in practice, can the code path be taken, ...?