-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
61 lines (51 loc) · 1.54 KB
/
index.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
#!/usr/bin/env node
import cdk = require('@aws-cdk/core');
import { StaticSite } from './static-site';
import { Pipeline } from './pipeline';
// Configuration
const appName = 'MyStaticSite'
// aws
const awsAccount = '';
const awsRegion = 'us-east-1'
const awsServiceRoleName = 'ServiceRoleCloudFormationAdminAccess'
// github token
const sourceToken = 'github-token-xxxxx'
const app = new cdk.App();
/**
* This stack relies on getting the domain name from CDK context.
* Use 'cdk synth -c domain=mystaticsite.com -c subdomain=www'
* Or add the following to cdk.json:
* {
* "context": {
* "domain": "mystaticsite.com",
* "subdomain": "www",
* "account": "awsAccount_id"
* }
* }
**/
class MyStaticSiteStack extends cdk.Stack {
constructor(parent: cdk.App, name: string, props: cdk.StackProps) {
super(parent, name, props);
new StaticSite(this, 'StaticSite', {
domainName: this.node.tryGetContext('domain'),
siteSubDomain: this.node.tryGetContext('subdomain'),
});
}
}
class PipelineStack extends cdk.Stack {
constructor(parent: cdk.App, name: string, props: cdk.StackProps) {
super(parent, name, props);
new Pipeline(this, 'Pipeline', {
sourceToken,
cfnTemplate: appName + '.template.json',
serviceRole: 'arn:aws:iam::' + awsAccount + ':role/' + awsServiceRoleName
});
}
}
new MyStaticSiteStack(app, appName, {
env: { region: awsRegion, account: awsAccount }
});
new PipelineStack(app, 'PipelineMyStaticSite', {
env: { region: awsRegion, account: awsAccount }
})
app.synth();