AWS log hose

pull/218/head
Frostebite 2021-02-05 23:14:45 +00:00
parent 45f9a907ae
commit 0c952a745e
6 changed files with 52 additions and 27 deletions

File diff suppressed because one or more lines are too long

View File

@ -17,10 +17,11 @@
"@actions/core": "^1.2.6",
"@actions/exec": "1.0.4",
"@actions/github": "^2.1.1",
"aws-sdk": "^2.812.0",
"base-64": "^0.1.0",
"cloudwatch-logs-hose": "0.0.2",
"kubernetes-client": "^9.0.0",
"semver": "^7.3.2",
"aws-sdk": "^2.812.0",
"websocket": "^1.0.33"
},
"devDependencies": {

View File

@ -5,6 +5,7 @@ import * as SDK from 'aws-sdk';
const WebSocketClient = require('websocket').client;
const fs = require('fs');
const core = require('@actions/core');
const hose = require('cloudwatch-logs-hose');
class AWS {
static async runBuildJob(buildParameters, baseImage) {
@ -126,32 +127,18 @@ class AWS {
core.info(`Build job is running, `);
// watching logs
const taskDescriptions = await ECS.describeTasks({
tasks: [task.tasks[0].taskArn],
cluster: clusterName,
}).promise();
const networkInterfaces = await EC2.describeNetworkInterfaces({
NetworkInterfaceIds: [
taskDescriptions.tasks[0].attachments
.find((x) => x.type === 'ElasticNetworkInterface')
.details.find((x) => x.name === 'networkInterfaceId').value,
],
}).promise();
core.info(JSON.stringify(networkInterfaces.NetworkInterfaces[0].Association.PublicIp));
const client = new WebSocketClient(
`ws://${networkInterfaces.NetworkInterfaces[0].Association.PublicIp}:80`,
);
client.on('connect', (con) => {
con.on('message', (message) => {
core.info(message);
});
const source = new hose.Source({
LogGroup: '/aws/lambda/MINUS-49dda359e9abcd4e180f73bd8ba7e2f9',
aws: { region: 'us-west-2' },
});
// await this.watch(async () => {
// return (
// await ECS.describeTasks({ tasks: [task.tasks[0].taskArn], cluster: clusterName }).promise()
// ).tasks[0].lastStatus;
// }, 'example');
source.on('logs', AWS.onlog);
source.on('error', (error) => {
core.info('Error: ', error);
});
source.open();
await ECS.waitFor('tasksStopped', {
cluster: clusterName,
@ -160,5 +147,9 @@ class AWS {
core.info('Build job has ended');
}
static onlog(batch){
}
}
export default AWS;

View File

@ -1372,6 +1372,20 @@ atob@^2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/atob/-/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9"
aws-sdk@^2.1.14:
version "2.839.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.839.0.tgz#74e9697e5dcb2d116032363ad80f5b705759fafb"
dependencies:
buffer "4.9.2"
events "1.1.1"
ieee754 "1.1.13"
jmespath "0.15.0"
querystring "0.2.0"
sax "1.2.1"
url "0.10.3"
uuid "3.3.2"
xml2js "0.4.19"
aws-sdk@^2.812.0:
version "2.834.0"
resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.834.0.tgz#1d9f8ed7cf2ed885041142d67e29f45cbb8621b7"
@ -1745,6 +1759,13 @@ clone@^1.0.2:
version "1.0.4"
resolved "https://registry.yarnpkg.com/clone/-/clone-1.0.4.tgz#da309cc263df15994c688ca902179ca3c7cd7c7e"
cloudwatch-logs-hose@0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/cloudwatch-logs-hose/-/cloudwatch-logs-hose-0.0.2.tgz#711b3e5e8dd2ade4505796a6b33aaae4b93c0234"
dependencies:
aws-sdk "^2.1.14"
jasmine "^2.2.1"
co@^4.6.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
@ -2690,7 +2711,7 @@ glob-parent@^5.0.0:
dependencies:
is-glob "^4.0.1"
glob@^7.0.0, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4:
glob@^7.0.0, glob@^7.0.6, glob@^7.1.1, glob@^7.1.2, glob@^7.1.3, glob@^7.1.4:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
dependencies:
@ -3166,6 +3187,18 @@ istanbul-reports@^3.0.2:
html-escaper "^2.0.0"
istanbul-lib-report "^3.0.0"
jasmine-core@~2.99.0:
version "2.99.1"
resolved "https://registry.yarnpkg.com/jasmine-core/-/jasmine-core-2.99.1.tgz#e6400df1e6b56e130b61c4bcd093daa7f6e8ca15"
jasmine@^2.2.1:
version "2.99.0"
resolved "https://registry.yarnpkg.com/jasmine/-/jasmine-2.99.0.tgz#8ca72d102e639b867c6489856e0e18a9c7aa42b7"
dependencies:
exit "^0.1.2"
glob "^7.0.6"
jasmine-core "~2.99.0"
jest-changed-files@^25.5.0:
version "25.5.0"
resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-25.5.0.tgz#141cc23567ceb3f534526f8614ba39421383634c"