-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove dependency from toolkit on CDK (#352)
Due to a cyclic dependency caused by the need for CDK libraries to depend on the toolkit for testing purposes, we decided not to use the CDK to define the "toolkit stack". It's a very simple stack that essentially contains a single bucket. Therefore, we just embed the template in the toolkit code, and finally we don't have cycles anymore. Tested this manually by: * Bootstrapping the toolkit stack in my dev account * Updating the toolkit stack * Verifying that "deploy" can discover the bucket and upload a template The empty "WaitHandle" stack also used the CDK, so this was also embedded inline. --reject-cycles is enabled now Fixes #293
- Loading branch information
Elad Ben-Israel
authored
Jul 17, 2018
1 parent
e021793
commit e1c61fb
Showing
10 changed files
with
222 additions
and
292 deletions.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,12 +1,41 @@ | ||
import { App } from '@aws-cdk/core'; | ||
import { Environment } from '@aws-cdk/cx-api'; | ||
import { Environment, SynthesizedStack } from '@aws-cdk/cx-api'; | ||
import { deployStack, DeployStackResult } from './deploy-stack'; | ||
import { SDK } from './util/sdk'; | ||
import { ToolkitStack } from './util/toolkit-stack'; | ||
|
||
// tslint:disable:max-line-length | ||
|
||
export const BUCKET_NAME_OUTPUT = 'BucketName'; | ||
export const BUCKET_DOMAIN_NAME_OUTPUT = 'BucketDomainName'; | ||
|
||
export async function bootstrapEnvironment(environment: Environment, aws: SDK, toolkitStackName: string): Promise<DeployStackResult> { | ||
const app = new App(); | ||
const stack = new ToolkitStack(app, toolkitStackName, { env: environment }); | ||
const synthesizedStack = await app.synthesizeStack(stack.name); | ||
const synthesizedStack: SynthesizedStack = { | ||
environment, | ||
metadata: { }, | ||
template: { | ||
Description: "The CDK Toolkit Stack. It cas created by `cdk bootstrap` and manages resources necessary for managing your Cloud Applications with AWS CDK.", | ||
Resources: { | ||
StagingBucket: { | ||
Type: "AWS::S3::Bucket", | ||
Properties: { | ||
AccessControl: "Private", | ||
BucketEncryption: { ServerSideEncryptionConfiguration: [ { ServerSideEncryptionByDefault: { SSEAlgorithm: "aws:kms" } } ] } | ||
} | ||
} | ||
}, | ||
Outputs: { | ||
[BUCKET_NAME_OUTPUT]: { | ||
Description: "The name of the S3 bucket owned by the CDK toolkit stack", | ||
Value: { Ref: "StagingBucket" }, | ||
Export: { Name: "CDKToolkit:BucketName" } | ||
}, | ||
[BUCKET_DOMAIN_NAME_OUTPUT]: { | ||
Description: "The domain name of the S3 bucket owned by the CDK toolkit stack", | ||
Value: { "Fn::GetAtt": [ "StagingBucket", "DomainName" ] }, | ||
Export: { Name: "CDKToolkit:BucketDomainName" } | ||
} | ||
} | ||
}, | ||
name: toolkitStackName, | ||
}; | ||
return await deployStack(synthesizedStack, aws); | ||
} |
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
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.