@mbc-cqrs-serverless/cli 1.3.3 → 1.3.5
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/index.js +1 -1
- package/dist/utils/local-binaries.js +1 -1
- package/package.json +2 -2
- package/templates/.env.local +11 -3
- package/templates/infra/config/type.ts +25 -0
- package/templates/infra/libs/infra-stack.ts +171 -6
- package/templates/infra/test/__snapshots__/infra.test.ts.snap +86 -12
- package/templates/infra/test/fixtures/app/README.txt +1 -0
- package/templates/infra/test/fixtures/layer/README.txt +1 -0
- package/templates/infra/test/infra.test.ts +49 -10
- package/templates/infra-local/appsync-simulator/package-lock.json +1198 -696
- package/templates/infra-local/appsync-simulator/package.json +4 -1
- package/templates/infra-local/cognito-local/package-lock.json +297 -240
- package/templates/infra-local/cognito-local/package.json +3 -2
- package/templates/infra-local/cognito-local/start.sh +46 -0
- package/templates/infra-local/docker-compose.yml +6 -2
- package/templates/infra-local/scripts/resources.ps1 +6 -3
- package/templates/infra-local/scripts/resources.sh +7 -3
- package/templates/infra-local/scripts/trigger_ddb_stream.ps1 +95 -2
- package/templates/infra-local/scripts/trigger_ddb_stream.sh +89 -3
- package/templates/infra-local/serverless.yml +11 -0
- package/templates/package-lock.json +8527 -3164
- package/templates/package.json +36 -13
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
|
|
5
5
|
import * as cdk from 'aws-cdk-lib'
|
|
6
|
-
import { Template } from 'aws-cdk-lib/assertions'
|
|
6
|
+
import { Match, Template } from 'aws-cdk-lib/assertions'
|
|
7
7
|
import { getConfig } from '../config'
|
|
8
8
|
import { InfraStack } from '../libs/infra-stack'
|
|
9
9
|
|
|
@@ -29,18 +29,20 @@ jest.mock('crypto', () => ({
|
|
|
29
29
|
jest.mock('aws-cdk-lib', () => ({
|
|
30
30
|
...jest.requireActual('aws-cdk-lib'),
|
|
31
31
|
Duration: {
|
|
32
|
-
days: jest.fn(() => ({
|
|
33
|
-
toMilliseconds: jest.fn(() =>
|
|
32
|
+
days: jest.fn((n: number) => ({
|
|
33
|
+
toMilliseconds: jest.fn(() => n * 24 * 60 * 60 * 1000),
|
|
34
|
+
toSeconds: jest.fn(() => n * 24 * 60 * 60),
|
|
34
35
|
})),
|
|
35
|
-
hours: jest.fn(() => ({
|
|
36
|
-
minutes: jest.fn(() =>
|
|
37
|
-
toSeconds: jest.fn(() =>
|
|
36
|
+
hours: jest.fn((n: number) => ({
|
|
37
|
+
minutes: jest.fn(() => n * 60),
|
|
38
|
+
toSeconds: jest.fn(() => n * 60 * 60),
|
|
39
|
+
toMilliseconds: jest.fn(() => n * 60 * 60 * 1000),
|
|
38
40
|
})),
|
|
39
|
-
minutes: jest.fn(() => ({
|
|
40
|
-
toSeconds: jest.fn(() =>
|
|
41
|
+
minutes: jest.fn((n: number) => ({
|
|
42
|
+
toSeconds: jest.fn(() => n * 60),
|
|
41
43
|
})),
|
|
42
|
-
seconds: jest.fn(() => ({
|
|
43
|
-
toSeconds: jest.fn(() =>
|
|
44
|
+
seconds: jest.fn((n: number) => ({
|
|
45
|
+
toSeconds: jest.fn(() => n),
|
|
44
46
|
})),
|
|
45
47
|
},
|
|
46
48
|
Expiration: {
|
|
@@ -52,6 +54,17 @@ jest.mock('aws-cdk-lib', () => ({
|
|
|
52
54
|
},
|
|
53
55
|
}))
|
|
54
56
|
|
|
57
|
+
// buildApp() shells out to a real `npm ci && npm run build:prod` of the parent
|
|
58
|
+
// application (via execSync). That cannot run in the isolated template / CI
|
|
59
|
+
// context, so it is mocked to return placeholder asset directories, keeping the
|
|
60
|
+
// CDK synthesis hermetic and the snapshot deterministic.
|
|
61
|
+
jest.mock('../libs/build-app', () => ({
|
|
62
|
+
buildApp: jest.fn(() => ({
|
|
63
|
+
layerPath: require('path').resolve(__dirname, 'fixtures/layer'),
|
|
64
|
+
appPath: require('path').resolve(__dirname, 'fixtures/app'),
|
|
65
|
+
})),
|
|
66
|
+
}))
|
|
67
|
+
|
|
55
68
|
function replaceKeyValue(obj: any, desKey: string, desVal: string): any {
|
|
56
69
|
if (typeof obj !== 'object' || obj === null) {
|
|
57
70
|
return obj
|
|
@@ -93,3 +106,29 @@ test('snapshot test for InfraStack', () => {
|
|
|
93
106
|
|
|
94
107
|
expect(template).toMatchSnapshot()
|
|
95
108
|
})
|
|
109
|
+
|
|
110
|
+
test('lambda-api SendTaskSuccess is scoped to command-handler state machine', () => {
|
|
111
|
+
const cdkEnv: cdk.Environment = {
|
|
112
|
+
account: '101010101010',
|
|
113
|
+
region: 'ap-northeast-1',
|
|
114
|
+
}
|
|
115
|
+
const config = getConfig('dev')
|
|
116
|
+
const app = new cdk.App()
|
|
117
|
+
const stack = new InfraStack(app, 'TestInfraStackIam', {
|
|
118
|
+
env: cdkEnv,
|
|
119
|
+
config,
|
|
120
|
+
})
|
|
121
|
+
const template = Template.fromStack(stack)
|
|
122
|
+
|
|
123
|
+
template.hasResourceProperties('AWS::IAM::Policy', {
|
|
124
|
+
PolicyDocument: {
|
|
125
|
+
Statement: Match.arrayWith([
|
|
126
|
+
Match.objectLike({
|
|
127
|
+
Action: 'states:SendTaskSuccess',
|
|
128
|
+
Effect: 'Allow',
|
|
129
|
+
Resource: { Ref: 'commandhandlerstatemachine937D91FB' },
|
|
130
|
+
}),
|
|
131
|
+
]),
|
|
132
|
+
},
|
|
133
|
+
})
|
|
134
|
+
})
|