@onivoro/server-aws-ecs 24.14.0 → 24.15.0
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/package.json +10 -4
- package/jest.config.ts +0 -11
- package/project.json +0 -33
- package/src/index.ts +0 -5
- package/src/lib/classes/server-aws-ecs-config.class.ts +0 -4
- package/src/lib/functions/parse-csv-string.function.ts +0 -3
- package/src/lib/server-aws-ecs.module.ts +0 -33
- package/src/lib/services/__snapshots__/ecs.service.spec.ts.snap +0 -21
- package/src/lib/services/ecs.service.spec.ts +0 -13
- package/src/lib/services/ecs.service.ts +0 -41
- package/tsconfig.json +0 -16
- package/tsconfig.lib.json +0 -10
- package/tsconfig.spec.json +0 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onivoro/server-aws-ecs",
|
|
3
|
-
"version": "24.
|
|
3
|
+
"version": "24.15.0",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"types": "./index.d.ts",
|
|
@@ -9,12 +9,18 @@
|
|
|
9
9
|
"url": "https://github.com/onivoro/monorepo.git"
|
|
10
10
|
},
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@onivoro/server-aws-credential-providers": "24.
|
|
13
|
-
"@onivoro/server-common": "24.
|
|
12
|
+
"@onivoro/server-aws-credential-providers": "24.15.0",
|
|
13
|
+
"@onivoro/server-common": "24.15.0",
|
|
14
14
|
"tslib": "^2.3.0"
|
|
15
15
|
},
|
|
16
16
|
"peerDependencies": {
|
|
17
17
|
"@aws-sdk/client-ecs": "~3.782.0",
|
|
18
18
|
"@nestjs/common": "~10.4.6"
|
|
19
|
-
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"**/*.js",
|
|
22
|
+
"**/*.d.ts",
|
|
23
|
+
"**/*.js.map",
|
|
24
|
+
"README.md"
|
|
25
|
+
]
|
|
20
26
|
}
|
package/jest.config.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
export default {
|
|
3
|
-
displayName: 'lib-server-aws-ecs',
|
|
4
|
-
preset: '../../../jest.preset.js',
|
|
5
|
-
testEnvironment: 'node',
|
|
6
|
-
transform: {
|
|
7
|
-
'^.+\\.[tj]s$': ['ts-jest', { tsconfig: '<rootDir>/tsconfig.spec.json' }],
|
|
8
|
-
},
|
|
9
|
-
moduleFileExtensions: ['ts', 'js', 'html'],
|
|
10
|
-
coverageDirectory: '../../../coverage/libs/server/aws-ecs',
|
|
11
|
-
};
|
package/project.json
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "lib-server-aws-ecs",
|
|
3
|
-
"$schema": "../../../node_modules/nx/schemas/project-schema.json",
|
|
4
|
-
"sourceRoot": "libs/server/aws-ecs/src",
|
|
5
|
-
"projectType": "library",
|
|
6
|
-
"targets": {
|
|
7
|
-
"build": {
|
|
8
|
-
"executor": "@nx/js:tsc",
|
|
9
|
-
"outputs": ["{options.outputPath}"],
|
|
10
|
-
"options": {
|
|
11
|
-
"outputPath": "dist/libs/server/aws-ecs",
|
|
12
|
-
"main": "libs/server/aws-ecs/src/index.ts",
|
|
13
|
-
"tsConfig": "libs/server/aws-ecs/tsconfig.lib.json",
|
|
14
|
-
"assets": [
|
|
15
|
-
"libs/server/aws-ecs/README.md",
|
|
16
|
-
"libs/server/aws-ecs/package.json"
|
|
17
|
-
],
|
|
18
|
-
"declaration": true,
|
|
19
|
-
"updateBuildableProjectPackageJsonDependencies": true,
|
|
20
|
-
"rootDir": "libs/server/aws-ecs/src"
|
|
21
|
-
}
|
|
22
|
-
},
|
|
23
|
-
"publish": {
|
|
24
|
-
"executor": "@nx/js:npm",
|
|
25
|
-
"outputs": [],
|
|
26
|
-
"dependsOn": ["build"],
|
|
27
|
-
"options": {
|
|
28
|
-
"packageRoot": "dist/libs/server/aws-ecs"
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
},
|
|
32
|
-
"tags": []
|
|
33
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { Module } from '@nestjs/common';
|
|
2
|
-
import { moduleFactory } from '@onivoro/server-common';
|
|
3
|
-
import { ECS } from '@aws-sdk/client-ecs';
|
|
4
|
-
import { EcsService } from './services/ecs.service';
|
|
5
|
-
import { ServerAwsEcsConfig } from './classes/server-aws-ecs-config.class';
|
|
6
|
-
import { AwsCredentials, ServerAwsCredentialProvidersModule } from '@onivoro/server-aws-credential-providers';
|
|
7
|
-
|
|
8
|
-
let ecsClient: ECS | null = null;
|
|
9
|
-
|
|
10
|
-
@Module({})
|
|
11
|
-
export class ServerAwsEcsModule {
|
|
12
|
-
static configure(config: ServerAwsEcsConfig) {
|
|
13
|
-
return moduleFactory({
|
|
14
|
-
module: ServerAwsEcsModule,
|
|
15
|
-
imports: [ServerAwsCredentialProvidersModule.configure(config)],
|
|
16
|
-
providers: [
|
|
17
|
-
{
|
|
18
|
-
provide: ECS,
|
|
19
|
-
useFactory: (credentials: AwsCredentials) => ecsClient
|
|
20
|
-
? ecsClient
|
|
21
|
-
: ecsClient = new ECS({
|
|
22
|
-
region: config.AWS_REGION,
|
|
23
|
-
logger: console,
|
|
24
|
-
credentials
|
|
25
|
-
}),
|
|
26
|
-
inject: [AwsCredentials]
|
|
27
|
-
},
|
|
28
|
-
{ provide: ServerAwsEcsConfig, useValue: config },
|
|
29
|
-
EcsService
|
|
30
|
-
],
|
|
31
|
-
})
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Bun Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
-
|
|
3
|
-
exports[`EcsService mapObjectToEcsEnvironmentArray given "{"hot":"sauce"}", lives up to its name 1`] = `
|
|
4
|
-
[
|
|
5
|
-
{
|
|
6
|
-
"Name": "hot",
|
|
7
|
-
"Value": "sauce",
|
|
8
|
-
},
|
|
9
|
-
]
|
|
10
|
-
`;
|
|
11
|
-
|
|
12
|
-
exports[`EcsService mapObjectToEcsEnvironmentArray given "null", lives up to its name 1`] = `[]`;
|
|
13
|
-
|
|
14
|
-
exports[`EcsService mapObjectToEcsEnvironmentArray given "{"age":337}", lives up to its name 1`] = `
|
|
15
|
-
[
|
|
16
|
-
{
|
|
17
|
-
"Name": "age",
|
|
18
|
-
"Value": 337,
|
|
19
|
-
},
|
|
20
|
-
]
|
|
21
|
-
`;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { EcsService } from './ecs.service';
|
|
2
|
-
|
|
3
|
-
describe(EcsService.name, () => {
|
|
4
|
-
describe(EcsService.mapObjectToEcsEnvironmentArray.name, () => {
|
|
5
|
-
it.each([
|
|
6
|
-
[{ hot: "sauce" }],
|
|
7
|
-
[null],
|
|
8
|
-
[{ age: 337 }],
|
|
9
|
-
])('given "%j", lives up to its name', (_) => {
|
|
10
|
-
expect(EcsService.mapObjectToEcsEnvironmentArray(_)).toMatchSnapshot();
|
|
11
|
-
});
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { Injectable } from "@nestjs/common";
|
|
2
|
-
import { ECS, KeyValuePair, RunTaskCommand, RunTaskCommandInput, RunTaskCommandOutput } from '@aws-sdk/client-ecs';
|
|
3
|
-
import { parseCsvString } from "../functions/parse-csv-string.function";
|
|
4
|
-
|
|
5
|
-
@Injectable()
|
|
6
|
-
export class EcsService {
|
|
7
|
-
|
|
8
|
-
constructor(private ecsClient: ECS) { }
|
|
9
|
-
|
|
10
|
-
runTasks(_: { taskDefinition: string, subnets: string, securityGroups: string, taskCount: number, cluster: string } & Pick<RunTaskCommandInput, 'overrides'>): Promise<Array<RunTaskCommandOutput>> {
|
|
11
|
-
const { taskDefinition, subnets, securityGroups, taskCount, cluster, overrides } = _;
|
|
12
|
-
try {
|
|
13
|
-
const params: RunTaskCommandInput = {
|
|
14
|
-
cluster,
|
|
15
|
-
taskDefinition,
|
|
16
|
-
launchType: 'FARGATE',
|
|
17
|
-
networkConfiguration: {
|
|
18
|
-
awsvpcConfiguration: {
|
|
19
|
-
assignPublicIp: 'DISABLED',
|
|
20
|
-
subnets: parseCsvString(subnets),
|
|
21
|
-
securityGroups: parseCsvString(securityGroups),
|
|
22
|
-
}
|
|
23
|
-
},
|
|
24
|
-
overrides
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
const taskPromises = new Array(taskCount)
|
|
28
|
-
.fill(undefined)
|
|
29
|
-
.map(() => this.ecsClient.send(new RunTaskCommand(params)));
|
|
30
|
-
|
|
31
|
-
return Promise.all(taskPromises);
|
|
32
|
-
} catch (error) {
|
|
33
|
-
console.error('Failed to run ECS task:', error);
|
|
34
|
-
throw error;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
static mapObjectToEcsEnvironmentArray (_: Record<string, any> | null | undefined): KeyValuePair[] {
|
|
39
|
-
return Object.entries(_ || {} as Record<string, any>).reduce((__, [Name, Value]) => [...__, {Name, Value}], [] as any);
|
|
40
|
-
}
|
|
41
|
-
}
|
package/tsconfig.json
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../../../tsconfig.server.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"outDir": "../../../dist/out-tsc"
|
|
5
|
-
},
|
|
6
|
-
"files": [],
|
|
7
|
-
"include": [],
|
|
8
|
-
"references": [
|
|
9
|
-
{
|
|
10
|
-
"path": "./tsconfig.lib.json"
|
|
11
|
-
},
|
|
12
|
-
{
|
|
13
|
-
"path": "./tsconfig.spec.json"
|
|
14
|
-
}
|
|
15
|
-
]
|
|
16
|
-
}
|
package/tsconfig.lib.json
DELETED
package/tsconfig.spec.json
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "./tsconfig.json",
|
|
3
|
-
"compilerOptions": {
|
|
4
|
-
"types": [
|
|
5
|
-
"jest",
|
|
6
|
-
"node"
|
|
7
|
-
]
|
|
8
|
-
},
|
|
9
|
-
"include": [
|
|
10
|
-
"jest.config.ts",
|
|
11
|
-
"**/*.test.ts",
|
|
12
|
-
"**/*.spec.ts",
|
|
13
|
-
"**/*.test.tsx",
|
|
14
|
-
"**/*.spec.tsx",
|
|
15
|
-
"**/*.test.js",
|
|
16
|
-
"**/*.spec.js",
|
|
17
|
-
"**/*.test.jsx",
|
|
18
|
-
"**/*.spec.jsx",
|
|
19
|
-
"**/*.d.ts"
|
|
20
|
-
]
|
|
21
|
-
}
|