konokenj.cdk-api-mcp-server 0.45.0__py3-none-any.whl → 0.47.0__py3-none-any.whl

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.
Files changed (24) hide show
  1. cdk_api_mcp_server/__about__.py +1 -1
  2. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/aws-elasticache-alpha/README.md +421 -0
  3. cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/custom-resource-handlers/README.md +15 -78
  4. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/README.md +14 -0
  5. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-cloudfront-origins/integ.http-origin.ts +5 -2
  6. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-config.ts +4 -15
  7. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-group.ts +218 -40
  8. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-docdb/README.md +24 -0
  9. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-docdb/integ.cluster-serverless.ts +34 -0
  10. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.availability-zone-rebalancing.ts +14 -4
  11. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.enable-execute-command.ts +35 -29
  12. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.exec-command.ts +16 -22
  13. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.lb-awsvpc-nw.ts +26 -16
  14. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.pseudo-terminal.ts +18 -8
  15. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke-jsonata.ts +80 -87
  16. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke.ts +69 -87
  17. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.start-job-run.ts +43 -96
  18. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/pipelines/README.md +4 -0
  19. cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/pipelines/integ.newpipeline-reduce-stagerole-scope.ts +4 -1
  20. {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/METADATA +2 -2
  21. {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/RECORD +24 -22
  22. {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/WHEEL +0 -0
  23. {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/entry_points.txt +0 -0
  24. {konokenj_cdk_api_mcp_server-0.45.0.dist-info → konokenj_cdk_api_mcp_server-0.47.0.dist-info}/licenses/LICENSE.txt +0 -0
@@ -1,4 +1,4 @@
1
1
  # SPDX-FileCopyrightText: 2025-present Kenji Kono <konoken@amazon.co.jp>
2
2
  #
3
3
  # SPDX-License-Identifier: MIT
4
- __version__ = "0.45.0"
4
+ __version__ = "0.47.0"
@@ -0,0 +1,421 @@
1
+ # ElastiCache CDK Construct Library
2
+ <!--BEGIN STABILITY BANNER-->
3
+
4
+ ---
5
+
6
+ ![cdk-constructs: Experimental](https://img.shields.io/badge/cdk--constructs-experimental-important.svg?style=for-the-badge)
7
+
8
+ > The APIs of higher level constructs in this module are experimental and under active development.
9
+ > They are subject to non-backward compatible changes or removal in any future version. These are
10
+ > not subject to the [Semantic Versioning](https://semver.org/) model and breaking changes will be
11
+ > announced in the release notes. This means that while you may use them, you may need to update
12
+ > your source code when upgrading to a newer version of this package.
13
+
14
+ ---
15
+
16
+ <!--END STABILITY BANNER-->
17
+
18
+ This module has constructs for [Amazon ElastiCache](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/WhatIs.html).
19
+
20
+ * The `ServerlessCache` construct facilitates the creation and management of serverless cache.
21
+ * The `User` and `UserGroup` constructs facilitate the creation and management of users for the cache.
22
+
23
+ ## Serverless Cache
24
+
25
+ Amazon ElastiCache Serverless is a serverless option that automatically scales cache capacity based on application traffic patterns. You can create a serverless cache using the `ServerlessCache` construct:
26
+
27
+ ```ts
28
+ const vpc = new ec2.Vpc(this, 'VPC');
29
+
30
+ const cache = new elasticache.ServerlessCache(this, 'ServerlessCache', {
31
+ vpc,
32
+ });
33
+ ```
34
+
35
+ ### Connecting to serverless cache
36
+
37
+ To control who can access the serverless cache by the security groups, use the `.connections` attribute.
38
+
39
+ The serverless cache has a default port `6379`.
40
+
41
+ This example allows an EC2 instance to connect to the serverless cache:
42
+
43
+ ```ts
44
+ declare const serverlessCache: elasticache.ServerlessCache;
45
+ declare const instance: ec2.Instance;
46
+
47
+ // allow the EC2 instance to connect to serverless cache on default port 6379
48
+ serverlessCache.connections.allowDefaultPortFrom(instance);
49
+ ```
50
+
51
+ ### Cache usage limits
52
+
53
+ You can configure usage limits on both cache data storage and ECPU/second for your cache to control costs and ensure predictable performance.
54
+
55
+ **Configuration options:**
56
+
57
+ * **Maximum limits**: Ensure your cache usage never exceeds the configured maximum
58
+ * **Minimum limits**: Reserve a baseline level of resources for consistent performance
59
+ * **Both**: Define a range where your cache usage will operate
60
+
61
+ For more infomation, see [Setting scaling limits to manage costs](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/Scaling.html#Pre-Scaling).
62
+
63
+ ```ts
64
+ declare const vpc: ec2.Vpc;
65
+
66
+ const serverlessCache = new elasticache.ServerlessCache(this, 'ServerlessCache', {
67
+ engine: elasticache.CacheEngine.VALKEY_LATEST,
68
+ vpc,
69
+ cacheUsageLimits: {
70
+ // cache data storage limits (GB)
71
+ dataStorageMinimumSize: Size.gibibytes(2), // minimum: 1GB
72
+ dataStorageMaximumSize: Size.gibibytes(3), // maximum: 5000GB
73
+ // rate limits (ECPU/second)
74
+ requestRateLimitMinimum: 1000, // minimum: 1000
75
+ requestRateLimitMaximum: 10000, // maximum: 15000000
76
+ },
77
+ });
78
+ ```
79
+
80
+ ### Backups and restore
81
+
82
+ You can enable automatic backups for serverless cache.
83
+ When automatic backups are enabled, ElastiCache creates a backup of the cache on a daily basis.
84
+
85
+ Also you can set the backup window for any time when it's most convenient.
86
+ If you don't specify a backup window, ElastiCache assigns one automatically.
87
+
88
+ For more information, see [Scheduling automatic backups](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/backups-automatic.html).
89
+
90
+ To enable automatic backups, set the `backupRetentionLimit` property. You can also specify the snapshot creation time by setting `backupTime` property:
91
+
92
+ ```ts
93
+ declare const vpc: ec2.Vpc;
94
+
95
+ const serverlessCache = new elasticache.ServerlessCache(this, 'ServerlessCache', {
96
+ backup: {
97
+ // enable automatic backups and set the retention period to 6 days
98
+ backupRetentionLimit: 6,
99
+ // set the backup window to 9:00 AM UTC
100
+ backupTime: events.Schedule.cron({
101
+ hour: '9',
102
+ minute: '0',
103
+ }),
104
+ },
105
+ vpc,
106
+ });
107
+ ```
108
+
109
+ You can create a final backup by setting `backupNameBeforeDeletion` property.
110
+
111
+ ```ts
112
+ declare const vpc: ec2.Vpc;
113
+
114
+ const serverlessCache = new elasticache.ServerlessCache(this, 'ServerlessCache', {
115
+ engine: elasticache.CacheEngine.VALKEY_LATEST,
116
+ backup: {
117
+ // set a backup name before deleting a cache
118
+ backupNameBeforeDeletion: "my-final-backup-name",
119
+ },
120
+ vpc,
121
+ });
122
+ ```
123
+
124
+ You can restore from backups by setting snapshot ARNs to `backupArnsToRestore` property:
125
+
126
+ ```ts
127
+ declare const vpc: ec2.Vpc;
128
+
129
+ const serverlessCache = new elasticache.ServerlessCache(this, 'ServerlessCache', {
130
+ engine: elasticache.CacheEngine.VALKEY_LATEST,
131
+ backup: {
132
+ // set the backup(s) to restore
133
+ backupArnsToRestore: ['arn:aws:elasticache:us-east-1:123456789012:serverlesscachesnapshot:my-final-backup-name'],
134
+ },
135
+ vpc,
136
+ });
137
+ ```
138
+
139
+ ### Encryption at rest
140
+
141
+ At-rest encryption is always enabled for Serverless Cache. There are two encryption options:
142
+
143
+ * **Default**: When no `kmsKey` is specified (left as `undefined`), AWS owned KMS keys are used automatically
144
+ * **Customer Managed Key**: Create a KMS key first, then pass it to the cache via the `kmsKey` property
145
+
146
+ ### Customer Managed Key for encryption at rest
147
+
148
+ ElastiCache supports symmetric Customer Managed key (CMK) for encryption at rest.
149
+
150
+ For more information, see [Using customer managed keys from AWS KMS](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/at-rest-encryption.html#using-customer-managed-keys-for-elasticache-security).
151
+
152
+ To use CMK, set your CMK to the `kmsKey` property:
153
+
154
+ ```ts
155
+ import { Key } from 'aws-cdk-lib/aws-kms';
156
+
157
+ declare const kmsKey: Key;
158
+ declare const vpc: ec2.Vpc;
159
+
160
+ const serverlessCache = new elasticache.ServerlessCache(this, 'ServerlessCache', {
161
+ engine: elasticache.CacheEngine.VALKEY_LATEST,
162
+ serverlessCacheName: 'my-serverless-cache',
163
+ vpc,
164
+ // set Customer Managed Key
165
+ kmsKey,
166
+ });
167
+ ```
168
+
169
+ ### Metrics and monitoring
170
+
171
+ You can monitor your serverless cache using CloudWatch Metrics via the `metric` method.
172
+
173
+ For more information about serverless cache metrics, see [Serverless metrics and events for Valkey and Redis OSS](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/serverless-metrics-events-redis.html) and [Serverless metrics and events for Memcached](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/serverless-metrics-events.memcached.html).
174
+
175
+ ```ts
176
+ declare const serverlessCache: elasticache.ServerlessCache;
177
+
178
+ // The 5 minutes average of the total number of successful read-only key lookups in the cache.
179
+ const cacheHits = serverlessCache.metricCacheHitCount();
180
+
181
+ // The 5 minutes average of the total number of bytes used by the data stored in the cache.
182
+ const bytesUsedForCache = serverlessCache.metricDataStored();
183
+
184
+ // The 5 minutes average of the total number of ElastiCacheProcessingUnits (ECPUs) consumed by the requests executed on the cache.
185
+ const elastiCacheProcessingUnits = serverlessCache.metricProcessingUnitsConsumed();
186
+
187
+ // Create an alarm for ECPUs.
188
+ elastiCacheProcessingUnits.createAlarm(this, 'ElastiCacheProcessingUnitsAlarm', {
189
+ threshold: 50,
190
+ evaluationPeriods: 1,
191
+ });
192
+ ```
193
+
194
+ ### Import an existing serverless cache
195
+
196
+ To import an existing ServerlessCache, use the `ServerlessCache.fromServerlessCacheAttributes` method:
197
+
198
+ ```ts
199
+ declare const securityGroup: ec2.SecurityGroup;
200
+
201
+ const importedServerlessCache = elasticache.ServerlessCache.fromServerlessCacheAttributes(this, 'ImportedServerlessCache', {
202
+ serverlessCacheName: 'my-serverless-cache',
203
+ securityGroups: [securityGroup],
204
+ });
205
+ ```
206
+
207
+ ## User and User Group
208
+
209
+ Setup required properties and create:
210
+
211
+ ```ts
212
+ const newDefaultUser = new elasticache.NoPasswordUser(this, 'NoPasswordUser', {
213
+ userId: 'default',
214
+ accessControl: elasticache.AccessControl.fromAccessString("on ~* +@all"),
215
+ })
216
+
217
+ const userGroup = new elasticache.UserGroup(this, 'UserGroup', {
218
+ users: [newDefaultUser],
219
+ });
220
+ ```
221
+
222
+ ### RBAC
223
+
224
+ In Valkey 7.2 and onward and Redis OSS 6.0 onward you can use a feature called Role-Based Access Control (RBAC). RBAC is also the only way to control access to serverless caches.
225
+
226
+ RBAC enables you to control cache access through user groups. These user groups are designed as a way to organize access to caches.
227
+
228
+ For more information, see [Role-Based Access Control (RBAC)](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/Clusters.RBAC.html).
229
+
230
+ To enable RBAC for ElastiCache with Valkey or Redis OSS, you take the following steps:
231
+
232
+ * Create users.
233
+ * Create a user group and add users to the user group.
234
+ * Assign the user group to a cache.
235
+
236
+ ### Create users
237
+
238
+ First, you need to create users by using `IamUser`, `PasswordUser` or `NoPasswordUser` construct.
239
+
240
+ With RBAC, you create users and assign them specific permissions by using `accessString` property.
241
+
242
+ For more information, see [Specifying Permissions Using an Access String](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/Clusters.RBAC.html#Access-string).
243
+
244
+ You can create an IAM-enabled user by using `IamUser` construct:
245
+
246
+ ```ts
247
+ const user = new elasticache.IamUser(this, 'User', {
248
+ // set user engine
249
+ engine: elasticache.UserEngine.REDIS,
250
+
251
+ // set user id
252
+ userId: 'my-user',
253
+
254
+ // set username
255
+ userName: 'my-user',
256
+
257
+ // set access string
258
+ accessControl: elasticache.AccessControl.fromAccessString("on ~* +@all"),
259
+ });
260
+ ```
261
+
262
+ > NOTE: IAM-enabled users must have matching user id and username. For more information, see [Limitations](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/auth-iam.html). The construct can set automatically the username to be the same as the user id.
263
+
264
+ If you want to create a password authenticated user, use `PasswordUser` construct:
265
+
266
+ ```ts
267
+ const user = new elasticache.PasswordUser(this, 'User', {
268
+ // set user engine
269
+ engine: elasticache.UserEngine.VALKEY,
270
+
271
+ // set user id
272
+ userId: 'my-user-id',
273
+
274
+ // set access string
275
+ accessControl: elasticache.AccessControl.fromAccessString("on ~* +@all"),
276
+
277
+ // set username
278
+ userName: 'my-user-name',
279
+
280
+ // set up to two passwords
281
+ passwords: [
282
+ // "SecretIdForPassword" is the secret id for the password
283
+ SecretValue.secretsManager('SecretIdForPassword'),
284
+ // "AnotherSecretIdForPassword" is the secret id for the password
285
+ SecretValue.secretsManager('AnotherSecretIdForPassword'),
286
+ ],
287
+ });
288
+ ```
289
+
290
+ You can also create a no password required user by using `NoPasswordUser` construct:
291
+
292
+ ```ts
293
+ const user = new elasticache.NoPasswordUser(this, 'User', {
294
+ // set user engine
295
+ engine: elasticache.UserEngine.REDIS,
296
+
297
+ // set user id
298
+ userId: 'my-user-id',
299
+
300
+ // set access string
301
+ accessControl: elasticache.AccessControl.fromAccessString("on ~* +@all"),
302
+
303
+ // set username
304
+ userName: 'my-user-name',
305
+ });
306
+ ```
307
+
308
+ ### Default user
309
+
310
+ ElastiCache automatically creates a default user with both a user ID and username set to `default`. This default user cannot be modified or deleted. The user is created as a no password authentication user.
311
+
312
+ This user is intended for compatibility with the default behavior of previous Redis OSS versions and has an access string that permits it to call all commands and access all keys.
313
+
314
+ To use this automatically created default user in CDK, you can import it using `NoPasswordUser.fromUserAttributes` method. For more information on import methods, see the [Import an existing user and user group](#import-an-existing-user-and-user-group) section.
315
+
316
+ To add proper access control to a cache, replace the default user with a new one that is either disabled by setting the `accessString` to `off -@all` or secured with a strong password.
317
+
318
+ To change the default user, create a new default user with the username set to `default`. You can then swap it with the original default user.
319
+
320
+ For more information, see [Applying RBAC to a Cache for ElastiCache with Valkey or Redis OSS](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/Clusters.RBAC.html#rbac-using).
321
+
322
+ If you want to create a new default user, `userName` must be `default` and `userId` must not be `default` by using `NoPasswordUser` or `PasswordUser`:
323
+
324
+ ```ts
325
+ // use the original `default` user by using import method
326
+ const defaultUser = elasticache.NoPasswordUser.fromUserAttributes(this, 'DefaultUser', {
327
+ // userId and userName must be 'default'
328
+ userId: 'default',
329
+ });
330
+
331
+ // create a new default user
332
+ const newDefaultUser = new elasticache.NoPasswordUser(this, 'NewDefaultUser', {
333
+ // new default user id must not be 'default'
334
+ userId: 'new-default',
335
+ // new default username must be 'default'
336
+ userName: 'default',
337
+ // set access string
338
+ accessControl: elasticache.AccessControl.fromAccessString("on ~* +@all"),
339
+ });
340
+ ```
341
+
342
+ > NOTE: You can't create a new default user using `IamUser` because an IAM-enabled user's username and user ID cannot be different.
343
+
344
+ ### Add users to the user group
345
+
346
+ Next, use the `UserGroup` construct to create a user group and add users to it.
347
+ Ensure that you include either the original default user or a new default user:
348
+
349
+ ```ts
350
+ declare const newDefaultUser: elasticache.IUser;
351
+ declare const user: elasticache.IUser;
352
+ declare const anotherUser: elasticache.IUser;
353
+
354
+ const userGroup = new elasticache.UserGroup(this, 'UserGroup', {
355
+ // add users including default user
356
+ users: [newDefaultUser, user],
357
+ });
358
+
359
+ // you can also add a user by using addUser method
360
+ userGroup.addUser(anotherUser);
361
+ ```
362
+
363
+ ### Assign user group
364
+
365
+ Finally, assign a user group to cache:
366
+
367
+ ```ts
368
+ declare const vpc: ec2.Vpc;
369
+ declare const userGroup: elasticache.UserGroup;
370
+
371
+ const serverlessCache = new elasticache.ServerlessCache(this, 'ServerlessCache', {
372
+ engine: elasticache.CacheEngine.VALKEY_LATEST,
373
+ serverlessCacheName: 'my-serverless-cache',
374
+ vpc,
375
+ // assign User Group
376
+ userGroup,
377
+ });
378
+
379
+ ```
380
+
381
+ ### Grant permissions to IAM-enabled users
382
+
383
+ If you create IAM-enabled users, `"elasticache:Connect"` action must be allowed for the users and cache.
384
+
385
+ > NOTE: You don't need grant permissions to no password required users or password authentication users.
386
+
387
+ For more information, see [Authenticating with IAM](https://docs.aws.amazon.com/AmazonElastiCache/latest/dg/auth-iam.html).
388
+
389
+ To grant permissions, you can use the `grantConnect` method in `IamUser` and `ServerlessCache` constructs:
390
+
391
+ ```ts
392
+ declare const user: elasticache.IamUser;
393
+ declare const serverlessCache: elasticache.ServerlessCache;
394
+ declare const role: iam.Role;
395
+
396
+ // grant "elasticache:Connect" action permissions to role
397
+ user.grantConnect(role);
398
+ serverlessCache.grantConnect(role);
399
+ ```
400
+
401
+ ### Import an existing user and user group
402
+
403
+ You can import an existing user and user group by using import methods:
404
+
405
+ ```ts
406
+ const stack = new Stack();
407
+
408
+ const importedIamUser = elasticache.IamUser.fromUserId(this, 'ImportedIamUser', 'my-iam-user-id');
409
+
410
+ const importedPasswordUser = elasticache.PasswordUser.fromUserAttributes(stack, 'ImportedPasswordUser', {
411
+ userId: 'my-password-user-id',
412
+ });
413
+
414
+ const importedNoPasswordUser = elasticache.NoPasswordUser.fromUserAttributes(stack, 'ImportedNoPasswordUser', {
415
+ userId: 'my-no-password-user-id',
416
+ });
417
+
418
+ const importedUserGroup = elasticache.UserGroup.fromUserGroupAttributes(this, 'ImportedUserGroup', {
419
+ userGroupName: 'my-user-group-name'
420
+ });
421
+ ```
@@ -1,83 +1,20 @@
1
- # CDK Handler Framework
1
+ # Type definitions copied from 'aws-cdk-lib'
2
2
 
3
- The CDK handler framework is an internal framework used to code generate constructs that extend a lambda `Function`, lambda `SingletonFunction`, or core `CustomResourceProvider` construct and prohibit the user from directly configuring the `handler`, `runtime`, `code`, and `codeDirectory` properties. In doing this, we are able to establish best practices, runtime enforcement, and consistency across all handlers we build and vend within the aws-cdk.
3
+ `aws-cdk-lib` depends on this package; but this package depends on some
4
+ types defined in `aws-cdk-lib`.
4
5
 
5
- ## CDK Handler Framework Concepts
6
+ This cyclic dependency leads to a non-executable build graph. In order to
7
+ break the cycle, we're just copying some types over from `aws-cdk-lib`.
6
8
 
7
- This framework allows for the creation of three component types:
8
- 1. `ComponentType.FUNCTION` - This is a wrapper around the lambda `Function` construct. It offers the same behavior and performance as a lambda `Function`, but it restricts the consumer from configuring the `handler`, `runtime`, and `code` properties.
9
- 2. `ComponentType.SINGLETON_FUNCTION` - This is a wrapper around the lambda `SingletonFunction` construct. It offers the same behavior and performance as a lambda `SingletonFunction`, but it restricts the consumer from configuring the `handler`, `runtime`, and `code` properties.
10
- 3. `ComponentType.CUSTOM_RESOURCE_PROVIDER` - This is a wrapper around the core `CustomResourceProvider` construct. It offers the same behavior and performance as a `CustomResourceProvider` and can be instantiated via the `getOrCreate` or `getOrCreateProvider` methods. This component restricts the consumer from configuring the `runtime` and `codeDirectory` properties.
9
+ I readily admit this is not a great long-term solution, but those types have
10
+ been stable for years and are unlikely to change. The correct solution would
11
+ probably be to externalize them into a separate package, but even the most
12
+ simple solution of that accord would require bundling the types into
13
+ `aws-cdk-lib` with `bundledDependencies` and that requires us writing a
14
+ replacement for `npm pack`, because by default NPM will refuse to bundle
15
+ `bundledDependencies` that have been symlinked into a local workspace (in fact,
16
+ it will silently ignore them).
11
17
 
12
- Code generating one of these three component types requires adding the component properties to the [config](./config.ts) file by providing `ComponentProps`. The `ComponentProps` are responsible for code generating the specified `ComponentType` with the `handler`, `runtime`, `code`, and `codeDirectory` properties set internally. `ComponentProps` includes the following properties:
13
- - `type` - the framework component type to generate.
14
- - `sourceCode` - the source code that will be excuted by the framework component.
15
- - `runtime` - the runtime that is compatible with the framework component's source code. This is an optional property with a default node runtime that will be the latest available node runtime in the `Stack` deployment region. In general, you should not configure this property unless a `runtime` override is absolutely necessary.
16
- - `handler` - the name of the method with the source code that the framework component will call. This is an optional property and the default is `index.handler`.
17
- - `minifyAndBundle` - whether the source code should be minified and bundled. This an optional property and the default is `true`. This should only be set to `false` for python files or for typescript/javascript files with a require import.
18
+ We can build our own replacement for `npm pack`, or we can do a little
19
+ copy/paste. I'm opting for the latter.
18
20
 
19
- The [config](./config.ts) file is structured with the top level mapping to an aws-cdk module, i.e., aws-s3, aws-dynamodb, etc. Each service can contain one or more component modules. Component modules are containers for handler framework components and will be rendered as a code generated file. Each component module can contain one or more `ComponentProps` objects. The following example shows a more structural breakdown of how the [config](./config.ts) file is configured:
20
-
21
- ```ts
22
- const config = {
23
- 'aws-s3': { // the aws-cdk-lib module
24
- 'replica-provider': [ // the component module
25
- // handler framework component defined as a `ComponentProps` object
26
- {
27
- // the handler framework component type
28
- type: ComponentType.FUNCTION,
29
- // the source code that the component will use
30
- sourceCode: path.resolve(__dirname, '..', 'aws-dynamodb', 'replica-handler', 'index.ts'),
31
- // the handler in the source code that the component will execute
32
- handler: 'index.onEventHandler',
33
- },
34
- ],
35
- },
36
- 'aws-stepfunctions-tasks': {
37
- // contains multiple component modules
38
- 'eval-nodejs-provider': [
39
- {
40
- type: ComponentType.SINGLETON_FUNCTION,
41
- sourceCode: path.resolve(__dirname, '..', 'aws-stepfunctions-tasks', 'eval-nodejs-handler', 'index.ts'),
42
- },
43
- ],
44
- 'role-policy-provider': [
45
- {
46
- type: ComponentType.SINGLETON_FUNCTION,
47
- sourceCode: path.resolve(__dirname, '..', 'aws-stepfunctions-tasks', 'role-policy-handler', 'index.py'),
48
- runtime: Runtime.PYTHON_3_9,
49
- // prevent minify and bundle since the source code is a python file
50
- minifyAndBundle: false,
51
- },
52
- ],
53
- },
54
- };
55
- ```
56
-
57
- Code generation for the component modules is triggered when this package - `@aws-cdk/custom-resource-handlers` - is built. Importantly, this framework is also responsible for minifying and bundling the custom resource providers' source code and dependencies. A flag named `minifyAndBundle` can be configured as part of the `ComponentProps` to prevent minifying and bundling the source code for a specific provider. This flag is only needed for python files or for typescript/javascript files containing require imports.
58
-
59
- Once built, all generated code and bundled source code will be written to `@aws-cdk/custom-resource-handlers/dist`. The top level field in the [config](./config.ts) file defining individual aws-cdk modules will be used to create specific directories within `@aws-cdk/custom-resource-handlers/dist` and each component module will be a separate code generated file within these directories named `<component-module>.generated.ts`. As an example, the sample [config](./config.ts) file above would create the following file structure:
60
-
61
- |--- @aws-cdk
62
- | |--- custom-resource-handlers
63
- | | |--- dist
64
- | | | |--- aws-s3
65
- | | | | |--- replica-handler
66
- | | | | | |--- index.js
67
- | | | | |--- replica-provider.generated.ts
68
- | | | |--- aws-stepfunctions-tasks
69
- | | | | |--- eval-nodejs-handler
70
- | | | | | |--- index.js
71
- | | | | |--- role-policy-handler
72
- | | | | | |--- index.py
73
- | | | | |--- eval-nodejs-provider.generated.ts
74
- | | | | |--- role-policy-provider.generated.ts
75
-
76
- The code generated handler framework components are consumable from `aws-cdk-lib/custom-resource-handlers/dist` once `aws-cdk-lib` is built. The file structure of `aws-cdk-lib/custom-resource-handlers/dist` will have the same structure as `@aws-cdk/custom-resource-handlers/dist` with the exception of `core`. To prevent circular dependencies, all handler framework components defined in `core`and any associated source code will be consumable from `aws-cdk-lib/core/dist/core`.
77
-
78
- ## Creating a Handler Framework Component
79
-
80
- Creating a new handler framework component involves three steps:
81
- 1. Add the source code to `@aws-cdk/custom-resource-handlers/lib/<aws-cdk-lib-module>`
82
- 2. Update the [config](./config.ts) file by specifying all required `ComponentProps`.
83
- 3. At this point you can directly build `@aws-cdk/custom-resource-handlers` with `yarn build` to view the generated component in `@aws-cdk/custom-resource-handlers/dist`. Alternatively, you can build `aws-cdk-lib` with `npx lerna run build --scope=aws-cdk-lib --skip-nx-cache` to make the generated component available for use within `aws-cdk-lib`
@@ -597,6 +597,20 @@ new cloudfront.Distribution(this, 'myDist', {
597
597
  });
598
598
  ```
599
599
 
600
+ You can specify the IP address type for connecting to the origin:
601
+
602
+ ```ts
603
+ const origin = new origins.HttpOrigin('www.example.com', {
604
+ ipAddressType: cloudfront.OriginIpAddressType.IPV6, // IPv4, IPv6, or DUALSTACK
605
+ });
606
+
607
+ new cloudfront.Distribution(this, 'Distribution', {
608
+ defaultBehavior: { origin },
609
+ });
610
+ ```
611
+
612
+ The `ipAddressType` property allows you to specify whether CloudFront should use IPv4, IPv6, or both (dual-stack) when connecting to your origin.
613
+
600
614
  The origin can be customized with timeout settings to handle different response scenarios:
601
615
 
602
616
  ```ts
@@ -1,13 +1,16 @@
1
1
  import * as cloudfront from 'aws-cdk-lib/aws-cloudfront';
2
2
  import * as cdk from 'aws-cdk-lib';
3
3
  import * as origins from 'aws-cdk-lib/aws-cloudfront-origins';
4
+ import { IntegTest } from '@aws-cdk/integ-tests-alpha';
4
5
 
5
6
  const app = new cdk.App();
6
7
 
7
8
  const stack = new cdk.Stack(app, 'cloudfront-http-origin');
8
9
 
9
10
  new cloudfront.Distribution(stack, 'Distribution', {
10
- defaultBehavior: { origin: new origins.HttpOrigin('www.example.com') },
11
+ defaultBehavior: { origin: new origins.HttpOrigin('www.example.com', { ipAddressType: cloudfront.OriginIpAddressType.DUALSTACK }) },
11
12
  });
12
13
 
13
- app.synth();
14
+ new IntegTest(app, 'http-origin-test-integ', {
15
+ testCases: [stack],
16
+ });
@@ -2,28 +2,17 @@ import * as cdk from 'aws-cdk-lib';
2
2
  import * as integ from '@aws-cdk/integ-tests-alpha';
3
3
  import * as codedeploy from 'aws-cdk-lib/aws-codedeploy';
4
4
 
5
- const app = new cdk.App({
6
- postCliContext: {
7
- '@aws-cdk/aws-lambda:useCdkManagedLogGroup': false,
8
- },
9
- });
10
- const stack = new cdk.Stack(app, 'aws-cdk-codedeploy-lambda-config');
5
+ const app = new cdk.App();
6
+ const stack = new cdk.Stack(app, 'aws-cdk-codedeploy-ecs-config');
11
7
 
12
- new codedeploy.LambdaDeploymentConfig(stack, 'LinearConfig', {
8
+ new codedeploy.EcsDeploymentConfig(stack, 'LinearConfig', {
13
9
  trafficRouting: codedeploy.TrafficRouting.timeBasedLinear({
14
10
  interval: cdk.Duration.minutes(1),
15
11
  percentage: 5,
16
12
  }),
17
13
  });
18
14
 
19
- new codedeploy.CustomLambdaDeploymentConfig(stack, 'CustomConfig', {
20
- interval: cdk.Duration.minutes(1),
21
- percentage: 5,
22
- type: cdk.aws_codedeploy.CustomLambdaDeploymentConfigType.LINEAR,
23
- deploymentConfigName: 'hello',
24
- });
25
-
26
- new integ.IntegTest(app, 'LambdaDeploymentConfigTest', {
15
+ new integ.IntegTest(app, 'EcsDeploymentConfigTest', {
27
16
  testCases: [stack],
28
17
  });
29
18