carlin 0.22.1 → 0.22.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/deploy/cicd/lambdas/imageUpdaterSchedule.handler.js +4 -3
- package/dist/deploy/cicd/lambdas/pipelines.handler.js +2 -2
- package/dist/deploy/cicd/pipelines.js +3 -2
- package/dist/deploy/staticApp/staticApp.template.js +27 -57
- package/dist/deploy/staticApp/uploadBuiltAppToS3.js +5 -11
- package/package.json +2 -1
|
@@ -2,10 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.imageUpdaterScheduleHandler = void 0;
|
|
4
4
|
const executeTasks_1 = require("./executeTasks");
|
|
5
|
+
/**
|
|
6
|
+
* Update CI/CD resources with the newest carlin and repository image.
|
|
7
|
+
*/
|
|
5
8
|
const imageUpdaterScheduleHandler = async () => {
|
|
6
9
|
const cicdConfig = process.env.CICD_CONFIG;
|
|
7
10
|
if (!cicdConfig) {
|
|
8
|
-
console.log('No CICD config found.');
|
|
9
11
|
return;
|
|
10
12
|
}
|
|
11
13
|
const commands = [
|
|
@@ -20,7 +22,7 @@ const imageUpdaterScheduleHandler = async () => {
|
|
|
20
22
|
'cat carlin.json',
|
|
21
23
|
`carlin deploy cicd -c carlin.json`,
|
|
22
24
|
];
|
|
23
|
-
|
|
25
|
+
await (0, executeTasks_1.executeTasks)({
|
|
24
26
|
commands,
|
|
25
27
|
cpu: '512',
|
|
26
28
|
memory: '2048',
|
|
@@ -31,6 +33,5 @@ const imageUpdaterScheduleHandler = async () => {
|
|
|
31
33
|
},
|
|
32
34
|
],
|
|
33
35
|
});
|
|
34
|
-
console.log(JSON.stringify(response, null, 2));
|
|
35
36
|
};
|
|
36
37
|
exports.imageUpdaterScheduleHandler = imageUpdaterScheduleHandler;
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.pipelinesHandler = exports.getJobDetails = exports.getJobDetailsFilename = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const adm_zip_1 = tslib_1.__importDefault(require("adm-zip"));
|
|
6
|
-
const aws_sdk_1 = require("aws-sdk");
|
|
7
5
|
const fs = tslib_1.__importStar(require("fs"));
|
|
6
|
+
const aws_sdk_1 = require("aws-sdk");
|
|
8
7
|
const pipelines_1 = require("../pipelines");
|
|
9
8
|
const executeTasks_1 = require("./executeTasks");
|
|
10
9
|
const putApprovalResultManualTask_1 = require("./putApprovalResultManualTask");
|
|
10
|
+
const adm_zip_1 = tslib_1.__importDefault(require("adm-zip"));
|
|
11
11
|
const codepipeline = new aws_sdk_1.CodePipeline();
|
|
12
12
|
const getUserParameters = (event) => {
|
|
13
13
|
const [pipeline, stage] = event['CodePipeline.job'].data.actionConfiguration.configuration.UserParameters.split('&');
|
|
@@ -12,7 +12,7 @@ const getPrCommands = ({ branch }) => [
|
|
|
12
12
|
* Update to the most recent main branch to Lerna performs the diff properly.
|
|
13
13
|
*/
|
|
14
14
|
'git pull origin main',
|
|
15
|
-
`git checkout ${branch} || echo 'branch not found, probably deleted'; exit 0`,
|
|
15
|
+
`git checkout ${branch} || (echo 'branch not found, probably deleted'; exit 0)`,
|
|
16
16
|
`git pull origin ${branch}`,
|
|
17
17
|
'git rev-parse HEAD',
|
|
18
18
|
'git status',
|
|
@@ -45,7 +45,8 @@ const getMainCommands = () => [
|
|
|
45
45
|
/**
|
|
46
46
|
* Reporting `MainTagFound` before exiting the process. This command blocks
|
|
47
47
|
* the process if tag was found. If we don't do this, the loop would never
|
|
48
|
-
* end
|
|
48
|
+
* end because `main` command can create a tag, that would trigger this
|
|
49
|
+
* pipeline again.
|
|
49
50
|
*/
|
|
50
51
|
'if git describe --exact-match; then echo "Tag found" && carlin cicd-ecs-task-report --status=MainTagFound && exit 0; fi',
|
|
51
52
|
'yarn',
|
|
@@ -6,15 +6,14 @@ const getOriginShieldRegion_1 = require("./getOriginShieldRegion");
|
|
|
6
6
|
const PACKAGE_VERSION = (0, utils_1.getPackageVersion)();
|
|
7
7
|
const STATIC_APP_BUCKET_LOGICAL_ID = 'StaticBucket';
|
|
8
8
|
const CLOUDFRONT_DISTRIBUTION_ID = 'CloudFrontDistributionId';
|
|
9
|
-
const CLOUDFRONT_DISTRIBUTION_ORIGIN_ACCESS_IDENTITY_LOGICAL_ID = 'CloudFrontDistributionOriginAccessIdentity';
|
|
10
9
|
exports.CLOUDFRONT_DISTRIBUTION_LOGICAL_ID = 'CloudFrontDistribution';
|
|
11
10
|
exports.ROUTE_53_RECORD_SET_GROUP_LOGICAL_ID = 'Route53RecordSetGroup';
|
|
12
11
|
/**
|
|
13
|
-
* Name: Managed-
|
|
14
|
-
* ID:
|
|
12
|
+
* Name: Managed-CachingDisabled
|
|
13
|
+
* ID: 4135ea2d-6df8-44a3-9df3-4b5a84be39ad
|
|
15
14
|
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-cache-policies.html
|
|
16
15
|
*/
|
|
17
|
-
const CACHE_POLICY_ID = '
|
|
16
|
+
const CACHE_POLICY_ID = '4135ea2d-6df8-44a3-9df3-4b5a84be39ad';
|
|
18
17
|
/**
|
|
19
18
|
* Name: Managed-CORS-S3Origin
|
|
20
19
|
* ID: 88a5eaf4-2fd4-4709-b370-b4c650ea3fcf
|
|
@@ -27,7 +26,7 @@ const ORIGIN_REQUEST_POLICY_ID = '88a5eaf4-2fd4-4709-b370-b4c650ea3fcf';
|
|
|
27
26
|
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/using-managed-response-headers-policies.html
|
|
28
27
|
*/
|
|
29
28
|
const ORIGIN_RESPONSE_POLICY_ID = 'eaab4381-ed33-4a86-88ca-d9558dc6cd63';
|
|
30
|
-
const getBaseTemplate = ({
|
|
29
|
+
const getBaseTemplate = ({ spa, }) => {
|
|
31
30
|
return {
|
|
32
31
|
AWSTemplateFormatVersion: '2010-09-09',
|
|
33
32
|
Resources: {
|
|
@@ -47,7 +46,7 @@ const getBaseTemplate = ({ cloudfront, spa, }) => {
|
|
|
47
46
|
},
|
|
48
47
|
WebsiteConfiguration: {
|
|
49
48
|
IndexDocument: `index.html`,
|
|
50
|
-
ErrorDocument:
|
|
49
|
+
ErrorDocument: spa ? 'index.html' : '404/index.html',
|
|
51
50
|
},
|
|
52
51
|
},
|
|
53
52
|
},
|
|
@@ -60,6 +59,7 @@ const getBaseTemplate = ({ cloudfront, spa, }) => {
|
|
|
60
59
|
{
|
|
61
60
|
Action: ['s3:GetObject'],
|
|
62
61
|
Effect: 'Allow',
|
|
62
|
+
Principal: '*',
|
|
63
63
|
Resource: {
|
|
64
64
|
'Fn::Join': [
|
|
65
65
|
'',
|
|
@@ -70,23 +70,6 @@ const getBaseTemplate = ({ cloudfront, spa, }) => {
|
|
|
70
70
|
],
|
|
71
71
|
],
|
|
72
72
|
},
|
|
73
|
-
Principal: cloudfront
|
|
74
|
-
? /**
|
|
75
|
-
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/private-content-restricting-access-to-s3.html
|
|
76
|
-
*/
|
|
77
|
-
{
|
|
78
|
-
AWS: {
|
|
79
|
-
'Fn::Sub': [
|
|
80
|
-
'arn:aws:iam::cloudfront:user/CloudFront Origin Access Identity ${OAI}',
|
|
81
|
-
{
|
|
82
|
-
OAI: {
|
|
83
|
-
Ref: CLOUDFRONT_DISTRIBUTION_ORIGIN_ACCESS_IDENTITY_LOGICAL_ID,
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
],
|
|
87
|
-
},
|
|
88
|
-
}
|
|
89
|
-
: '*',
|
|
90
73
|
},
|
|
91
74
|
],
|
|
92
75
|
},
|
|
@@ -106,19 +89,6 @@ const getBaseTemplate = ({ cloudfront, spa, }) => {
|
|
|
106
89
|
const getCloudFrontTemplate = ({ acm, aliases = [], cloudfront, spa, hostedZoneName, region, }) => {
|
|
107
90
|
const template = { ...getBaseTemplate({ cloudfront, spa }) };
|
|
108
91
|
const cloudFrontResources = {
|
|
109
|
-
[CLOUDFRONT_DISTRIBUTION_ORIGIN_ACCESS_IDENTITY_LOGICAL_ID]: {
|
|
110
|
-
Type: 'AWS::CloudFront::CloudFrontOriginAccessIdentity',
|
|
111
|
-
Properties: {
|
|
112
|
-
CloudFrontOriginAccessIdentityConfig: {
|
|
113
|
-
Comment: {
|
|
114
|
-
'Fn::Sub': [
|
|
115
|
-
'CloudFront Distribution Origin Access Identity for ${Project} project.',
|
|
116
|
-
{ Project: { Ref: 'Project' } },
|
|
117
|
-
],
|
|
118
|
-
},
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
92
|
[exports.CLOUDFRONT_DISTRIBUTION_LOGICAL_ID]: {
|
|
123
93
|
Type: 'AWS::CloudFront::Distribution',
|
|
124
94
|
Properties: {
|
|
@@ -142,17 +112,17 @@ const getCloudFrontTemplate = ({ acm, aliases = [], cloudfront, spa, hostedZoneN
|
|
|
142
112
|
ErrorCachingMinTTL: 0,
|
|
143
113
|
ErrorCode: errorCode,
|
|
144
114
|
ResponseCode: 404,
|
|
145
|
-
ResponsePagePath: '/404
|
|
115
|
+
ResponsePagePath: '/404',
|
|
146
116
|
};
|
|
147
117
|
}),
|
|
148
118
|
DefaultCacheBehavior: {
|
|
149
119
|
AllowedMethods: ['GET', 'HEAD', 'OPTIONS'],
|
|
150
120
|
Compress: true,
|
|
121
|
+
CachedMethods: ['GET', 'HEAD', 'OPTIONS'],
|
|
151
122
|
/**
|
|
152
123
|
* Caching OPTIONS. Related to OriginRequestPolicyId property.
|
|
153
124
|
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/header-caching.html#header-caching-web-cors
|
|
154
125
|
*/
|
|
155
|
-
CachedMethods: ['GET', 'HEAD', 'OPTIONS'],
|
|
156
126
|
OriginRequestPolicyId: ORIGIN_REQUEST_POLICY_ID,
|
|
157
127
|
/**
|
|
158
128
|
* CachePolicyId property:
|
|
@@ -163,20 +133,34 @@ const getCloudFrontTemplate = ({ acm, aliases = [], cloudfront, spa, hostedZoneN
|
|
|
163
133
|
TargetOriginId: { Ref: STATIC_APP_BUCKET_LOGICAL_ID },
|
|
164
134
|
ViewerProtocolPolicy: 'redirect-to-https',
|
|
165
135
|
},
|
|
166
|
-
DefaultRootObject: 'index.html',
|
|
136
|
+
DefaultRootObject: spa ? 'index.html' : undefined,
|
|
167
137
|
Enabled: true,
|
|
168
138
|
HttpVersion: 'http2',
|
|
169
139
|
Origins: [
|
|
170
140
|
{
|
|
141
|
+
CustomOriginConfig: {
|
|
142
|
+
OriginProtocolPolicy: 'http-only',
|
|
143
|
+
},
|
|
171
144
|
/**
|
|
172
|
-
*
|
|
173
|
-
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/distribution-web-values-specify.html#DownloadDistValuesDomainName
|
|
145
|
+
* https://github.com/aws/aws-cdk/issues/1882#issuecomment-629141467
|
|
174
146
|
*/
|
|
175
147
|
DomainName: {
|
|
176
|
-
'Fn::
|
|
148
|
+
'Fn::Select': [
|
|
149
|
+
1,
|
|
150
|
+
{
|
|
151
|
+
'Fn::Split': [
|
|
152
|
+
'//',
|
|
153
|
+
{
|
|
154
|
+
'Fn::GetAtt': [
|
|
155
|
+
STATIC_APP_BUCKET_LOGICAL_ID,
|
|
156
|
+
'WebsiteURL',
|
|
157
|
+
],
|
|
158
|
+
},
|
|
159
|
+
],
|
|
160
|
+
},
|
|
161
|
+
],
|
|
177
162
|
},
|
|
178
163
|
Id: { Ref: STATIC_APP_BUCKET_LOGICAL_ID },
|
|
179
|
-
OriginPath: `/${PACKAGE_VERSION}`,
|
|
180
164
|
/**
|
|
181
165
|
* https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/origin-shield.html#choose-origin-shield-region
|
|
182
166
|
*/
|
|
@@ -186,20 +170,6 @@ const getCloudFrontTemplate = ({ acm, aliases = [], cloudfront, spa, hostedZoneN
|
|
|
186
170
|
OriginShieldRegion: (0, getOriginShieldRegion_1.getOriginShieldRegion)(region),
|
|
187
171
|
},
|
|
188
172
|
}),
|
|
189
|
-
S3OriginConfig: {
|
|
190
|
-
OriginAccessIdentity: {
|
|
191
|
-
'Fn::Join': [
|
|
192
|
-
'/',
|
|
193
|
-
[
|
|
194
|
-
'origin-access-identity',
|
|
195
|
-
'cloudfront',
|
|
196
|
-
{
|
|
197
|
-
Ref: CLOUDFRONT_DISTRIBUTION_ORIGIN_ACCESS_IDENTITY_LOGICAL_ID,
|
|
198
|
-
},
|
|
199
|
-
],
|
|
200
|
-
],
|
|
201
|
-
},
|
|
202
|
-
},
|
|
203
173
|
},
|
|
204
174
|
],
|
|
205
175
|
},
|
|
@@ -3,9 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.uploadBuiltAppToS3 = void 0;
|
|
4
4
|
const findDefaultBuildFolder_1 = require("./findDefaultBuildFolder");
|
|
5
5
|
const s3_1 = require("../s3");
|
|
6
|
-
const
|
|
7
|
-
const uploadBuiltAppToS3 = async ({ buildFolder: directory, bucket, cloudfront, }) => {
|
|
8
|
-
const version = cloudfront ? (0, utils_1.getPackageVersion)() : undefined;
|
|
6
|
+
const uploadBuiltAppToS3 = async ({ buildFolder: directory, bucket, }) => {
|
|
9
7
|
/**
|
|
10
8
|
* Only empty directory if the number of the files inside $directory.
|
|
11
9
|
* If the number of files is zero, uploadDirectoryToS3 will thrown.
|
|
@@ -13,19 +11,15 @@ const uploadBuiltAppToS3 = async ({ buildFolder: directory, bucket, cloudfront,
|
|
|
13
11
|
if (directory) {
|
|
14
12
|
const files = await (0, s3_1.getAllFilesInsideADirectory)({ directory });
|
|
15
13
|
if (files.length > 0) {
|
|
16
|
-
await (0, s3_1.emptyS3Directory)({ bucket
|
|
14
|
+
await (0, s3_1.emptyS3Directory)({ bucket });
|
|
17
15
|
}
|
|
18
|
-
await (0, s3_1.uploadDirectoryToS3)({ bucket,
|
|
16
|
+
await (0, s3_1.uploadDirectoryToS3)({ bucket, directory });
|
|
19
17
|
return;
|
|
20
18
|
}
|
|
21
19
|
const defaultDirectory = await (0, findDefaultBuildFolder_1.findDefaultBuildFolder)();
|
|
22
20
|
if (defaultDirectory) {
|
|
23
|
-
await (0, s3_1.emptyS3Directory)({ bucket
|
|
24
|
-
await (0, s3_1.uploadDirectoryToS3)({
|
|
25
|
-
bucket,
|
|
26
|
-
bucketKey: version,
|
|
27
|
-
directory: defaultDirectory,
|
|
28
|
-
});
|
|
21
|
+
await (0, s3_1.emptyS3Directory)({ bucket });
|
|
22
|
+
await (0, s3_1.uploadDirectoryToS3)({ bucket, directory: defaultDirectory });
|
|
29
23
|
return;
|
|
30
24
|
}
|
|
31
25
|
throw new Error(`build-folder option wasn't provided and files weren't found in ${findDefaultBuildFolder_1.defaultBuildFolders.join(', ')} directories.`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "carlin",
|
|
3
|
-
"version": "0.22.
|
|
3
|
+
"version": "0.22.4",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -47,6 +47,7 @@
|
|
|
47
47
|
"prettier": "^2.6.2",
|
|
48
48
|
"semver": "^7.3.7",
|
|
49
49
|
"simple-git": "^3.7.1",
|
|
50
|
+
"ts-node": "^10.8.1",
|
|
50
51
|
"uglify-js": "^3.15.4",
|
|
51
52
|
"yargs": "^17.4.1"
|
|
52
53
|
},
|