@kensio/yulin 1.21.7 → 1.21.9
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/README.md +22 -2
- package/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-properties.js +2 -0
- package/dist/service/lambda/cfn/event-source-mapping/sim-cfn-lambda-event-source-mapping-property-rules.js +1 -1
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.d.ts +2 -0
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-input.js +4 -0
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping-refusals.js +0 -5
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.d.ts +2 -0
- package/dist/service/lambda/command/event-source-mapping/create-event-source-mapping.handler.js +2 -0
- package/dist/service/lambda/command/event-source-mapping/sim-lambda-event-source-mapping-commands.d.ts +2 -0
- package/dist/service/lambda/destination/sim-lambda-destination-targets.d.ts +2 -1
- package/dist/service/lambda/event-source/poll/kinesis/sim-lambda-kinesis-shard-poller.d.ts +0 -4
- package/dist/service/lambda/event-source/poll/kinesis/sim-lambda-kinesis-shard-poller.js +10 -15
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.d.ts +1 -6
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-event-source-poller.js +9 -27
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-polling.d.ts +19 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-dynamodb-stream-polling.js +27 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-event-source-function.d.ts +1 -1
- package/dist/service/lambda/event-source/poll/sim-lambda-event-source-function.js +3 -1
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-age.d.ts +13 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-age.js +27 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-info.d.ts +15 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-info.js +26 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-outcome.d.ts +1 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-outcome.js +7 -1
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-processing.d.ts +17 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-batch-processing.js +12 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-cursor.d.ts +15 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-cursor.js +28 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-expiry.d.ts +19 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-expiry.js +23 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-context.d.ts +3 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-context.js +19 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-destination.d.ts +15 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-destination.js +38 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-record.d.ts +41 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-failure-record.js +17 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress-state.d.ts +21 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress-state.js +39 -0
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress.d.ts +7 -37
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-progress.js +22 -62
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-retry.d.ts +4 -39
- package/dist/service/lambda/event-source/poll/sim-lambda-stream-retry.js +12 -64
- package/dist/service/lambda/event-source/sim-lambda-event-source-mapping.d.ts +10 -3
- package/dist/service/lambda/event-source/sim-lambda-event-source-mapping.js +12 -3
- package/dist/service/lambda/event-source/sim-lambda-stream-destination-config.d.ts +7 -0
- package/dist/service/lambda/event-source/sim-lambda-stream-destination-config.js +38 -0
- package/dist/service/lambda/event-source/stream/kinesis/sim-kinesis-event-source-streams.js +1 -0
- package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-reader.js +1 -0
- package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-shard.d.ts +1 -0
- package/dist/service/lambda/event-source/stream/sim-dynamodb-event-source-stream-shard.js +7 -0
- package/dist/service/lambda/event-source/stream/sim-lambda-event-source-streams.d.ts +1 -0
- package/dist/service/lambda/index.d.ts +1 -0
- package/dist/service/lambda/sim-lambda-commands.js +1 -0
- package/dist/service/ses/command/authorize/sim-ses-authorizer.d.ts +9 -0
- package/dist/service/ses/command/authorize/sim-ses-authorizer.js +18 -2
- package/dist/service/ses/command/send/sim-ses-send-email.js +2 -1
- package/docs/README.md +7 -0
- package/docs/ai-skill/README.md +6 -1
- package/docs/sdk/README.md +15 -0
- package/docs/services/acm/README.md +24 -40
- package/docs/services/apigateway/README.md +52 -71
- package/docs/services/apigatewayv2/README.md +55 -74
- package/docs/services/athena/README.md +17 -26
- package/docs/services/backup/README.md +29 -39
- package/docs/services/bedrock/README.md +38 -52
- package/docs/services/cloudformation/README.md +43 -55
- package/docs/services/cloudfront/README.md +69 -95
- package/docs/services/cloudwatch/README.md +40 -54
- package/docs/services/cognito/README.md +30 -45
- package/docs/services/dynamodb/README.md +34 -51
- package/docs/services/ecr/README.md +36 -77
- package/docs/services/ecs/README.md +26 -46
- package/docs/services/elbv2/README.md +19 -29
- package/docs/services/eventbridge/README.md +14 -18
- package/docs/services/firehose/README.md +24 -32
- package/docs/services/glue/README.md +41 -78
- package/docs/services/iam/README.md +13 -15
- package/docs/services/kinesis/README.md +53 -93
- package/docs/services/kms/README.md +22 -32
- package/docs/services/lambda/README.md +112 -85
- package/docs/services/logs/README.md +41 -50
- package/docs/services/organizations/README.md +50 -85
- package/docs/services/personalize/README.md +28 -44
- package/docs/services/rekognition/README.md +26 -38
- package/docs/services/route53/README.md +17 -17
- package/docs/services/s3/README.md +47 -51
- package/docs/services/scheduler/README.md +41 -52
- package/docs/services/secretsmanager/README.md +27 -42
- package/docs/services/ses/README.md +24 -34
- package/docs/services/sns/README.md +18 -26
- package/docs/services/sqs/README.md +14 -14
- package/docs/services/ssm/README.md +13 -17
- package/docs/services/stepfunctions/README.md +18 -20
- package/docs/services/sts/README.md +32 -45
- package/docs/services/wafv2/README.md +12 -17
- package/docs/testing/README.md +228 -0
- package/docs/time/README.md +10 -0
- package/llms.txt +1 -0
- package/package.json +1 -1
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
# Simulated CloudWatch Metrics
|
|
2
2
|
|
|
3
|
-
Yulin
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
it was to assert that the SDK client had been called. That proves the call was made. What it
|
|
10
|
-
measured goes untested.
|
|
11
|
-
|
|
12
|
-
Most of what lives here is custom metrics. Simulated Lambda publishes its own `AWS/Lambda`
|
|
13
|
-
`Invocations`, `Errors`, `Duration` and `IteratorAge`, simulated Cognito publishes a pool's
|
|
14
|
-
`AWS/Cognito` counts, and no other simulated service publishes into an `AWS/` namespace yet. A
|
|
15
|
-
query for one nothing measures comes back empty, in place of a number that was never taken. A test
|
|
16
|
-
can stand a datapoint up for one of those itself, which is what drives an alarm on a service metric
|
|
17
|
-
to a state change.
|
|
3
|
+
Yulin simulates CloudWatch metrics and alarms in memory. Application code can publish datapoints and
|
|
4
|
+
read their statistics through the normal CloudWatch commands. Alarms evaluate on simulated time and
|
|
5
|
+
can notify simulated SNS topics.
|
|
6
|
+
|
|
7
|
+
Simulated Lambda publishes `AWS/Lambda` metrics, and simulated Cognito publishes `AWS/Cognito`
|
|
8
|
+
metrics. Tests can seed other AWS-managed metrics through the service writer described below.
|
|
18
9
|
|
|
19
10
|
A custom metric's datapoints arrive either from `PutMetricData` or from a CloudWatch Logs metric
|
|
20
11
|
filter counting matching log events. See the [CloudWatch Logs docs](../logs/README.md) for the
|
|
@@ -24,8 +15,8 @@ CloudWatch specific types are imported from the `@kensio/yulin/cloudwatch` subpa
|
|
|
24
15
|
|
|
25
16
|
## Publishing and reading back a metric
|
|
26
17
|
|
|
27
|
-
A metric is identified by its namespace,
|
|
28
|
-
|
|
18
|
+
A metric is identified by its namespace, name, and exact set of dimensions. Publish a value and
|
|
19
|
+
read it back over a period:
|
|
29
20
|
|
|
30
21
|
```typescript sim-cloudwatch-publish-and-read
|
|
31
22
|
/**
|
|
@@ -84,18 +75,14 @@ the way out. A query naming a unit CloudWatch lacks fails here as it would in an
|
|
|
84
75
|
|
|
85
76
|
## Metrics are identified by their dimensions
|
|
86
77
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
That is the behaviour teams most often get wrong, and it is worth a test of its own. A dashboard
|
|
92
|
-
query written against a metric name alone finds nothing at all if every publish carried a dimension.
|
|
78
|
+
CloudWatch treats each exact set of dimensions as a separate metric. Publishing the same metric name
|
|
79
|
+
with two dimension values creates two metrics. A query without dimensions reads only datapoints
|
|
80
|
+
published without dimensions.
|
|
93
81
|
|
|
94
82
|
## Metrics and simulated time
|
|
95
83
|
|
|
96
|
-
A datum
|
|
97
|
-
|
|
98
|
-
datapoints in the period it moved to:
|
|
84
|
+
A datum without a `Timestamp` uses the simulation's clock. Set or advance the clock to place
|
|
85
|
+
datapoints in exact periods:
|
|
99
86
|
|
|
100
87
|
```typescript sim-cloudwatch-simulated-time
|
|
101
88
|
/**
|
|
@@ -153,11 +140,14 @@ window drops a metric out of the listing without anything having to expire it.
|
|
|
153
140
|
|
|
154
141
|
## Metrics a simulated service publishes
|
|
155
142
|
|
|
156
|
-
|
|
143
|
+
Callers publish custom metrics through `PutMetricData`. AWS-managed metrics use namespaces beginning
|
|
144
|
+
with `AWS/`, which callers cannot publish into.
|
|
157
145
|
|
|
158
|
-
|
|
146
|
+
Simulated Cognito publishes counts under `AWS/Cognito`, dimensioned by `UserPool` and
|
|
147
|
+
`UserPoolClient`. See the [Cognito docs](../cognito/README.md).
|
|
159
148
|
|
|
160
|
-
Simulated Lambda publishes
|
|
149
|
+
Simulated Lambda publishes `Invocations`, `Duration`, and `Errors` under `AWS/Lambda`, dimensioned by
|
|
150
|
+
`FunctionName`. These metrics require no extra configuration or execution-role permission.
|
|
161
151
|
|
|
162
152
|
```typescript sim-cloudwatch-lambda-errors
|
|
163
153
|
/**
|
|
@@ -217,13 +207,15 @@ const { MetricAlarms } = await simAws
|
|
|
217
207
|
console.log(MetricAlarms?.[0]?.StateValue);
|
|
218
208
|
```
|
|
219
209
|
|
|
220
|
-
`Duration`
|
|
210
|
+
`Duration` uses the simulation's clock rather than the host's. A handler that advances the clock
|
|
211
|
+
reports that elapsed time, while a handler that leaves it unchanged reports zero duration.
|
|
212
|
+
`IteratorAge` uses the same clock. The Lambda documentation describes the value reported by a stream
|
|
213
|
+
event source mapping.
|
|
221
214
|
|
|
222
215
|
## Seeding a metric AWS publishes
|
|
223
216
|
|
|
224
|
-
`PutMetricData` refuses
|
|
225
|
-
|
|
226
|
-
The service writer is the way in. It is the same route simulated Lambda's own metrics take, reached from a test through `cloudWatch().serviceWriter()`, and it stands a datapoint up in any namespace.
|
|
217
|
+
`PutMetricData` refuses namespaces beginning with `AWS/`. To test an alarm for another AWS-managed
|
|
218
|
+
metric, add the datapoint through `cloudWatch().serviceWriter()`.
|
|
227
219
|
|
|
228
220
|
```typescript sim-cloudwatch-seed-service-metric
|
|
229
221
|
/**
|
|
@@ -286,14 +278,13 @@ console.log(MetricAlarms?.[0]?.StateValue);
|
|
|
286
278
|
|
|
287
279
|
A datapoint arriving without a `timestamp` is stamped with the simulation's clock. One carrying its own lands where it says, which fills a window without the clock having to be walked through it.
|
|
288
280
|
|
|
289
|
-
|
|
281
|
+
The service writer is a test setup API. `PutMetricData` keeps its reserved-namespace validation.
|
|
290
282
|
|
|
291
283
|
## Alarms
|
|
292
284
|
|
|
293
|
-
An alarm watches one metric and changes state on the simulation's clock
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
line of the test runs.
|
|
285
|
+
An alarm watches one metric and changes state on the simulation's clock. Each evaluation is scheduled
|
|
286
|
+
at the next period boundary. Advancing time by twenty minutes runs twenty one-minute evaluations and
|
|
287
|
+
settles before the next line of the test.
|
|
297
288
|
|
|
298
289
|
```typescript sim-cloudwatch-alarm
|
|
299
290
|
/**
|
|
@@ -353,8 +344,8 @@ console.log(described.MetricAlarms?.at(0)?.StateValue);
|
|
|
353
344
|
```
|
|
354
345
|
|
|
355
346
|
A new alarm is in `INSUFFICIENT_DATA` until it has evaluated a period, as on real CloudWatch. The
|
|
356
|
-
window it looks back over reaches behind the moment the alarm was created. An alarm over
|
|
357
|
-
|
|
347
|
+
window it looks back over reaches behind the moment the alarm was created. An alarm over an empty
|
|
348
|
+
metric, with `TreatMissingData: "breaching"`, therefore fires on its first
|
|
358
349
|
evaluation, without waiting for the periods to accumulate. That is what an account does too.
|
|
359
350
|
|
|
360
351
|
### Reaching a subscriber
|
|
@@ -458,10 +449,9 @@ had never named them.
|
|
|
458
449
|
|
|
459
450
|
## Permissions
|
|
460
451
|
|
|
461
|
-
CloudWatch metrics have no ARN,
|
|
462
|
-
|
|
463
|
-
`arn:aws:cloudwatch:eu-west-2:111111111111:metric/Orders/Failed`
|
|
464
|
-
account.
|
|
452
|
+
CloudWatch metrics have no ARN, so every metric action uses a resource of `*`. A policy written
|
|
453
|
+
against a fabricated metric ARN such as
|
|
454
|
+
`arn:aws:cloudwatch:eu-west-2:111111111111:metric/Orders/Failed` is invalid in Yulin and AWS.
|
|
465
455
|
|
|
466
456
|
Alarms are the exception, and do have an ARN. `PutMetricAlarm`, `DeleteAlarms` and `SetAlarmState`
|
|
467
457
|
authorize against `arn:aws:cloudwatch:<region>:<account>:alarm:<name>`, while `DescribeAlarms` and
|
|
@@ -525,7 +515,7 @@ await simAws.cloudWatch().putMetricData(
|
|
|
525
515
|
// Publishing into any other namespace as this Role is denied.
|
|
526
516
|
```
|
|
527
517
|
|
|
528
|
-
##
|
|
518
|
+
## Supported operations
|
|
529
519
|
|
|
530
520
|
- `PutMetricData`, with `Value`, `StatisticValues` and `Values`/`Counts`.
|
|
531
521
|
- `ListMetrics`, filtered by namespace, metric name and dimensions, with `RecentlyActive` and
|
|
@@ -546,11 +536,9 @@ await simAws.cloudWatch().putMetricData(
|
|
|
546
536
|
- `AWS::CloudWatch::Alarm` in simulated CloudFormation, deployed through `PutMetricAlarm` and taken
|
|
547
537
|
down with the stack.
|
|
548
538
|
|
|
549
|
-
##
|
|
539
|
+
## Unsupported operations and options
|
|
550
540
|
|
|
551
|
-
|
|
552
|
-
rather than accepted and ignored. A silently dropped filter is worse than a failure, because the
|
|
553
|
-
test still passes and no longer means what it says.
|
|
541
|
+
Yulin rejects unsupported CloudWatch behavior instead of ignoring it:
|
|
554
542
|
|
|
555
543
|
- **Composite and anomaly detection alarms.** `Metrics` and `ThresholdMetricId` on `PutMetricAlarm`
|
|
556
544
|
are refused. There is no trained model here for an anomaly band to come from.
|
|
@@ -571,8 +559,6 @@ test still passes and no longer means what it says.
|
|
|
571
559
|
through the service writer. A CloudWatch Logs metric filter naming a reserved namespace is refused
|
|
572
560
|
when it publishes, as `PutMetricData` refuses a caller naming one.
|
|
573
561
|
|
|
574
|
-
Two
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
CloudWatch's contract permits without promising, because a test reading the third period of five
|
|
578
|
-
needs an order it can rely on.
|
|
562
|
+
Two behaviors differ from AWS. Yulin accepts datapoints more than two weeks old or more than two
|
|
563
|
+
hours in the future, which makes it easier to seed a test window. It also returns datapoints in
|
|
564
|
+
ascending timestamp order so tests receive deterministic results.
|
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
# Simulated Cognito IDP
|
|
2
2
|
|
|
3
|
-
Yulin
|
|
4
|
-
|
|
3
|
+
Yulin simulates Cognito user pools, app clients, users, groups, tokens, hosted domains and Lambda
|
|
4
|
+
triggers. Use `simAws.cognitoIdp()` directly or intercept a `CognitoIdentityProviderClient`.
|
|
5
|
+
Cognito types are available from `@kensio/yulin/cognito`.
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
are a different service and are outside the simulation.
|
|
8
|
-
|
|
9
|
-
Cognito-specific types are imported from the `@kensio/yulin/cognito` subpath.
|
|
7
|
+
Cognito identity pools are unsupported.
|
|
10
8
|
|
|
11
9
|
## Creating a pool and an app client
|
|
12
10
|
|
|
13
|
-
A pool needs a name.
|
|
14
|
-
applies.
|
|
11
|
+
A user pool needs a name. Other properties use Cognito's defaults.
|
|
15
12
|
|
|
16
13
|
```typescript sim-cognito-create-user-pool
|
|
17
14
|
/**
|
|
@@ -46,16 +43,14 @@ const appClient = await cognito.createUserPoolClient(
|
|
|
46
43
|
console.log(appClient.UserPoolClient?.ClientId); // 26 lowercase characters
|
|
47
44
|
```
|
|
48
45
|
|
|
49
|
-
A pool
|
|
50
|
-
splits the id on the underscore to find the region works here for the same reason it works on AWS.
|
|
46
|
+
A pool ID contains the region before its underscore, matching Cognito's ID format.
|
|
51
47
|
|
|
52
48
|
Two pools may share a name. Only the id identifies one.
|
|
53
49
|
|
|
54
50
|
## Password policy
|
|
55
51
|
|
|
56
|
-
A pool created without
|
|
57
|
-
|
|
58
|
-
those keeps the defaults for the rest.
|
|
52
|
+
A pool created without `Policies` requires at least eight characters with uppercase, lowercase,
|
|
53
|
+
numeric and symbol characters. Setting part of the policy keeps the defaults for omitted fields.
|
|
59
54
|
|
|
60
55
|
```typescript sim-cognito-password-policy
|
|
61
56
|
/**
|
|
@@ -86,10 +81,9 @@ with `InvalidPasswordException`, saying which rule it broke.
|
|
|
86
81
|
|
|
87
82
|
## Users
|
|
88
83
|
|
|
89
|
-
`AdminCreateUser` creates a user in `FORCE_CHANGE_PASSWORD
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
`FORCE_CHANGE_PASSWORD` gets the `NEW_PASSWORD_REQUIRED` challenge, not tokens.
|
|
84
|
+
`AdminCreateUser` creates a user in `FORCE_CHANGE_PASSWORD` with a temporary password. Sign-in
|
|
85
|
+
returns the `NEW_PASSWORD_REQUIRED` challenge until `AdminSetUserPassword` sets a permanent
|
|
86
|
+
password. A permanent password changes the status to `CONFIRMED`.
|
|
93
87
|
|
|
94
88
|
```typescript sim-cognito-create-user
|
|
95
89
|
/**
|
|
@@ -145,11 +139,9 @@ console.log(read.UserAttributes?.find((each) => each.Name === "sub")?.Value);
|
|
|
145
139
|
A password set without `Permanent: true` is temporary, and leaves the user in
|
|
146
140
|
`FORCE_CHANGE_PASSWORD` again.
|
|
147
141
|
|
|
148
|
-
A user's `sub` is a UUID
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
operation asks for a username. That is one thing that works there and not here. The refusal says so
|
|
152
|
-
when the username given is some user's `sub`.
|
|
142
|
+
A user's `sub` is a generated UUID and differs from the username. Yulin's admin operations accept
|
|
143
|
+
the username only. Cognito also accepts a `sub` for some operations, which Yulin reports as an
|
|
144
|
+
unsupported lookup.
|
|
153
145
|
|
|
154
146
|
Attributes come back under `Attributes` from `AdminCreateUser` and `ListUsers`, and under
|
|
155
147
|
`UserAttributes` from `AdminGetUser`, as the real API names them.
|
|
@@ -160,11 +152,9 @@ Attributes come back under `Attributes` from `AdminCreateUser` and `ListUsers`,
|
|
|
160
152
|
|
|
161
153
|
## Signing in by email or phone number
|
|
162
154
|
|
|
163
|
-
A pool
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
is what `AdminGetUser` reports and what the `cognito:username` claim carries. An application reading
|
|
167
|
-
"the username" off such a pool reads a UUID.
|
|
155
|
+
A pool with `UsernameAttributes` signs users in with an email address or phone number. Cognito
|
|
156
|
+
generates a UUID for the stored username. `AdminGetUser` and the `cognito:username` token claim
|
|
157
|
+
report that UUID.
|
|
168
158
|
|
|
169
159
|
A CDK `UserPool` with `signInAliases: { email: true }` emits `UsernameAttributes: ["email"]`, the
|
|
170
160
|
usual way to build an email sign-in pool.
|
|
@@ -384,13 +374,11 @@ outside the simulation.
|
|
|
384
374
|
|
|
385
375
|
## Signing up
|
|
386
376
|
|
|
387
|
-
`SignUp`
|
|
388
|
-
|
|
377
|
+
`SignUp` creates an `UNCONFIRMED` user through an app client. The operation does not use IAM
|
|
378
|
+
authorization.
|
|
389
379
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
deliberate divergence. Real Cognito never reports a code back to anyone, and reading one is what
|
|
393
|
-
makes a registration flow testable at all.
|
|
380
|
+
Read the confirmation code from `confirmationCode` on the simulated pool. Cognito sends the code by
|
|
381
|
+
email or text and never exposes it through the service API.
|
|
394
382
|
|
|
395
383
|
The pool also records the message it would have sent, holding the wording and the code a user
|
|
396
384
|
would have read. That is in [Messages a pool would have sent](#messages-a-pool-would-have-sent)
|
|
@@ -500,9 +488,8 @@ the deployed pool would give. A pool created without the setting allows sign-up,
|
|
|
500
488
|
|
|
501
489
|
## Resetting a forgotten password
|
|
502
490
|
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
are the pair an application calls when it has built its own sign-in screens.
|
|
491
|
+
`ForgotPassword` sends a code and `ConfirmForgotPassword` sets the new password. Both operations use
|
|
492
|
+
an app client and bypass IAM authorization.
|
|
506
493
|
|
|
507
494
|
The code goes to the same place a sign-up code goes, and is read back the same way, through
|
|
508
495
|
`confirmationCode` on the pool object. `ForgotPassword` answers with `CodeDeliveryDetails` naming
|
|
@@ -633,9 +620,8 @@ are refused for one.
|
|
|
633
620
|
|
|
634
621
|
## Messages a pool would have sent
|
|
635
622
|
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
medium, the subject, the body and the occasion it was sent on.
|
|
623
|
+
The pool records outgoing email and text messages in `sentMessages`. Each entry contains the
|
|
624
|
+
recipient, medium, subject, body and message type.
|
|
639
625
|
|
|
640
626
|
A message is recorded on five occasions. Those are a `SignUp`, a `ResendConfirmationCode`, an
|
|
641
627
|
`AdminCreateUser` that did not ask for `MessageAction: SUPPRESS`, an MFA code sent by text message,
|
|
@@ -2060,10 +2046,9 @@ own users at the same address, which real Cognito keeps as two accounts until
|
|
|
2060
2046
|
`AdminLinkProviderForUser` merges them. That operation is unsimulated.
|
|
2061
2047
|
|
|
2062
2048
|
Posting the page carries on into the sign-in the authorize endpoint already runs, ending in the same
|
|
2063
|
-
`<ProviderName>_<subject>` user and the same authorization code.
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
leaves a test that says who is signing in seeing none of this.
|
|
2049
|
+
`<ProviderName>_<subject>` user and the same authorization code. Provider state is discarded after
|
|
2050
|
+
the request. A later authorize request asks again because real Cognito asks the provider afresh each
|
|
2051
|
+
time. A provider configured with `signInAs` skips the page and uses the configured identity.
|
|
2067
2052
|
|
|
2068
2053
|
`/signup` is a link from that page. Its form asks for a username, a password and the attributes the
|
|
2069
2054
|
pool needs, which are the ones its `Schema` made required and the ones its `AutoVerifiedAttributes`
|
|
@@ -3704,8 +3689,8 @@ console.log(described.UserPoolClient?.ClientName);
|
|
|
3704
3689
|
|
|
3705
3690
|
A registered pool behaves like any other. It answers `DescribeUserPoolCommand` and
|
|
3706
3691
|
`ListUserPoolsCommand`, holds users, groups and app clients, and serves its JWKS and OpenID
|
|
3707
|
-
configuration on localhost.
|
|
3708
|
-
|
|
3692
|
+
configuration on localhost. The registered ID determines the pool ARN, issuer URL, token `iss` claim
|
|
3693
|
+
and `ProviderName`. A
|
|
3709
3694
|
policy naming `arn:aws:cognito-idp:eu-west-2:111111111111:userpool/eu-west-2_aBcDeFgHi` authorizes
|
|
3710
3695
|
the handler that reads the pool, which is what a template carrying the id in two places needs.
|
|
3711
3696
|
|
|
@@ -1,18 +1,13 @@
|
|
|
1
1
|
# Simulated DynamoDB
|
|
2
2
|
|
|
3
|
-
Yulin
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
This page covers creating, describing, listing and deleting tables. What a request says is checked
|
|
7
|
-
the way real DynamoDB checks it. A table that can be created here is one that could be created on
|
|
8
|
-
AWS.
|
|
9
|
-
|
|
10
|
-
DynamoDB-specific types are imported from the `@kensio/yulin/dynamodb` subpath.
|
|
3
|
+
Yulin simulates DynamoDB tables, indexes, items, streams and time to live in memory. Use
|
|
4
|
+
`simAws.dynamoDb()` directly or intercept a `DynamoDBClient`. DynamoDB types are available from
|
|
5
|
+
`@kensio/yulin/dynamodb`.
|
|
11
6
|
|
|
12
7
|
## Creating a table
|
|
13
8
|
|
|
14
|
-
`CreateTable`
|
|
15
|
-
attribute
|
|
9
|
+
`CreateTable` requires a table name, a key schema and an attribute definition for every key
|
|
10
|
+
attribute.
|
|
16
11
|
|
|
17
12
|
```typescript sim-dynamodb-create-table
|
|
18
13
|
/**
|
|
@@ -45,8 +40,7 @@ await simAws.backgroundTasksComplete();
|
|
|
45
40
|
A new table is `CREATING`, and activation is scheduled as background work. Call
|
|
46
41
|
`simAws.backgroundTasksComplete()` when a test needs the table to be `ACTIVE`.
|
|
47
42
|
|
|
48
|
-
The
|
|
49
|
-
definitions, the table ARN, a table ID, and the billing and capacity the table was created with.
|
|
43
|
+
The response describes the table's keys, attribute definitions, ARN, ID, billing mode and capacity.
|
|
50
44
|
|
|
51
45
|
## Key schema and attribute definitions
|
|
52
46
|
|
|
@@ -62,9 +56,8 @@ attribute as the type the table declared for it.
|
|
|
62
56
|
|
|
63
57
|
## Billing modes and throughput
|
|
64
58
|
|
|
65
|
-
`BillingMode` defaults to `PROVISIONED
|
|
66
|
-
|
|
67
|
-
no capacity, and is refused.
|
|
59
|
+
`BillingMode` defaults to `PROVISIONED`. A provisioned table requires at least one read and one write
|
|
60
|
+
capacity unit in `ProvisionedThroughput`.
|
|
68
61
|
|
|
69
62
|
`PAY_PER_REQUEST` refuses `ProvisionedThroughput`, since an on-demand table has no capacity to
|
|
70
63
|
provision.
|
|
@@ -111,8 +104,8 @@ reports for one.
|
|
|
111
104
|
|
|
112
105
|
## Global secondary indexes
|
|
113
106
|
|
|
114
|
-
`GlobalSecondaryIndexes`
|
|
115
|
-
|
|
107
|
+
`GlobalSecondaryIndexes` adds indexes over the table's items. Each index requires an `IndexName`,
|
|
108
|
+
`KeySchema` and `Projection`.
|
|
116
109
|
|
|
117
110
|
```typescript sim-dynamodb-global-secondary-index
|
|
118
111
|
/**
|
|
@@ -583,9 +576,8 @@ console.log(description.Table?.TableStatus); // "ACTIVE"
|
|
|
583
576
|
|
|
584
577
|
## Tagging tables
|
|
585
578
|
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
`ResourceArn`, where the table commands take a name or an ARN.
|
|
579
|
+
Add tags during `CreateTable` or later with `TagResource`. Remove them with `UntagResource` and read
|
|
580
|
+
them with `ListTagsOfResource`. Tag commands require the table ARN in `ResourceArn`.
|
|
589
581
|
|
|
590
582
|
```typescript sim-dynamodb-tag-table
|
|
591
583
|
/**
|
|
@@ -683,9 +675,8 @@ calling `Tags.of(stack).add("Environment", "test")` gets a tagged table.
|
|
|
683
675
|
|
|
684
676
|
## Writing items
|
|
685
677
|
|
|
686
|
-
`PutItem`
|
|
687
|
-
|
|
688
|
-
step in between.
|
|
678
|
+
`PutItem` replaces the complete item stored under the primary key. The write is visible when the
|
|
679
|
+
command returns.
|
|
689
680
|
|
|
690
681
|
```typescript sim-dynamodb-put-item
|
|
691
682
|
/**
|
|
@@ -739,10 +730,9 @@ anywhere else in the item.
|
|
|
739
730
|
|
|
740
731
|
## Reading and deleting items
|
|
741
732
|
|
|
742
|
-
`GetItem` reads
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
`ValidationException` naming the attribute at fault.
|
|
733
|
+
`GetItem` reads an item by primary key. `DeleteItem` removes it. The `Key` must contain every key
|
|
734
|
+
attribute and no others, using the types declared in `AttributeDefinitions`. Invalid keys raise
|
|
735
|
+
`ValidationException`.
|
|
746
736
|
|
|
747
737
|
```typescript sim-dynamodb-get-delete-item
|
|
748
738
|
/**
|
|
@@ -822,9 +812,8 @@ Both take the table's name or its ARN, as the table commands do.
|
|
|
822
812
|
|
|
823
813
|
## Updating items
|
|
824
814
|
|
|
825
|
-
`UpdateItem` changes
|
|
826
|
-
|
|
827
|
-
Each keyword appears at most once, and the actions inside a clause are separated by commas.
|
|
815
|
+
`UpdateItem` changes selected attributes. Its `UpdateExpression` may contain `SET`, `REMOVE`, `ADD`
|
|
816
|
+
and `DELETE` clauses in any order. Each clause may appear once and contain comma-separated actions.
|
|
828
817
|
|
|
829
818
|
A `SET` action is `path = operand`, where an operand is a value from `ExpressionAttributeValues`,
|
|
830
819
|
another document path, or a call to `if_not_exists(path, operand)` or `list_append(one, other)`. Two
|
|
@@ -1066,12 +1055,11 @@ placeholder used by either counts as used.
|
|
|
1066
1055
|
|
|
1067
1056
|
## Conditional writes
|
|
1068
1057
|
|
|
1069
|
-
`PutItem`, `DeleteItem` and `UpdateItem`
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
uses.
|
|
1058
|
+
`PutItem`, `DeleteItem` and `UpdateItem` evaluate `ConditionExpression` against the stored item before
|
|
1059
|
+
writing. A failed condition leaves the item unchanged and raises
|
|
1060
|
+
`ConditionalCheckFailedException`.
|
|
1073
1061
|
|
|
1074
|
-
|
|
1062
|
+
Use `attribute_not_exists` for insert-only writes or compare a version attribute for optimistic
|
|
1075
1063
|
locking.
|
|
1076
1064
|
|
|
1077
1065
|
```typescript sim-dynamodb-conditional-write
|
|
@@ -1176,9 +1164,8 @@ expression, in both directions. A placeholder the request leaves undefined is a
|
|
|
1176
1164
|
|
|
1177
1165
|
## Projecting attributes
|
|
1178
1166
|
|
|
1179
|
-
`
|
|
1180
|
-
|
|
1181
|
-
indexes, such as `address.city` or `lines[0].sku`.
|
|
1167
|
+
`ProjectionExpression` is a comma-separated list of document paths returned by `GetItem`. A path can
|
|
1168
|
+
contain map attributes and list indexes, such as `address.city` or `lines[0].sku`.
|
|
1182
1169
|
|
|
1183
1170
|
An attribute name that is a DynamoDB reserved word, or that has a character an expression cannot
|
|
1184
1171
|
carry, is written as a `#name` placeholder and defined in `ExpressionAttributeNames`.
|
|
@@ -1259,12 +1246,11 @@ index and a path past that depth are each a `ValidationException` naming the pat
|
|
|
1259
1246
|
|
|
1260
1247
|
## Querying an item collection
|
|
1261
1248
|
|
|
1262
|
-
A table with a sort key
|
|
1263
|
-
|
|
1249
|
+
A table with a sort key keeps one ordered item collection per partition key. `Query` reads one
|
|
1250
|
+
collection.
|
|
1264
1251
|
|
|
1265
|
-
`KeyConditionExpression`
|
|
1266
|
-
`AND
|
|
1267
|
-
`BETWEEN` or `begins_with`, and both bounds of a `BETWEEN` are inside the range.
|
|
1252
|
+
`KeyConditionExpression` requires equality on the partition key. It may add one sort key condition
|
|
1253
|
+
with `AND`. Sort key operators are `=`, `<`, `<=`, `>`, `>=`, `BETWEEN` and `begins_with`.
|
|
1268
1254
|
|
|
1269
1255
|
```typescript sim-dynamodb-query
|
|
1270
1256
|
/**
|
|
@@ -1371,8 +1357,8 @@ in `ExpressionAttributeNames`, as in any other expression.
|
|
|
1371
1357
|
|
|
1372
1358
|
### Paging a collection
|
|
1373
1359
|
|
|
1374
|
-
`Limit` counts
|
|
1375
|
-
|
|
1360
|
+
`Limit` counts evaluated items. Pass `LastEvaluatedKey` back as `ExclusiveStartKey` to continue after
|
|
1361
|
+
the last evaluated item.
|
|
1376
1362
|
|
|
1377
1363
|
```typescript sim-dynamodb-query-paging
|
|
1378
1364
|
/**
|
|
@@ -1447,9 +1433,7 @@ from a different partition key is refused, since it names a collection this quer
|
|
|
1447
1433
|
|
|
1448
1434
|
## Reading a global secondary index
|
|
1449
1435
|
|
|
1450
|
-
`IndexName` on `Query`
|
|
1451
|
-
the index key schema and not the table's, which is the point. The index is how an access pattern the
|
|
1452
|
-
table key cannot serve gets served.
|
|
1436
|
+
Set `IndexName` on `Query` or `Scan` to read an index. Key conditions then use the index key schema.
|
|
1453
1437
|
|
|
1454
1438
|
```typescript sim-dynamodb-query-index
|
|
1455
1439
|
/**
|
|
@@ -1572,9 +1556,8 @@ refused.
|
|
|
1572
1556
|
|
|
1573
1557
|
## Scanning a table
|
|
1574
1558
|
|
|
1575
|
-
`Scan` reads every item in a table
|
|
1576
|
-
|
|
1577
|
-
patterns, since it reads the whole table however few items the caller wanted.
|
|
1559
|
+
`Scan` reads every item in a table without a key condition. It is useful for test assertions but
|
|
1560
|
+
usually reads more data than application code needs.
|
|
1578
1561
|
|
|
1579
1562
|
```typescript sim-dynamodb-scan
|
|
1580
1563
|
/**
|