/
.projenrc.js
162 lines (144 loc) · 3.97 KB
/
.projenrc.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
const {
AwsCdkConstructLibrary,
Gitpod,
DevEnvironmentDockerImage,
} = require('projen');
const AUTOMATION_TOKEN = 'PROJEN_GITHUB_TOKEN';
const project = new AwsCdkConstructLibrary({
author: 'Chris Yang',
authorUrl: 'https://9incloud.com/',
cdkVersion: '1.111.0',
defaultReleaseBranch: 'main',
name: 'cdk-automated-waf',
repositoryUrl: 'https://github.com/kimisme9386/cdk-automated-waf.git',
description: 'Cloudfront and ALB with Automated WAF',
cdkDependencies: [
'@aws-cdk/core',
'@aws-cdk/aws-iam',
'@aws-cdk/aws-lambda',
'@aws-cdk/aws-s3',
'@aws-cdk/aws-kinesisfirehose',
'@aws-cdk/aws-glue',
'@aws-cdk/aws-athena',
'@aws-cdk/aws-wafv2',
'@aws-cdk/aws-cloudwatch',
'@aws-cdk/aws-events',
'@aws-cdk/aws-events-targets',
'@aws-cdk/aws-s3-notifications',
'@aws-cdk/custom-resources',
'@aws-cdk/aws-apigateway',
],
devDeps: ['projen-automate-it'],
publishToPypi: {
distName: 'cdk-automated-waf',
module: 'cdk-automated-waf',
},
catalog: {
announce: true,
},
stability: 'experimental',
autoApproveOptions: {
secret: 'GITHUB_TOKEN',
allowedUsernames: ['kimisme9386-bot'],
},
depsUpgrade: false,
release: false,
depsUpgradeOptions: {
workflowOptions: {
labels: ['auto-approve'],
secret: AUTOMATION_TOKEN,
},
ignoreProjen: false,
},
// update snapshot test by workflow because aws region need undefined
releaseWorkflowSetupSteps: [
{
name: 'run build',
run: 'yarn build',
},
{
name: 'run test',
run: 'yarn test',
},
{
name: 'run test update',
run: 'yarn test:update',
},
{
uses: 'EndBug/add-and-commit@v7',
with: {
add: 'test',
author_name: 'Chris Yang',
author_email: 'kimisme9386@gmail.com',
message: 'fix: update test snapshot',
},
},
],
});
project.eslint.addRules({
'comma-dangle': [
'error',
{
arrays: 'always-multiline',
objects: 'always-multiline',
imports: 'always-multiline',
exports: 'always-multiline',
functions: 'never',
},
],
});
const common_exclude = [
'cdk.out',
'cdk.context.json',
'images',
'yarn-error.log',
'dependabot.yml',
'lambda/codepipeline-event/dist',
];
project.npmignore.exclude(...common_exclude);
project.gitignore.exclude(...common_exclude);
const common_include = ['/lambda/codepipeline-event/tsconfig.json'];
project.npmignore.include(...common_include);
project.gitignore.include(...common_include);
// integration test
const cdkDiffInteg = project.addTask('cdk:diff-integ', {
description: 'cdk diff for integration test',
});
cdkDiffInteg.exec('cdk diff --app "npx ts-node --prefer-ts-exts src/integ.default.ts" -R --require-approval never');
const cdkDeployInteg = project.addTask('cdk:deploy-integ', {
description: 'cdk diff for integration test',
});
cdkDeployInteg.exec('cdk deploy --app "npx ts-node --prefer-ts-exts src/integ.default.ts" -R --require-approval never');
// gitpod
const gitpodPrebuild = project.addTask('gitpod:prebuild', {
description: 'Prebuild setup for Gitpod',
});
gitpodPrebuild.exec('yarn install --frozen-lockfile --check-files');
gitpodPrebuild.exec('npx projen upgrade');
gitpodPrebuild.exec('npm i -g aws-cdk');
let gitpod = new Gitpod(project, {
dockerImage: DevEnvironmentDockerImage.fromFile('.gitpod.Dockerfile'),
prebuilds: {
addCheck: true,
addBadge: true,
addLabel: true,
branches: true,
pullRequests: true,
pullRequestsFromForks: true,
},
});
gitpod.addCustomTask({
name: 'install package and check zsh and zsh plugin',
init: `yarn gitpod:prebuild
sudo chmod +x ./.gitpod/oh-my-zsh.sh && ./.gitpod/oh-my-zsh.sh`,
});
gitpod.addCustomTask({
name: 'change default shell to zsh and start zsh shell',
command: 'sudo chsh -s $(which zsh) && zsh',
});
/* spellchecker: disable */
gitpod.addVscodeExtensions(
'dbaeumer.vscode-eslint',
'streetsidesoftware.code-spell-checker-spanish'
);
project.synth();