carlin 0.19.16 → 0.20.2
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/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,35 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.20.2](https://github.com/ttoss/carlin/compare/v0.20.1...v0.20.2) (2022-02-01)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- update actions iam ([0fe5300](https://github.com/ttoss/carlin/commit/0fe53000c541d56e9d410853551bacbcb326a92c))
|
|
11
|
+
|
|
12
|
+
## [0.20.1](https://github.com/ttoss/carlin/compare/v0.20.0...v0.20.1) (2022-02-01)
|
|
13
|
+
|
|
14
|
+
### Bug Fixes
|
|
15
|
+
|
|
16
|
+
- update actions iam ([4ff073f](https://github.com/ttoss/carlin/commit/4ff073f6067ca20994c9af892d0c4aa62c2c2b90))
|
|
17
|
+
- update actions iam ([b5dd158](https://github.com/ttoss/carlin/commit/b5dd158ec992720e33b1c98baff495962a9e3481))
|
|
18
|
+
|
|
19
|
+
# [0.20.0](https://github.com/ttoss/carlin/compare/v0.19.17...v0.20.0) (2022-02-01)
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
- update cloudfront protocol ([13678cd](https://github.com/ttoss/carlin/commit/13678cd3551924aa47d72ec322ea3d8c0e0502bc))
|
|
24
|
+
|
|
25
|
+
### Features
|
|
26
|
+
|
|
27
|
+
- add tags to ecs report ([d0bf69d](https://github.com/ttoss/carlin/commit/d0bf69d82a737053a539356d8ba7afba966dacc3))
|
|
28
|
+
|
|
29
|
+
## [0.19.17](https://github.com/ttoss/carlin/compare/v0.19.16...v0.19.17) (2022-01-24)
|
|
30
|
+
|
|
31
|
+
### Bug Fixes
|
|
32
|
+
|
|
33
|
+
- pipelines commands ([1c01d40](https://github.com/ttoss/carlin/commit/1c01d4077ae6fc9fc1ab6a565c0d08b50a575664))
|
|
34
|
+
|
|
6
35
|
## [0.19.16](https://github.com/ttoss/carlin/compare/v0.19.15...v0.19.16) (2022-01-04)
|
|
7
36
|
|
|
8
37
|
### Bug Fixes
|
|
@@ -311,7 +311,8 @@ const getCicdTemplate = ({ pipelines = [], cpu = config_2.ECS_TASK_DEFAULT_CPU,
|
|
|
311
311
|
],
|
|
312
312
|
},
|
|
313
313
|
};
|
|
314
|
-
resources[exports.REPOSITORY_IMAGE_CODE_BUILD_PROJECT_LOGICAL_ID] =
|
|
314
|
+
resources[exports.REPOSITORY_IMAGE_CODE_BUILD_PROJECT_LOGICAL_ID] =
|
|
315
|
+
exports.getRepositoryImageBuilder();
|
|
315
316
|
})();
|
|
316
317
|
const createApiResources = () => {
|
|
317
318
|
resources[exports.API_LOGICAL_ID] = {
|
|
@@ -376,6 +377,11 @@ const getCicdTemplate = ({ pipelines = [], cpu = config_2.ECS_TASK_DEFAULT_CPU,
|
|
|
376
377
|
},
|
|
377
378
|
],
|
|
378
379
|
},
|
|
380
|
+
{
|
|
381
|
+
Effect: 'Allow',
|
|
382
|
+
Action: ['ecs:DescribeTasks'],
|
|
383
|
+
Resource: '*',
|
|
384
|
+
},
|
|
379
385
|
{
|
|
380
386
|
Effect: 'Allow',
|
|
381
387
|
Action: ['ecs:RunTask'],
|
|
@@ -517,27 +523,28 @@ const getCicdTemplate = ({ pipelines = [], cpu = config_2.ECS_TASK_DEFAULT_CPU,
|
|
|
517
523
|
/**
|
|
518
524
|
* Used to start the container.
|
|
519
525
|
*/
|
|
520
|
-
resources[exports.REPOSITORY_TASKS_ECS_TASK_DEFINITION_EXECUTION_ROLE_LOGICAL_ID] =
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
526
|
+
resources[exports.REPOSITORY_TASKS_ECS_TASK_DEFINITION_EXECUTION_ROLE_LOGICAL_ID] =
|
|
527
|
+
{
|
|
528
|
+
Type: 'AWS::IAM::Role',
|
|
529
|
+
Properties: {
|
|
530
|
+
AssumeRolePolicyDocument: {
|
|
531
|
+
Version: '2012-10-17',
|
|
532
|
+
Statement: [
|
|
533
|
+
{
|
|
534
|
+
Effect: 'Allow',
|
|
535
|
+
Principal: {
|
|
536
|
+
Service: 'ecs-tasks.amazonaws.com',
|
|
537
|
+
},
|
|
538
|
+
Action: 'sts:AssumeRole',
|
|
530
539
|
},
|
|
531
|
-
|
|
532
|
-
|
|
540
|
+
],
|
|
541
|
+
},
|
|
542
|
+
ManagedPolicyArns: [
|
|
543
|
+
'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy',
|
|
533
544
|
],
|
|
545
|
+
Path: utils_1.getIamPath(),
|
|
534
546
|
},
|
|
535
|
-
|
|
536
|
-
'arn:aws:iam::aws:policy/service-role/AmazonECSTaskExecutionRolePolicy',
|
|
537
|
-
],
|
|
538
|
-
Path: utils_1.getIamPath(),
|
|
539
|
-
},
|
|
540
|
-
};
|
|
547
|
+
};
|
|
541
548
|
/**
|
|
542
549
|
* Used inside de container execution.
|
|
543
550
|
*/
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ecsTaskReportHandler = exports.getEcsTaskLogsUrl = void 0;
|
|
3
|
+
exports.ecsTaskReportHandler = exports.getEcsTaskTags = exports.getEcsTaskLogsUrl = void 0;
|
|
4
4
|
const webhook_1 = require("@slack/webhook");
|
|
5
|
+
const aws_sdk_1 = require("aws-sdk");
|
|
5
6
|
const putApprovalResultManualTask_1 = require("./putApprovalResultManualTask");
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
!process.env.ECS_TASK_LOGS_LOG_GROUP) {
|
|
9
|
-
return undefined;
|
|
10
|
-
}
|
|
7
|
+
const ecs = new aws_sdk_1.ECS({ apiVersion: '2014-11-13' });
|
|
8
|
+
const getEcsTaskId = ({ ecsTaskArn }) => {
|
|
11
9
|
/**
|
|
12
10
|
* Arn has the following format:
|
|
13
11
|
* arn:aws:ecs:us-east-1:483684946879:task/CarlinCicdCarlinMonorepo-RepositoryTasksECSCluster-1J6saGT91hCr/6fcc78682de442ae89a0b7339ac7d981
|
|
@@ -15,6 +13,24 @@ const getEcsTaskLogsUrl = ({ ecsTaskArn }) => {
|
|
|
15
13
|
* We want the "6fcc78682de442ae89a0b7339ac7d981" part.
|
|
16
14
|
*/
|
|
17
15
|
const ecsTaskId = ecsTaskArn.split('/')[2];
|
|
16
|
+
return ecsTaskId;
|
|
17
|
+
};
|
|
18
|
+
const getEcsTaskCluster = ({ ecsTaskArn }) => {
|
|
19
|
+
/**
|
|
20
|
+
* Arn has the following format:
|
|
21
|
+
* arn:aws:ecs:us-east-1:483684946879:task/CarlinCicdCarlinMonorepo-RepositoryTasksECSCluster-1J6saGT91hCr/6fcc78682de442ae89a0b7339ac7d981
|
|
22
|
+
*
|
|
23
|
+
* We want the "CarlinCicdCarlinMonorepo-RepositoryTasksECSCluster-1J6saGT91hCr" part.
|
|
24
|
+
*/
|
|
25
|
+
const ecsTaskCluster = ecsTaskArn.split('/')[1];
|
|
26
|
+
return ecsTaskCluster;
|
|
27
|
+
};
|
|
28
|
+
const getEcsTaskLogsUrl = ({ ecsTaskArn }) => {
|
|
29
|
+
if (!process.env.ECS_TASK_CONTAINER_NAME ||
|
|
30
|
+
!process.env.ECS_TASK_LOGS_LOG_GROUP) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
const ecsTaskId = getEcsTaskId({ ecsTaskArn });
|
|
18
34
|
const ecsTaskLogsUrl = new URL([
|
|
19
35
|
/**
|
|
20
36
|
* https://docs.aws.amazon.com/lambda/latest/dg/configuration-envvars.html#configuration-envvars-runtime
|
|
@@ -30,6 +46,23 @@ const getEcsTaskLogsUrl = ({ ecsTaskArn }) => {
|
|
|
30
46
|
return ecsTaskLogsUrl.href;
|
|
31
47
|
};
|
|
32
48
|
exports.getEcsTaskLogsUrl = getEcsTaskLogsUrl;
|
|
49
|
+
const getEcsTaskTags = async ({ ecsTaskArn, }) => {
|
|
50
|
+
try {
|
|
51
|
+
const cluster = getEcsTaskCluster({ ecsTaskArn });
|
|
52
|
+
const { tasks } = await ecs
|
|
53
|
+
.describeTasks({ cluster, include: ['TAGS'], tasks: [ecsTaskArn] })
|
|
54
|
+
.promise();
|
|
55
|
+
const task = tasks === null || tasks === void 0 ? void 0 : tasks[0];
|
|
56
|
+
if (!task) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return task.tags;
|
|
60
|
+
}
|
|
61
|
+
catch (_a) {
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
exports.getEcsTaskTags = getEcsTaskTags;
|
|
33
66
|
/**
|
|
34
67
|
* This method is invoked when an ECS task is executed and the success or
|
|
35
68
|
* failure commands calls `carlin cicd-ecs-task-report --status=<status>`.
|
|
@@ -47,6 +80,7 @@ const ecsTaskReportHandler = async ({ ecsTaskArn, status, pipelineName, }) => {
|
|
|
47
80
|
});
|
|
48
81
|
}
|
|
49
82
|
};
|
|
83
|
+
const ecsTaskTags = ecsTaskArn && (await exports.getEcsTaskTags({ ecsTaskArn }));
|
|
50
84
|
const handleStackNotification = async () => {
|
|
51
85
|
/**
|
|
52
86
|
* Do not send a notification if the task was main pipeline with tag.
|
|
@@ -79,6 +113,7 @@ const ecsTaskReportHandler = async ({ ecsTaskArn, status, pipelineName, }) => {
|
|
|
79
113
|
text: `\`\`\`${JSON.stringify({
|
|
80
114
|
status,
|
|
81
115
|
pipelineName,
|
|
116
|
+
ecsTaskTags,
|
|
82
117
|
}, null, 2)}\`\`\``,
|
|
83
118
|
},
|
|
84
119
|
},
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTagCommands = exports.getMainCommands = exports.getClosedPrCommands = exports.getPrCommands = exports.pipelines = void 0;
|
|
3
|
+
exports.getTagCommands = exports.getMainCommands = exports.getClosedPrCommands = exports.getPrCommands = exports.getCommandFileDir = exports.pipelines = void 0;
|
|
4
4
|
exports.pipelines = ['pr', 'main', 'tag'];
|
|
5
|
-
const
|
|
5
|
+
const getCommandFileDir = (pipeline) => `./cicd/commands/${pipeline}`;
|
|
6
|
+
exports.getCommandFileDir = getCommandFileDir;
|
|
6
7
|
const getPrCommands = ({ branch }) => [
|
|
7
8
|
'set -e',
|
|
8
9
|
'git status',
|
|
@@ -16,7 +17,7 @@ const getPrCommands = ({ branch }) => [
|
|
|
16
17
|
'git rev-parse HEAD',
|
|
17
18
|
'git status',
|
|
18
19
|
'yarn',
|
|
19
|
-
|
|
20
|
+
`sh -e ${exports.getCommandFileDir('pr')}`,
|
|
20
21
|
];
|
|
21
22
|
exports.getPrCommands = getPrCommands;
|
|
22
23
|
const getClosedPrCommands = ({ branch }) => [
|
|
@@ -28,7 +29,7 @@ const getClosedPrCommands = ({ branch }) => [
|
|
|
28
29
|
'git pull origin main',
|
|
29
30
|
'git rev-parse HEAD',
|
|
30
31
|
`export CARLIN_BRANCH=${branch}`,
|
|
31
|
-
|
|
32
|
+
`sh ${exports.getCommandFileDir('closed-pr')} || true`,
|
|
32
33
|
];
|
|
33
34
|
exports.getClosedPrCommands = getClosedPrCommands;
|
|
34
35
|
const getMainCommands = () => [
|
|
@@ -43,7 +44,7 @@ const getMainCommands = () => [
|
|
|
43
44
|
*/
|
|
44
45
|
'if git describe --exact-match; then echo "Tag found" && carlin cicd-ecs-task-report --status=MainTagFound && exit 0; fi',
|
|
45
46
|
'yarn',
|
|
46
|
-
|
|
47
|
+
`sh -e ${exports.getCommandFileDir('main')}`,
|
|
47
48
|
];
|
|
48
49
|
exports.getMainCommands = getMainCommands;
|
|
49
50
|
const getTagCommands = ({ tag }) => [
|
|
@@ -54,6 +55,6 @@ const getTagCommands = ({ tag }) => [
|
|
|
54
55
|
`git checkout tags/${tag} -b ${tag}-branch`,
|
|
55
56
|
'git rev-parse HEAD',
|
|
56
57
|
'yarn',
|
|
57
|
-
|
|
58
|
+
`sh -e ${exports.getCommandFileDir('tag')}`,
|
|
58
59
|
];
|
|
59
60
|
exports.getTagCommands = getTagCommands;
|
|
@@ -777,6 +777,12 @@ const getCloudFrontTemplate = ({ acm, aliases, cloudfront, gtmId, csp, spa, host
|
|
|
777
777
|
},
|
|
778
778
|
};
|
|
779
779
|
if (acm) {
|
|
780
|
+
const acmRegex = /^arn:aws:acm:[-a-z0-9]+:\d{12}:certificate\/[-a-z0-9]+$/;
|
|
781
|
+
const acmCertificateArn = acmRegex.test(acm)
|
|
782
|
+
? acm
|
|
783
|
+
: {
|
|
784
|
+
'Fn::ImportValue': acm,
|
|
785
|
+
};
|
|
780
786
|
/**
|
|
781
787
|
* Add ACM to CloudFront template.
|
|
782
788
|
*/
|
|
@@ -785,11 +791,11 @@ const getCloudFrontTemplate = ({ acm, aliases, cloudfront, gtmId, csp, spa, host
|
|
|
785
791
|
.DistributionConfig,
|
|
786
792
|
Aliases: aliases || { Ref: 'AWS::NoValue' },
|
|
787
793
|
ViewerCertificate: {
|
|
788
|
-
AcmCertificateArn:
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
794
|
+
AcmCertificateArn: acmCertificateArn,
|
|
795
|
+
/**
|
|
796
|
+
* AWS CloudFront recommendation.
|
|
797
|
+
*/
|
|
798
|
+
MinimumProtocolVersion: 'TLSv1.2_2021',
|
|
793
799
|
SslSupportMethod: 'sni-only',
|
|
794
800
|
},
|
|
795
801
|
};
|