@mbc-cqrs-serverless/cli 1.0.24 → 1.0.26
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/actions/new.action.js +1 -1
- package/dist/actions/ui.action.js +3 -3
- package/dist/commands/ui.command.js +1 -1
- package/dist/runners/abstract.runner.js +1 -1
- package/dist/schematics/schematic.colection.js +2 -2
- package/dist/utils/formatting.js +1 -1
- package/package.json +2 -2
- package/templates/.env.local +41 -8
- package/templates/infra-local/appsync-simulator/package-lock.json +3 -7
- package/templates/infra-local/docker-compose.yml +14 -14
- package/templates/infra-local/scripts/trigger_ddb_stream.ps1 +24 -11
- package/templates/infra-local/scripts/trigger_ddb_stream.sh +21 -7
- package/templates/infra-local/serverless.yml +25 -13
|
@@ -29,7 +29,7 @@ async function newAction(name = '', options, command) {
|
|
|
29
29
|
packageVersion = `^${matchVersions.at(-1)}`; // use the patch and minor versions
|
|
30
30
|
}
|
|
31
31
|
else {
|
|
32
|
-
ui_1.logger.error(`The specified package version does not exist. Please
|
|
32
|
+
ui_1.logger.error(`The specified package version does not exist. Please choose a valid version! ${versions}`);
|
|
33
33
|
return;
|
|
34
34
|
}
|
|
35
35
|
}
|
|
@@ -16,19 +16,19 @@ async function uiAction(options, command) {
|
|
|
16
16
|
ui_1.logger.info(`Executing command '${command.name()}' for application with options '${JSON.stringify(options)}'`);
|
|
17
17
|
const { branch, auth, component, pathDir, token = '' } = options;
|
|
18
18
|
if (componentOptions.findIndex((optionName) => optionName === component) === -1) {
|
|
19
|
-
ui_1.logger.error(`Please choose correct component options: ${componentOptions.join(', ')}`);
|
|
19
|
+
ui_1.logger.error(`Please choose the correct component options: ${componentOptions.join(', ')}`);
|
|
20
20
|
}
|
|
21
21
|
// Check command run in base src
|
|
22
22
|
if (!(0, fs_1.existsSync)(path_1.default.join(process.cwd(), 'tsconfig.json'))) {
|
|
23
23
|
ui_1.logger.error('Please run command in base folder');
|
|
24
24
|
return;
|
|
25
25
|
}
|
|
26
|
-
// Check tsconfig.json
|
|
26
|
+
// Check tsconfig.json contains path @ms
|
|
27
27
|
const tsconfig = JSON.parse((0, fs_1.readFileSync)(path_1.default.join(process.cwd(), 'tsconfig.json'), 'utf8'));
|
|
28
28
|
if (tsconfig?.compilerOptions &&
|
|
29
29
|
tsconfig?.compilerOptions?.paths &&
|
|
30
30
|
tsconfig?.compilerOptions?.paths.hasOwnProperty('@ms/*')) {
|
|
31
|
-
ui_1.logger.error('The project already
|
|
31
|
+
ui_1.logger.error('The project already contains mbc-cqrs-ui-common');
|
|
32
32
|
return;
|
|
33
33
|
}
|
|
34
34
|
// Copy source
|
|
@@ -9,7 +9,7 @@ function uiCommand(program) {
|
|
|
9
9
|
program
|
|
10
10
|
.command('ui-common')
|
|
11
11
|
.alias('ui')
|
|
12
|
-
.description('
|
|
12
|
+
.description('Add mbc-cqrs-ui-common components to your project.')
|
|
13
13
|
.requiredOption('-p, --pathDir <string>', 'The place of common-ui')
|
|
14
14
|
.option('-b, --branch <string>', 'The branch name', 'main')
|
|
15
15
|
.option('--auth <string>', 'The auth method (HTTPS - Token, SSH)', 'SSH')
|
|
@@ -34,7 +34,7 @@ class AbstractRunner {
|
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
36
|
* @param command
|
|
37
|
-
* @returns The entire command that will be
|
|
37
|
+
* @returns The entire command that will be run when calling `run(command)`.
|
|
38
38
|
*/
|
|
39
39
|
rawFullCommand(command) {
|
|
40
40
|
const commandArgs = [...this.args, command];
|
|
@@ -26,12 +26,12 @@ exports.schematics = [
|
|
|
26
26
|
{
|
|
27
27
|
name: 'entity',
|
|
28
28
|
alias: 'en',
|
|
29
|
-
description: 'Create
|
|
29
|
+
description: 'Create an entity.',
|
|
30
30
|
},
|
|
31
31
|
{
|
|
32
32
|
name: 'dto',
|
|
33
33
|
alias: 'dto',
|
|
34
|
-
description: 'Create a
|
|
34
|
+
description: 'Create a DTO.',
|
|
35
35
|
},
|
|
36
36
|
];
|
|
37
37
|
function buildSchematicsListAsTable() {
|
package/dist/utils/formatting.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.normalizeToKebabOrSnakeCase = normalizeToKebabOrSnakeCase;
|
|
|
4
4
|
/**
|
|
5
5
|
*
|
|
6
6
|
* @param str
|
|
7
|
-
* @returns
|
|
7
|
+
* @returns formatted string
|
|
8
8
|
* @description normalizes input to supported path and file name format.
|
|
9
9
|
* Changes camelCase strings to kebab-case, replaces spaces with dash and keeps underscores.
|
|
10
10
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mbc-cqrs-serverless/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.26",
|
|
4
4
|
"description": "a CLI to get started with MBC CQRS serverless framework",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mbc",
|
|
@@ -58,5 +58,5 @@
|
|
|
58
58
|
"@faker-js/faker": "^8.3.1",
|
|
59
59
|
"copyfiles": "^2.4.1"
|
|
60
60
|
},
|
|
61
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "0956dc696475fb769dd134aa619679ba5155e646"
|
|
62
62
|
}
|
package/templates/.env.local
CHANGED
|
@@ -12,36 +12,69 @@ COMPOSE_PROJECT_NAME=%%projectName%%
|
|
|
12
12
|
LOG_LEVEL=verbose # debug, verbose, info, warn, error, fatal
|
|
13
13
|
# disable event route for API GW integration
|
|
14
14
|
EVENT_SOURCE_DISABLED=false
|
|
15
|
+
|
|
16
|
+
# ============================================
|
|
17
|
+
# Local Service Ports
|
|
18
|
+
# Change these if you have port conflicts with other services
|
|
19
|
+
# ============================================
|
|
20
|
+
# Serverless Offline (API Gateway)
|
|
21
|
+
LOCAL_HTTP_PORT=3000
|
|
22
|
+
LOCAL_LAMBDA_PORT=3002
|
|
23
|
+
# DynamoDB Local
|
|
24
|
+
LOCAL_DYNAMODB_PORT=8000
|
|
25
|
+
# MySQL (RDS)
|
|
26
|
+
LOCAL_RDS_PORT=3306
|
|
27
|
+
# LocalStack (S3)
|
|
28
|
+
LOCAL_S3_PORT=4566
|
|
29
|
+
# SNS
|
|
30
|
+
LOCAL_SNS_PORT=4002
|
|
31
|
+
# SQS (ElasticMQ)
|
|
32
|
+
LOCAL_SQS_PORT=9324
|
|
33
|
+
LOCAL_SQS_UI_PORT=9325
|
|
34
|
+
# Step Functions Local
|
|
35
|
+
LOCAL_SFN_PORT=8083
|
|
36
|
+
# Cognito Local
|
|
37
|
+
LOCAL_COGNITO_PORT=9229
|
|
38
|
+
# AppSync Simulator
|
|
39
|
+
LOCAL_APPSYNC_PORT=4001
|
|
40
|
+
# EventBridge
|
|
41
|
+
LOCAL_EVENTBRIDGE_PORT=4010
|
|
42
|
+
LOCAL_EVENTBRIDGE_PUBSUB_PORT=4011
|
|
43
|
+
# SES
|
|
44
|
+
LOCAL_SES_PORT=8005
|
|
45
|
+
# DynamoDB Admin UI
|
|
46
|
+
LOCAL_DDB_ADMIN_PORT=8001
|
|
47
|
+
|
|
15
48
|
# DynamoDB endpoint, useful for local development
|
|
16
|
-
DYNAMODB_ENDPOINT=http://localhost
|
|
49
|
+
DYNAMODB_ENDPOINT=http://localhost:${LOCAL_DYNAMODB_PORT:-8000}
|
|
17
50
|
DYNAMODB_REGION=ap-northeast-1
|
|
18
51
|
# set the limit size for `attributes` of object in DDB
|
|
19
52
|
ATTRIBUTE_LIMIT_SIZE=389120 # bytes, refer to https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/ServiceQuotas.html#limits-attributes
|
|
20
53
|
# S3 endpoint, useful for local development
|
|
21
|
-
S3_ENDPOINT=http://localhost
|
|
54
|
+
S3_ENDPOINT=http://localhost:${LOCAL_S3_PORT:-4566}
|
|
22
55
|
S3_REGION=ap-northeast-1
|
|
23
56
|
# save DDB attributes
|
|
24
57
|
S3_BUCKET_NAME=local-bucket
|
|
25
58
|
# Step Function endpoint, useful for local development
|
|
26
|
-
SFN_ENDPOINT=http://localhost
|
|
59
|
+
SFN_ENDPOINT=http://localhost:${LOCAL_SFN_PORT:-8083}
|
|
27
60
|
SFN_REGION=ap-northeast-1
|
|
28
61
|
SFN_COMMAND_ARN=arn:aws:states:ap-northeast-1:101010101010:stateMachine:command
|
|
29
62
|
SFN_TASK_ARN=arn:aws:states:ap-northeast-1:101010101010:stateMachine:sfn-task
|
|
30
63
|
# SNS endpoint, useful for local development
|
|
31
|
-
SNS_ENDPOINT=http://localhost
|
|
64
|
+
SNS_ENDPOINT=http://localhost:${LOCAL_SNS_PORT:-4002}
|
|
32
65
|
SNS_REGION=ap-northeast-1
|
|
33
66
|
SNS_TOPIC_ARN=arn:aws:sns:ap-northeast-1:101010101010:CqrsSnsTopic
|
|
34
67
|
SNS_ALARM_TOPIC_ARN=arn:aws:sns:ap-northeast-1:101010101010:AlarmSnsTopic
|
|
35
68
|
# Cognito endpoint, useful for local development
|
|
36
|
-
COGNITO_URL=http://localhost
|
|
69
|
+
COGNITO_URL=http://localhost:${LOCAL_COGNITO_PORT:-9229}
|
|
37
70
|
COGNITO_USER_POOL_ID=local_2G7noHgW
|
|
38
71
|
COGNITO_USER_POLL_CLIENT_ID=dnk8y7ii3wled35p3lw0l2cd7
|
|
39
72
|
COGNITO_REGION=ap-northeast-1
|
|
40
73
|
# AppSync endpoint, useful for local development
|
|
41
|
-
APPSYNC_ENDPOINT=http://localhost
|
|
74
|
+
APPSYNC_ENDPOINT=http://localhost:${LOCAL_APPSYNC_PORT:-4001}/graphql
|
|
42
75
|
APPSYNC_API_KEY=da2-fakeApiId123456
|
|
43
76
|
# SES email endpoint, useful for local development
|
|
44
|
-
SES_ENDPOINT=http://localhost
|
|
77
|
+
SES_ENDPOINT=http://localhost:${LOCAL_SES_PORT:-8005}
|
|
45
78
|
SES_REGION=ap-northeast-1
|
|
46
79
|
SES_FROM_EMAIL=email@example.com
|
|
47
80
|
|
|
@@ -52,7 +85,7 @@ SES_FROM_EMAIL=email@example.com
|
|
|
52
85
|
# Prisma supports the native connection string format for PostgreSQL, MySQL, SQLite, SQL Server, MongoDB and CockroachDB.
|
|
53
86
|
# See the documentation for all the connection string options: https://pris.ly/d/connection-strings
|
|
54
87
|
|
|
55
|
-
DATABASE_URL="mysql://root:RootCqrs@localhost
|
|
88
|
+
DATABASE_URL="mysql://root:RootCqrs@localhost:${LOCAL_RDS_PORT:-3306}/cqrs?schema=public&connection_limit=1"
|
|
56
89
|
|
|
57
90
|
# serverless dynamodb local stream
|
|
58
91
|
LOCAL_DDB_SAMPLE_STREAM=arn:aws:dynamodb:ddblocal:000000000000:table/local-test-cli-sample-command/stream/2025-01-14T12:05:57.881
|
|
@@ -406,7 +406,6 @@
|
|
|
406
406
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.19.67.tgz",
|
|
407
407
|
"integrity": "sha512-wI8uHusga+0ZugNp0Ol/3BqQfEcCCNfojtO6Oou9iVNGPTL6QNSdnUdqq85fRgIorLhLMuPIKpsN98QE9Nh+KQ==",
|
|
408
408
|
"license": "MIT",
|
|
409
|
-
"peer": true,
|
|
410
409
|
"dependencies": {
|
|
411
410
|
"undici-types": "~5.26.4"
|
|
412
411
|
}
|
|
@@ -651,7 +650,6 @@
|
|
|
651
650
|
"mime-types"
|
|
652
651
|
],
|
|
653
652
|
"license": "Apache-2.0",
|
|
654
|
-
"peer": true,
|
|
655
653
|
"dependencies": {
|
|
656
654
|
"@aws-cdk/asset-awscli-v1": "^2.2.208",
|
|
657
655
|
"@aws-cdk/asset-kubectl-v20": "^2.1.3",
|
|
@@ -1544,9 +1542,9 @@
|
|
|
1544
1542
|
}
|
|
1545
1543
|
},
|
|
1546
1544
|
"node_modules/diff": {
|
|
1547
|
-
"version": "4.0.
|
|
1548
|
-
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.
|
|
1549
|
-
"integrity": "sha512-
|
|
1545
|
+
"version": "4.0.4",
|
|
1546
|
+
"resolved": "https://registry.npmjs.org/diff/-/diff-4.0.4.tgz",
|
|
1547
|
+
"integrity": "sha512-X07nttJQkwkfKfvTPG/KSnE2OMdcUCao6+eXF3wmnIQRn2aPAHH3VxDbDOdegkd6JbPsXqShpvEOHfAT+nCNwQ==",
|
|
1550
1548
|
"license": "BSD-3-Clause",
|
|
1551
1549
|
"engines": {
|
|
1552
1550
|
"node": ">=0.3.1"
|
|
@@ -2208,7 +2206,6 @@
|
|
|
2208
2206
|
"resolved": "https://registry.npmjs.org/graphql/-/graphql-14.7.0.tgz",
|
|
2209
2207
|
"integrity": "sha512-l0xWZpoPKpppFzMfvVyFmp9vLN7w/ZZJPefUicMCepfJeQ8sMcztloGYY9DfjVPo6tIUDzU5Hw3MUbIjj9AVVA==",
|
|
2210
2208
|
"license": "MIT",
|
|
2211
|
-
"peer": true,
|
|
2212
2209
|
"dependencies": {
|
|
2213
2210
|
"iterall": "^1.2.2"
|
|
2214
2211
|
},
|
|
@@ -4293,7 +4290,6 @@
|
|
|
4293
4290
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
|
|
4294
4291
|
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
|
|
4295
4292
|
"license": "Apache-2.0",
|
|
4296
|
-
"peer": true,
|
|
4297
4293
|
"bin": {
|
|
4298
4294
|
"tsc": "bin/tsc",
|
|
4299
4295
|
"tsserver": "bin/tsserver"
|
|
@@ -3,15 +3,15 @@ services:
|
|
|
3
3
|
stepfunctions-local:
|
|
4
4
|
image: amazon/aws-stepfunctions-local
|
|
5
5
|
ports:
|
|
6
|
-
- 8083:8083
|
|
6
|
+
- ${LOCAL_SFN_PORT:-8083}:8083
|
|
7
7
|
environment:
|
|
8
8
|
- AWS_ACCOUNT_ID=101010101010
|
|
9
9
|
- AWS_DEFAULT_REGION=ap-northeast-1
|
|
10
|
-
- LAMBDA_ENDPOINT=http://host.docker.internal
|
|
11
|
-
- SQS_ENDPOINT=http://host.docker.internal
|
|
12
|
-
- SNS_ENDPOINT=http://host.docker.internal
|
|
13
|
-
- DYNAMODB_ENDPOINT=http://host.docker.internal
|
|
14
|
-
- STEP_FUNCTIONS_ENDPOINT=http://host.docker.internal
|
|
10
|
+
- LAMBDA_ENDPOINT=http://host.docker.internal:${LOCAL_LAMBDA_PORT:-3002}
|
|
11
|
+
- SQS_ENDPOINT=http://host.docker.internal:${LOCAL_SQS_PORT:-9324}
|
|
12
|
+
- SNS_ENDPOINT=http://host.docker.internal:${LOCAL_SNS_PORT:-4002}
|
|
13
|
+
- DYNAMODB_ENDPOINT=http://host.docker.internal:${LOCAL_DYNAMODB_PORT:-8000}
|
|
14
|
+
- STEP_FUNCTIONS_ENDPOINT=http://host.docker.internal:${LOCAL_SFN_PORT:-8083}
|
|
15
15
|
- ECS_ENDPOINT=VALUE
|
|
16
16
|
extra_hosts:
|
|
17
17
|
- 'host.docker.internal:host-gateway'
|
|
@@ -24,12 +24,12 @@ services:
|
|
|
24
24
|
volumes:
|
|
25
25
|
- ./docker-data/mysql:/var/lib/mysql
|
|
26
26
|
ports:
|
|
27
|
-
- 3306:3306
|
|
27
|
+
- ${LOCAL_RDS_PORT:-3306}:3306
|
|
28
28
|
|
|
29
29
|
dynamodb-local:
|
|
30
30
|
image: amazon/dynamodb-local
|
|
31
31
|
ports:
|
|
32
|
-
- 8000:8000
|
|
32
|
+
- ${LOCAL_DYNAMODB_PORT:-8000}:8000
|
|
33
33
|
volumes:
|
|
34
34
|
- ./docker-data/dynamodb-local:/home/dynamodblocal/data
|
|
35
35
|
working_dir: /home/dynamodblocal
|
|
@@ -43,15 +43,15 @@ services:
|
|
|
43
43
|
- AWS_ACCESS_KEY_ID=local
|
|
44
44
|
- AWS_SECRET_ACCESS_KEY=local
|
|
45
45
|
ports:
|
|
46
|
-
- 8001:8001
|
|
46
|
+
- ${LOCAL_DDB_ADMIN_PORT:-8001}:8001
|
|
47
47
|
depends_on:
|
|
48
48
|
- dynamodb-local
|
|
49
49
|
|
|
50
50
|
queue:
|
|
51
51
|
image: softwaremill/elasticmq-native:latest
|
|
52
52
|
ports:
|
|
53
|
-
- 9324:9324 # sqs
|
|
54
|
-
- 9325:9325 # ui
|
|
53
|
+
- ${LOCAL_SQS_PORT:-9324}:9324 # sqs
|
|
54
|
+
- ${LOCAL_SQS_UI_PORT:-9325}:9325 # ui
|
|
55
55
|
volumes:
|
|
56
56
|
- ./elasticmq.conf:/opt/elasticmq.conf
|
|
57
57
|
- ./docker-data/elasticmq:/data
|
|
@@ -59,7 +59,7 @@ services:
|
|
|
59
59
|
localstack:
|
|
60
60
|
image: localstack/localstack
|
|
61
61
|
ports:
|
|
62
|
-
- '4566:4566'
|
|
62
|
+
- '${LOCAL_S3_PORT:-4566}:4566'
|
|
63
63
|
- '4510-4559:4510-4559'
|
|
64
64
|
environment:
|
|
65
65
|
- SERVICES=s3
|
|
@@ -76,7 +76,7 @@ services:
|
|
|
76
76
|
context: ./appsync-simulator
|
|
77
77
|
dockerfile: Dockerfile
|
|
78
78
|
ports:
|
|
79
|
-
- 4001:4001
|
|
79
|
+
- ${LOCAL_APPSYNC_PORT:-4001}:4001
|
|
80
80
|
environment:
|
|
81
81
|
- PORT=4001
|
|
82
82
|
- API_KEY=da2-fakeApiId123456
|
|
@@ -86,6 +86,6 @@ services:
|
|
|
86
86
|
context: ./cognito-local
|
|
87
87
|
dockerfile: Dockerfile
|
|
88
88
|
ports:
|
|
89
|
-
- 9229:9229
|
|
89
|
+
- ${LOCAL_COGNITO_PORT:-9229}:9229
|
|
90
90
|
volumes:
|
|
91
91
|
- ./docker-data/.cognito:/app/.cognito
|
|
@@ -4,9 +4,7 @@ $env:AWS_ACCOUNT_ID = "101010101010"
|
|
|
4
4
|
$env:AWS_ACCESS_KEY_ID = "local"
|
|
5
5
|
$env:AWS_SECRET_ACCESS_KEY = "local"
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
# Load environment variables from .env file (assuming you have a utility to load it)
|
|
7
|
+
# Load environment variables from .env file
|
|
10
8
|
Get-Content .env | ForEach-Object {
|
|
11
9
|
if ($_ -match "^\s*#") {
|
|
12
10
|
return
|
|
@@ -19,6 +17,22 @@ Get-Content .env | ForEach-Object {
|
|
|
19
17
|
}
|
|
20
18
|
}
|
|
21
19
|
|
|
20
|
+
# Build table name prefix from environment variables
|
|
21
|
+
# Default: NODE_ENV=local, APP_NAME from .env
|
|
22
|
+
$tablePrefix = if ($env:NODE_ENV) { $env:NODE_ENV } else { "local" }
|
|
23
|
+
$tablePrefix = "$tablePrefix-$env:APP_NAME"
|
|
24
|
+
|
|
25
|
+
# Get ports from environment variables with defaults
|
|
26
|
+
$dynamodbPort = if ($env:LOCAL_DYNAMODB_PORT) { $env:LOCAL_DYNAMODB_PORT } else { "8000" }
|
|
27
|
+
$httpPort = if ($env:LOCAL_HTTP_PORT) { $env:LOCAL_HTTP_PORT } else { "3000" }
|
|
28
|
+
|
|
29
|
+
$endpoint = "http://localhost:$dynamodbPort"
|
|
30
|
+
|
|
31
|
+
Write-Host "Using configuration:"
|
|
32
|
+
Write-Host " TABLE_PREFIX: $tablePrefix"
|
|
33
|
+
Write-Host " DynamoDB endpoint: $endpoint"
|
|
34
|
+
Write-Host " Serverless HTTP port: $httpPort"
|
|
35
|
+
|
|
22
36
|
Write-Host "Read table name"
|
|
23
37
|
|
|
24
38
|
# Read table names from JSON file
|
|
@@ -34,9 +48,8 @@ foreach ($table in $tables) {
|
|
|
34
48
|
exit 1
|
|
35
49
|
}
|
|
36
50
|
|
|
37
|
-
Write-Host "Check health table
|
|
38
|
-
|
|
39
|
-
$status = aws --endpoint $endpoint dynamodb describe-table --table-name "local-$env:APP_NAME-$table-command" --query "Table.TableStatus"
|
|
51
|
+
Write-Host "Check health table $tablePrefix-$table-command"
|
|
52
|
+
$status = aws --endpoint $endpoint dynamodb describe-table --table-name "$tablePrefix-$table-command" --query "Table.TableStatus"
|
|
40
53
|
|
|
41
54
|
Write-Host "Table status: $status"
|
|
42
55
|
if ($status -eq '"ACTIVE"') {
|
|
@@ -59,7 +72,7 @@ while ($true) {
|
|
|
59
72
|
}
|
|
60
73
|
|
|
61
74
|
Write-Host "Check health table tasks"
|
|
62
|
-
$status = aws --endpoint $endpoint dynamodb describe-table --table-name "
|
|
75
|
+
$status = aws --endpoint $endpoint dynamodb describe-table --table-name "$tablePrefix-tasks" --query "Table.TableStatus"
|
|
63
76
|
|
|
64
77
|
Write-Host "Table status: $status"
|
|
65
78
|
if ($status -eq '"ACTIVE"') {
|
|
@@ -82,7 +95,7 @@ while ($true) {
|
|
|
82
95
|
|
|
83
96
|
Write-Host "Check health serverless"
|
|
84
97
|
try {
|
|
85
|
-
$response = Invoke-WebRequest -Uri "http://localhost
|
|
98
|
+
$response = Invoke-WebRequest -Uri "http://localhost:$httpPort" -UseBasicParsing -ErrorAction Stop
|
|
86
99
|
$status = $response.StatusCode
|
|
87
100
|
} catch {
|
|
88
101
|
if ($_.Exception.Response -ne $null) {
|
|
@@ -122,12 +135,12 @@ foreach ($table in $tables) {
|
|
|
122
135
|
|
|
123
136
|
Write-Host "Send a item to trigger command $table"
|
|
124
137
|
|
|
125
|
-
aws dynamodb put-item --endpoint
|
|
138
|
+
aws dynamodb put-item --endpoint $endpoint --table-name "$tablePrefix-$table-command" --item $escapedJsonItemString
|
|
126
139
|
}
|
|
127
140
|
|
|
128
|
-
# Trigger
|
|
141
|
+
# Trigger tasks stream
|
|
129
142
|
Write-Host "Send a command to trigger command stream tasks"
|
|
130
143
|
$command = @"
|
|
131
|
-
aws dynamodb put-item --endpoint
|
|
144
|
+
aws dynamodb put-item --endpoint $endpoint --table-name "$tablePrefix-tasks" --item '{\"input\":{\"M\":{}},\"sk\":{\"S\":\"$timestamp\"},\"pk\":{\"S\":\"test\"}}'
|
|
132
145
|
"@
|
|
133
146
|
Invoke-Expression $command
|
|
@@ -5,10 +5,24 @@ export AWS_ACCOUNT_ID=101010101010
|
|
|
5
5
|
export AWS_ACCESS_KEY_ID=local
|
|
6
6
|
export AWS_SECRET_ACCESS_KEY=local
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
8
|
+
# Load environment variables from .env file
|
|
10
9
|
source .env
|
|
11
10
|
|
|
11
|
+
# Build table name prefix from environment variables
|
|
12
|
+
# Default: NODE_ENV=local, APP_NAME from .env
|
|
13
|
+
TABLE_PREFIX="${NODE_ENV:-local}-${APP_NAME}"
|
|
14
|
+
|
|
15
|
+
# Get ports from environment variables with defaults
|
|
16
|
+
DYNAMODB_PORT="${LOCAL_DYNAMODB_PORT:-8000}"
|
|
17
|
+
HTTP_PORT="${LOCAL_HTTP_PORT:-3000}"
|
|
18
|
+
|
|
19
|
+
endpoint="http://localhost:${DYNAMODB_PORT}"
|
|
20
|
+
|
|
21
|
+
echo "Using configuration:"
|
|
22
|
+
echo " TABLE_PREFIX: ${TABLE_PREFIX}"
|
|
23
|
+
echo " DynamoDB endpoint: ${endpoint}"
|
|
24
|
+
echo " Serverless HTTP port: ${HTTP_PORT}"
|
|
25
|
+
|
|
12
26
|
echo "Read table name"
|
|
13
27
|
declare -a tables
|
|
14
28
|
while IFS= read -r line; do
|
|
@@ -27,7 +41,7 @@ for table in "${tables[@]}"; do
|
|
|
27
41
|
fi
|
|
28
42
|
|
|
29
43
|
echo "Check health table ${table}"
|
|
30
|
-
status=$(aws --endpoint=${endpoint} dynamodb describe-table --table-name
|
|
44
|
+
status=$(aws --endpoint=${endpoint} dynamodb describe-table --table-name ${TABLE_PREFIX}-${table}-command --query 'Table.TableStatus')
|
|
31
45
|
echo "Table status: ${status}"
|
|
32
46
|
if [[ "${status}" == "\"ACTIVE\"" ]]; then
|
|
33
47
|
echo "Table ${table} is ACTIVE"
|
|
@@ -48,7 +62,7 @@ while true; do
|
|
|
48
62
|
fi
|
|
49
63
|
|
|
50
64
|
echo "Check health table tasks"
|
|
51
|
-
status=$(aws --endpoint=${endpoint} dynamodb describe-table --table-name
|
|
65
|
+
status=$(aws --endpoint=${endpoint} dynamodb describe-table --table-name ${TABLE_PREFIX}-tasks --query 'Table.TableStatus')
|
|
52
66
|
echo "Table status: ${status}"
|
|
53
67
|
if [[ "${status}" == "\"ACTIVE\"" ]]; then
|
|
54
68
|
echo "Table tasks is ACTIVE"
|
|
@@ -70,7 +84,7 @@ while true; do
|
|
|
70
84
|
fi
|
|
71
85
|
|
|
72
86
|
echo "Check health serverless"
|
|
73
|
-
status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost
|
|
87
|
+
status=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:${HTTP_PORT})
|
|
74
88
|
echo "Serverless status: ${status}"
|
|
75
89
|
if [[ "${status}" == "200" ]]; then
|
|
76
90
|
echo "Serverless is ACTIVE"
|
|
@@ -85,8 +99,8 @@ done
|
|
|
85
99
|
timestamp=$(date +%s)
|
|
86
100
|
for table in "${tables[@]}"; do
|
|
87
101
|
echo "Send a command to trigger command stream ${table}"
|
|
88
|
-
aws --endpoint=${endpoint} dynamodb put-item --table-name
|
|
102
|
+
aws --endpoint=${endpoint} dynamodb put-item --table-name ${TABLE_PREFIX}-${table}-command --item "{\"pk\": {\"S\": \"test\" }, \"sk\": { \"S\": \"${timestamp}\" }}"
|
|
89
103
|
done
|
|
90
104
|
|
|
91
105
|
echo "Send a command to trigger command stream tasks"
|
|
92
|
-
aws --endpoint
|
|
106
|
+
aws --endpoint=${endpoint} dynamodb put-item --table-name ${TABLE_PREFIX}-tasks --item "{\"input\":{\"M\":{}},\"sk\":{\"S\":\"${timestamp}\"},\"pk\":{\"S\":\"test\"}}"
|
|
@@ -14,23 +14,35 @@ plugins:
|
|
|
14
14
|
- serverless-offline
|
|
15
15
|
|
|
16
16
|
custom:
|
|
17
|
+
# Port configuration - override via environment variables in .env
|
|
18
|
+
httpPort: ${env:LOCAL_HTTP_PORT, 3000}
|
|
19
|
+
lambdaPort: ${env:LOCAL_LAMBDA_PORT, 3002}
|
|
20
|
+
dynamodbPort: ${env:LOCAL_DYNAMODB_PORT, 8000}
|
|
21
|
+
sqsPort: ${env:LOCAL_SQS_PORT, 9324}
|
|
22
|
+
snsPort: ${env:LOCAL_SNS_PORT, 4002}
|
|
23
|
+
eventBridgePort: ${env:LOCAL_EVENTBRIDGE_PORT, 4010}
|
|
24
|
+
sesPort: ${env:LOCAL_SES_PORT, 8005}
|
|
25
|
+
cognitoPort: ${env:LOCAL_COGNITO_PORT, 9229}
|
|
26
|
+
|
|
17
27
|
serverless-offline:
|
|
18
28
|
corsAllowOrigin: '*'
|
|
19
29
|
corsAllowHeaders: '*'
|
|
20
30
|
host: 0.0.0.0
|
|
31
|
+
httpPort: ${self:custom.httpPort}
|
|
32
|
+
lambdaPort: ${self:custom.lambdaPort}
|
|
21
33
|
reloadHandler: true
|
|
22
34
|
ignoreJWTSignature: true
|
|
23
35
|
serverless-offline-ses-v2:
|
|
24
|
-
port:
|
|
36
|
+
port: ${self:custom.sesPort}
|
|
25
37
|
serverless-offline-sns:
|
|
26
|
-
port:
|
|
38
|
+
port: ${self:custom.snsPort}
|
|
27
39
|
debug: true
|
|
28
40
|
subscriptions:
|
|
29
41
|
- topic:
|
|
30
42
|
topicName: CqrsSnsTopic
|
|
31
43
|
rawMessageDelivery: 'true'
|
|
32
44
|
filterPolicy: { 'action': ['task-execute'] }
|
|
33
|
-
queue: http://localhost:
|
|
45
|
+
queue: http://localhost:${self:custom.sqsPort}/101010101010/task-action-queue
|
|
34
46
|
- topic:
|
|
35
47
|
topicName: CqrsSnsTopic
|
|
36
48
|
rawMessageDelivery: 'true'
|
|
@@ -39,21 +51,21 @@ custom:
|
|
|
39
51
|
'action':
|
|
40
52
|
['notification-action', 'command-status', 'task-status'],
|
|
41
53
|
}
|
|
42
|
-
queue: http://localhost:
|
|
54
|
+
queue: http://localhost:${self:custom.sqsPort}/101010101010/notification-queue
|
|
43
55
|
- topic:
|
|
44
56
|
topicName: CqrsSnsTopic
|
|
45
57
|
rawMessageDelivery: 'true'
|
|
46
58
|
filterPolicy: { 'action': ['sub-task-status'] }
|
|
47
|
-
queue: http://localhost:
|
|
59
|
+
queue: http://localhost:${self:custom.sqsPort}/101010101010/sub-task-status-queue
|
|
48
60
|
- topic:
|
|
49
61
|
topicName: CqrsSnsTopic
|
|
50
62
|
rawMessageDelivery: 'true'
|
|
51
63
|
filterPolicy: { 'action': ['import-execute'] }
|
|
52
|
-
queue: http://localhost:
|
|
64
|
+
queue: http://localhost:${self:custom.sqsPort}/101010101010/import-action-queue
|
|
53
65
|
- topic:
|
|
54
66
|
topicName: AlarmSnsTopic
|
|
55
67
|
rawMessageDelivery: 'true'
|
|
56
|
-
queue: http://localhost:
|
|
68
|
+
queue: http://localhost:${self:custom.sqsPort}/101010101010/alarm-queue
|
|
57
69
|
# host: 0.0.0.0 # Optional, defaults to 127.0.0.1 if not provided to serverless-offline
|
|
58
70
|
# sns-endpoint: http://127.0.0.1:4567 # Optional. Only if you want to use a custom SNS provider endpoint
|
|
59
71
|
# sns-subscribe-endpoint: http://127.0.0.1:3000 # Optional. Only if you want to use a custom subscribe endpoint from SNS to send messages back to
|
|
@@ -63,7 +75,7 @@ custom:
|
|
|
63
75
|
accountId: 101010101010
|
|
64
76
|
debug: true
|
|
65
77
|
apiVersion: '2012-11-05'
|
|
66
|
-
endpoint: http://localhost:
|
|
78
|
+
endpoint: http://localhost:${self:custom.sqsPort}
|
|
67
79
|
region: ap-northeast-1
|
|
68
80
|
accessKeyId: root
|
|
69
81
|
secretAccessKey: root
|
|
@@ -80,19 +92,19 @@ custom:
|
|
|
80
92
|
start:
|
|
81
93
|
docker: true
|
|
82
94
|
inMemory: true
|
|
83
|
-
port:
|
|
95
|
+
port: ${self:custom.dynamodbPort}
|
|
84
96
|
noStart: true
|
|
85
97
|
seed: true
|
|
86
98
|
migrate: false # create tables on start
|
|
87
99
|
onStart: false
|
|
88
100
|
convertEmptyValues: true
|
|
89
101
|
serverless-offline-dynamodb-streams:
|
|
90
|
-
endpoint: http://localhost:
|
|
102
|
+
endpoint: http://localhost:${self:custom.dynamodbPort}
|
|
91
103
|
serverless-offline-aws-eventbridge:
|
|
92
|
-
port:
|
|
104
|
+
port: ${self:custom.eventBridgePort}
|
|
93
105
|
mockEventBridgeServer: true # Set to false if EventBridge is already mocked by another stack
|
|
94
106
|
hostname: 127.0.0.1 # IP or hostname of existing EventBridge if mocked by another stack
|
|
95
|
-
pubSubPort: 4011
|
|
107
|
+
pubSubPort: ${env:LOCAL_EVENTBRIDGE_PUBSUB_PORT, 4011}
|
|
96
108
|
debug: false # flag to show debug messages
|
|
97
109
|
account: '' # account id that gets passed to the event
|
|
98
110
|
maximumRetryAttempts: 10 # maximumRetryAttempts to retry lambda
|
|
@@ -113,7 +125,7 @@ provider:
|
|
|
113
125
|
localAuthorizer:
|
|
114
126
|
type: jwt
|
|
115
127
|
identitySource: $request.header.Authorization
|
|
116
|
-
issuerUrl: http://localhost:
|
|
128
|
+
issuerUrl: http://localhost:${self:custom.cognitoPort}/local_2G7noHgW
|
|
117
129
|
audience:
|
|
118
130
|
- dnk8y7ii3wled35p3lw0l2cd7
|
|
119
131
|
# keycloakAuthorizer:
|