Skip to content
Merged
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
27 changes: 3 additions & 24 deletions packages/aws-cdk/lib/api/deploy-stack.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,14 @@ export async function deployStack(stack: cxapi.SynthesizedStack,
const cfn = await sdk.cloudFormation(stack.environment, Mode.ForWriting);
const bodyParameter = await makeBodyParameter(stack, toolkitInfo);

if (!await stackExists(cfn, deployName)) {
await createEmptyStack(cfn, deployName, quiet);
} else {
debug('Stack named %s already exists, updating it!', deployName);
}
const update = await stackExists(cfn, deployName);

const changeSetName = `CDK-${executionId}`;
debug('Attempting to create ChangeSet %s on stack %s', changeSetName, deployName);
debug(`Attempting to create ChangeSet ${changeSetName} to ${update ? 'update' : 'create'} stack ${deployName}`);
const changeSet = await cfn.createChangeSet({
StackName: deployName,
ChangeSetName: changeSetName,
ChangeSetType: update ? 'UPDATE' : 'CREATE',
Description: `CDK Changeset for execution ${executionId}`,
TemplateBody: bodyParameter.TemplateBody,
TemplateURL: bodyParameter.TemplateURL,
Expand Down Expand Up @@ -87,24 +84,6 @@ async function getStackOutputs(cfn: aws.CloudFormation, stackName: string): Prom
return result;
}

async function createEmptyStack(cfn: aws.CloudFormation, stackName: string, quiet: boolean): Promise<void> {
debug('Creating new empty stack named %s', stackName);

const template = {
Resources: {
WaitCondition: {
Type: 'AWS::CloudFormation::WaitConditionHandle'
}
}
};

const response = await cfn.createStack({ StackName: stackName, TemplateBody: JSON.stringify(template, null, 2) }).promise();
debug('CreateStack response: %j', response);
const monitor = quiet ? undefined : new StackActivityMonitor(cfn, stackName, undefined, 1).start();
await waitForStack(cfn, stackName);
if (monitor) { monitor.stop(); }
}

/**
* Prepares the body parameter for +CreateChangeSet+, putting the generated CloudFormation template in the toolkit-provided
* S3 bucket if present, otherwise using in-line template argument. If no +ToolkitInfo+ is provided and the template is
Expand Down