Skip to content

Commit

Permalink
chore(cli): convert the bootstrap template from JSON to YAML (aws#6799)
Browse files Browse the repository at this point in the history
* chore(cli): convert the bootstrap template from JSON to YAML.

This allows us to add comments to the template,
which make it clearer why certain things
(most noticeably, permissions)
are required.

While I was in the area,
fixed a small issue with the bootstrap integ test
(the test app wasn't respecting the env the bootstrap stack was created in).

* Reuse YAML parsing routines we already have

Co-authored-by: Rico Huijbers <rix0rrr@gmail.com>
Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 19, 2020
1 parent 564561a commit a4dcfb5
Show file tree
Hide file tree
Showing 8 changed files with 335 additions and 433 deletions.
2 changes: 1 addition & 1 deletion design/cdk-bootstrap.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,4 +323,4 @@ This should make sure the CFN update succeeds.
## Bootstrap template

The bootstrap template used by the CLI command can be found in the
[aws-cdk package](../packages/aws-cdk/lib/api/bootstrap/bootstrap-template.json).
[aws-cdk package](../packages/aws-cdk/lib/api/bootstrap/bootstrap-template.yaml).
12 changes: 8 additions & 4 deletions packages/aws-cdk/lib/api/bootstrap/bootstrap-environment2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import * as fs from 'fs-extra';
import * as os from 'os';
import * as path from 'path';
import { BootstrapEnvironmentProps, deployStack, DeployStackResult } from '..';
import { loadStructuredFile } from '../../serialize';
import { SdkProvider } from '../aws-auth';

export async function bootstrapEnvironment2(environment: cxapi.Environment, sdk: SdkProvider,
Expand All @@ -14,11 +15,14 @@ export async function bootstrapEnvironment2(environment: cxapi.Environment, sdk:

const outdir = await fs.mkdtemp(path.join(os.tmpdir(), 'cdk-bootstrap-new'));
const builder = new cxapi.CloudAssemblyBuilder(outdir);
const templateFile = `${toolkitStackName}.template.json`;

await fs.copy(
path.join(__dirname, 'bootstrap-template.json'),
path.join(builder.outdir, templateFile));
// convert from YAML to JSON (which the Cloud Assembly uses)
const templateFile = `${toolkitStackName}.template.json`;
const bootstrapTemplatePath = path.join(__dirname, 'bootstrap-template.yaml');
const bootstrapTemplateObject = loadStructuredFile(bootstrapTemplatePath);
await fs.writeJson(
path.join(builder.outdir, templateFile),
bootstrapTemplateObject);

builder.addArtifact(toolkitStackName, {
type: cxapi.ArtifactType.AWS_CLOUDFORMATION_STACK,
Expand Down
Loading

0 comments on commit a4dcfb5

Please sign in to comment.