unique task def per job
parent
eb1d5c995d
commit
b64816eed9
File diff suppressed because one or more lines are too long
|
|
@ -17,6 +17,9 @@ Parameters:
|
|||
Default: nginx
|
||||
Description: The url of a docker image that contains the application process that
|
||||
will handle the traffic for this service
|
||||
Entrypoint:
|
||||
Type: CommaDelimitedList
|
||||
|
||||
ContainerPort:
|
||||
Type: Number
|
||||
Default: 80
|
||||
|
|
@ -70,9 +73,14 @@ Mappings:
|
|||
# A log group for storing the stdout logs from this service's containers
|
||||
Conditions:
|
||||
HasCustomRole: !Not [ !Equals [!Ref 'Role', ''] ]
|
||||
|
||||
|
||||
Resources:
|
||||
|
||||
KinesisStream:
|
||||
Type: AWS::Kinesis::Stream
|
||||
Properties:
|
||||
Name: !Ref 'ServiceName'
|
||||
ShardCount: 1
|
||||
# The task definition. This is a simple metadata description of what
|
||||
# container to run, and what resource requirements it has.
|
||||
TaskDefinition:
|
||||
|
|
@ -85,12 +93,12 @@ Resources:
|
|||
Volumes:
|
||||
- Name: efs-data
|
||||
EFSVolumeConfiguration:
|
||||
FilesystemId:
|
||||
FilesystemId:
|
||||
Fn::ImportValue: !Sub ${EnvironmentName}:EfsFileStorageId
|
||||
TransitEncryption: ENABLED
|
||||
RequiresCompatibilities:
|
||||
- FARGATE
|
||||
ExecutionRoleArn:
|
||||
ExecutionRoleArn:
|
||||
Fn::ImportValue: !Sub ${EnvironmentName}:ECSTaskExecutionRole
|
||||
TaskRoleArn:
|
||||
Fn::If:
|
||||
|
|
@ -98,25 +106,28 @@ Resources:
|
|||
- !Ref 'Role'
|
||||
- !Ref "AWS::NoValue"
|
||||
ContainerDefinitions:
|
||||
- Name: !Ref 'ServiceName'
|
||||
Cpu: !Ref 'ContainerCpu'
|
||||
- Name: 'LoggingSidecar'
|
||||
Cpu: '!Ref LoggingCpu'
|
||||
Memory: !Ref 'ContainerMemory'
|
||||
Image: !Ref 'ImageUrl'
|
||||
PortMappings:
|
||||
- ContainerPort: !Ref ContainerPort
|
||||
HostPort: !Ref ContainerPort
|
||||
Environment:
|
||||
- Name: !Ref 'ServiceName'
|
||||
Cpu: !Ref 'ContainerCpu'
|
||||
Memory: !Ref 'ContainerMemory'
|
||||
Image: !Ref 'ImageUrl'
|
||||
Entrypoint: !Ref 'Entrypoint'
|
||||
Environment:
|
||||
- Name: ALLOW_EMPTY_PASSWORD
|
||||
Value: 'yes'
|
||||
MountPoints:
|
||||
- SourceVolume: efs-data
|
||||
ContainerPath: !Ref EFSMountPath
|
||||
ReadOnly: false
|
||||
|
||||
|
||||
LogConfiguration:
|
||||
LogDriver: 'awslogs'
|
||||
Options:
|
||||
awslogs-group: !Ref 'ServiceName'
|
||||
awslogs-region: !Ref 'AWS::Region'
|
||||
awslogs-stream-prefix: !Ref 'ServiceName'
|
||||
awslogs-stream-prefix: !Ref 'ServiceName'
|
||||
|
|
|
|||
|
|
@ -21,7 +21,9 @@
|
|||
"base-64": "^0.1.0",
|
||||
"cloudwatch-logs-hose": "0.0.2",
|
||||
"kubernetes-client": "^9.0.0",
|
||||
"semver": "^7.3.2"
|
||||
"selfsigned": "1.10.8",
|
||||
"semver": "^7.3.2",
|
||||
"shortid": "2.2.16"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/cli": "7.8.4",
|
||||
|
|
|
|||
|
|
@ -1,10 +1,11 @@
|
|||
/* eslint-disable no-plusplus */
|
||||
/* eslint-disable no-await-in-loop */
|
||||
import * as SDK from 'aws-sdk';
|
||||
import { CloudWatch, CloudWatchLogs } from 'aws-sdk';
|
||||
|
||||
const fs = require('fs');
|
||||
const core = require('@actions/core');
|
||||
const hose = require('cloudwatch-logs-hose');
|
||||
const Shortid = require('shortid');
|
||||
|
||||
class AWS {
|
||||
static async runBuildJob(buildParameters, baseImage) {
|
||||
|
|
@ -23,12 +24,7 @@ class AWS {
|
|||
buildParameters.awsStackName,
|
||||
baseImage.toString(),
|
||||
['bin/bash', '-c', 'echo "test"'],
|
||||
[
|
||||
{
|
||||
name: '',
|
||||
value: '',
|
||||
},
|
||||
],
|
||||
[],
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -37,7 +33,7 @@ class AWS {
|
|||
const CF = new SDK.CloudFormation();
|
||||
|
||||
const alphanumericImageName = image.toString().replace(/[^\da-z]/gi, '');
|
||||
const taskDefStackName = `${stackName}-taskDef-${alphanumericImageName}`;
|
||||
const taskDefStackName = `${stackName}-taskDef-${alphanumericImageName}-${new Shortid()}`;
|
||||
const stackExists =
|
||||
(await CF.listStacks().promise()).StackSummaries.find(
|
||||
(x) => x.StackName === taskDefStackName,
|
||||
|
|
@ -54,6 +50,10 @@ class AWS {
|
|||
ParameterKey: 'ImageUrl',
|
||||
ParameterValue: image,
|
||||
},
|
||||
{
|
||||
ParameterKey: 'Entrypoint',
|
||||
ParameterValue: commands,
|
||||
},
|
||||
],
|
||||
}).promise();
|
||||
await CF.waitFor('stackCreateComplete', { StackName: taskDefStackName }).promise();
|
||||
|
|
@ -81,7 +81,6 @@ class AWS {
|
|||
containerOverrides: [
|
||||
{
|
||||
name: 'example',
|
||||
command: commands,
|
||||
environment,
|
||||
},
|
||||
],
|
||||
|
|
@ -113,23 +112,6 @@ class AWS {
|
|||
|
||||
// watching logs
|
||||
|
||||
try {
|
||||
const source = new hose.Source({
|
||||
LogGroup: baseResources.StackResources.find((x) => x.LogicalResourceId === 'LogGroup'),
|
||||
aws: SDK.config,
|
||||
});
|
||||
|
||||
source.on('logs', AWS.onlog);
|
||||
|
||||
source.on('error', (error) => {
|
||||
core.info('Error: ', error);
|
||||
});
|
||||
|
||||
source.open();
|
||||
} catch (error) {
|
||||
core.info(error);
|
||||
}
|
||||
|
||||
await ECS.waitFor('tasksStopped', {
|
||||
cluster: clusterName,
|
||||
tasks: [task.tasks[0].taskArn],
|
||||
|
|
|
|||
20
yarn.lock
20
yarn.lock
|
|
@ -3939,6 +3939,10 @@ nan@^2.12.1:
|
|||
version "2.14.1"
|
||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01"
|
||||
|
||||
nanoid@^2.1.0:
|
||||
version "2.1.11"
|
||||
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-2.1.11.tgz#ec24b8a758d591561531b4176a01e3ab4f0f0280"
|
||||
|
||||
nanomatch@^1.2.9:
|
||||
version "1.2.13"
|
||||
resolved "https://registry.yarnpkg.com/nanomatch/-/nanomatch-1.2.13.tgz#b87a8aa4fc0de8fe6be88895b38983ff265bd119"
|
||||
|
|
@ -3967,6 +3971,10 @@ node-fetch@^2.3.0:
|
|||
version "2.6.1"
|
||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.1.tgz#045bd323631f76ed2e2b55573394416b639a0052"
|
||||
|
||||
node-forge@^0.10.0:
|
||||
version "0.10.0"
|
||||
resolved "https://registry.yarnpkg.com/node-forge/-/node-forge-0.10.0.tgz#32dea2afb3e9926f02ee5ce8794902691a676bf3"
|
||||
|
||||
node-int64@^0.4.0:
|
||||
version "0.4.0"
|
||||
resolved "https://registry.yarnpkg.com/node-int64/-/node-int64-0.4.0.tgz#87a9065cdb355d3182d8f94ce11188b825c68a3b"
|
||||
|
|
@ -4764,6 +4772,12 @@ saxes@^3.1.9:
|
|||
dependencies:
|
||||
xmlchars "^2.1.1"
|
||||
|
||||
selfsigned@1.10.8:
|
||||
version "1.10.8"
|
||||
resolved "https://registry.yarnpkg.com/selfsigned/-/selfsigned-1.10.8.tgz#0d17208b7d12c33f8eac85c41835f27fc3d81a30"
|
||||
dependencies:
|
||||
node-forge "^0.10.0"
|
||||
|
||||
semver-compare@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/semver-compare/-/semver-compare-1.0.0.tgz#0dee216a1c941ab37e9efb1788f6afc5ff5537fc"
|
||||
|
|
@ -4833,6 +4847,12 @@ shellwords@^0.1.1:
|
|||
version "0.1.1"
|
||||
resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"
|
||||
|
||||
shortid@2.2.16:
|
||||
version "2.2.16"
|
||||
resolved "https://registry.yarnpkg.com/shortid/-/shortid-2.2.16.tgz#b742b8f0cb96406fd391c76bfc18a67a57fe5608"
|
||||
dependencies:
|
||||
nanoid "^2.1.0"
|
||||
|
||||
side-channel@^1.0.2:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/side-channel/-/side-channel-1.0.2.tgz#df5d1abadb4e4bf4af1cd8852bf132d2f7876947"
|
||||
|
|
|
|||
Loading…
Reference in New Issue