/
bootstrapless-synthesizer.ts
63 lines (55 loc) · 2.15 KB
/
bootstrapless-synthesizer.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
import { DockerImageAssetLocation, DockerImageAssetSource, FileAssetLocation, FileAssetSource } from '../assets';
import { ISynthesisSession } from '../construct-compat';
import { assertBound } from './_shared';
import { DefaultStackSynthesizer } from './default-synthesizer';
/**
* Construction properties of {@link BootstraplessSynthesizer}.
*/
export interface BootstraplessSynthesizerProps {
/**
* The deploy Role ARN to use.
*
* @default - No deploy role (use CLI credentials)
*
*/
readonly deployRoleArn?: string;
/**
* The CFN execution Role ARN to use.
*
* @default - No CloudFormation role (use CLI credentials)
*/
readonly cloudFormationExecutionRoleArn?: string;
}
/**
* A special synthesizer that behaves similarly to DefaultStackSynthesizer,
* but doesn't require bootstrapping the environment it operates in.
* Because of that, stacks using it cannot have assets inside of them.
* Used by the CodePipeline construct for the support stacks needed for
* cross-region replication S3 buckets.
*/
export class BootstraplessSynthesizer extends DefaultStackSynthesizer {
constructor(props: BootstraplessSynthesizerProps) {
super({
deployRoleArn: props.deployRoleArn,
cloudFormationExecutionRole: props.cloudFormationExecutionRoleArn,
generateBootstrapVersionRule: false,
});
}
public addFileAsset(_asset: FileAssetSource): FileAssetLocation {
throw new Error('Cannot add assets to a Stack that uses the BootstraplessSynthesizer');
}
public addDockerImageAsset(_asset: DockerImageAssetSource): DockerImageAssetLocation {
throw new Error('Cannot add assets to a Stack that uses the BootstraplessSynthesizer');
}
public synthesize(session: ISynthesisSession): void {
assertBound(this.stack);
this.synthesizeStackTemplate(this.stack, session);
// do _not_ treat the template as an asset,
// because this synthesizer doesn't have a bootstrap bucket to put it in
this.emitStackArtifact(this.stack, session, {
assumeRoleArn: this.deployRoleArn,
cloudFormationExecutionRoleArn: this.cloudFormationExecutionRoleArn,
requiresBootstrapStackVersion: 1,
});
}
}