konokenj.cdk-api-mcp-server 0.39.0__py3-none-any.whl → 0.41.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.
- cdk_api_mcp_server/__about__.py +1 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/@aws-cdk/custom-resource-handlers/README.md +78 -15
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/README.md/README.md +364 -16
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/README.md +144 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.api-dualstack.ts +4 -3
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.api.ts +4 -2
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.stage.ts +20 -7
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.usage-plan.ts +80 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-authorizers/integ.iam.ts +38 -34
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2-integrations/integ.sqs.ts +71 -58
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-autoscaling/README.md +1 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-config.ts +15 -4
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-codedeploy/integ.deployment-group.ts +40 -218
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/README.md +21 -68
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.availability-zone-rebalancing.ts +4 -14
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.blue-green-deployment-strategy.ts +13 -71
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.enable-execute-command.ts +29 -35
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.exec-command.ts +22 -16
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.lb-awsvpc-nw.ts +16 -26
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-ecs/integ.pseudo-terminal.ts +8 -18
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-lambda/README.md +2 -2
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-route53/integ.delete-existing-record-set.ts +0 -1
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-deployment/integ.bucket-deployment-cross-stack-ssm-source.ts +91 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-s3-notifications/integ.bucket-notifications.ts +80 -42
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-signer/integ.signing-profile.ts +5 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/README.md +9 -3
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke-jsonata.ts +80 -87
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.invoke.ts +69 -87
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-stepfunctions-tasks/integ.start-job-run.ts +104 -102
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/core/README.md +2 -1893
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/FEATURE_FLAGS.md +25 -0
- cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/cx-api/README.md +24 -1
- {konokenj_cdk_api_mcp_server-0.39.0.dist-info → konokenj_cdk_api_mcp_server-0.41.0.dist-info}/METADATA +2 -2
- {konokenj_cdk_api_mcp_server-0.39.0.dist-info → konokenj_cdk_api_mcp_server-0.41.0.dist-info}/RECORD +37 -35
- {konokenj_cdk_api_mcp_server-0.39.0.dist-info → konokenj_cdk_api_mcp_server-0.41.0.dist-info}/WHEEL +0 -0
- {konokenj_cdk_api_mcp_server-0.39.0.dist-info → konokenj_cdk_api_mcp_server-0.41.0.dist-info}/entry_points.txt +0 -0
- {konokenj_cdk_api_mcp_server-0.39.0.dist-info → konokenj_cdk_api_mcp_server-0.41.0.dist-info}/licenses/LICENSE.txt +0 -0
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
- [WebSocket API](#websocket-api)
|
|
19
19
|
- [Manage Connections Permission](#manage-connections-permission)
|
|
20
20
|
- [Managing access to WebSocket APIs](#managing-access-to-websocket-apis)
|
|
21
|
+
- [Usage Plan and API Keys](#usage-plan-and-api-keys)
|
|
21
22
|
|
|
22
23
|
## Introduction
|
|
23
24
|
|
|
@@ -589,3 +590,146 @@ new apigwv2.HttpStage(this, 'Stage', {
|
|
|
589
590
|
detailedMetricsEnabled: true,
|
|
590
591
|
});
|
|
591
592
|
```
|
|
593
|
+
## Usage Plan and API Keys
|
|
594
|
+
|
|
595
|
+
A usage plan specifies who can access one or more deployed WebSocket API stages, and the rate at which they can be accessed. The plan uses API keys to
|
|
596
|
+
identify API clients and meters access to the associated API stages for each key. Usage plans also allow configuring throttling limits and quota limits that are
|
|
597
|
+
enforced on individual client API keys.
|
|
598
|
+
|
|
599
|
+
The following example shows how to create and associate a usage plan and an API key for WebSocket APIs:
|
|
600
|
+
|
|
601
|
+
```ts
|
|
602
|
+
const apiKey = new apigwv2.ApiKey(this, "ApiKey");
|
|
603
|
+
|
|
604
|
+
const usagePlan = new apigwv2.UsagePlan(this, "UsagePlan", {
|
|
605
|
+
usagePlanName: "WebSocketUsagePlan",
|
|
606
|
+
throttle: {
|
|
607
|
+
rateLimit: 10,
|
|
608
|
+
burstLimit: 2
|
|
609
|
+
}
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
usagePlan.addApiKey(apiKey);
|
|
613
|
+
```
|
|
614
|
+
|
|
615
|
+
To associate a plan to a given WebSocketAPI stage:
|
|
616
|
+
|
|
617
|
+
```ts
|
|
618
|
+
const api = new apigwv2.WebSocketApi(this, 'my-api');
|
|
619
|
+
const stage = new apigwv2.WebSocketStage(this, 'my-stage', {
|
|
620
|
+
webSocketApi: api,
|
|
621
|
+
stageName: 'dev',
|
|
622
|
+
});
|
|
623
|
+
|
|
624
|
+
const usagePlan = new apigwv2.UsagePlan(this, 'my-usage-plan', {
|
|
625
|
+
usagePlanName: 'Basic',
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
usagePlan.addApiStage({
|
|
629
|
+
api: api,
|
|
630
|
+
stage: stage,
|
|
631
|
+
});
|
|
632
|
+
```
|
|
633
|
+
Existing usage plans can be imported into a CDK app using its id.
|
|
634
|
+
|
|
635
|
+
```ts
|
|
636
|
+
const usagePlan: apigwv2.IUsagePlan = apigwv2.UsagePlan.fromUsagePlanId(this, 'imported-usage-plan', '<usage-plan-id>');
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
The name and value of the API Key can be specified at creation; if not provided, a name and a value will be automatically generated by API Gateway.
|
|
640
|
+
|
|
641
|
+
```ts
|
|
642
|
+
// Auto-generated name and value
|
|
643
|
+
const autoKey = new apigwv2.ApiKey(this, 'AutoKey');
|
|
644
|
+
|
|
645
|
+
// Explicit name and value
|
|
646
|
+
const explicitKey = new apigwv2.ApiKey(this, 'ExplicitKey', {
|
|
647
|
+
apiKeyName: 'MyWebSocketApiKey',
|
|
648
|
+
value: 'MyApiKeyThatIsAtLeast20Characters',
|
|
649
|
+
});
|
|
650
|
+
```
|
|
651
|
+
|
|
652
|
+
Existing API keys can also be imported into a CDK app using its id.
|
|
653
|
+
|
|
654
|
+
```ts
|
|
655
|
+
const importedKey = apigwv2.ApiKey.fromApiKeyId(this, 'imported-key', '<api-key-id>');
|
|
656
|
+
```
|
|
657
|
+
|
|
658
|
+
The "grant" methods can be used to give prepackaged sets of permissions to other resources. The
|
|
659
|
+
following code provides read permission to an API key.
|
|
660
|
+
|
|
661
|
+
```ts
|
|
662
|
+
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
663
|
+
|
|
664
|
+
const user = new iam.User(this, 'User');
|
|
665
|
+
const apiKey = new apigwv2.ApiKey(this, 'ApiKey', {
|
|
666
|
+
customerId: 'test-customer',
|
|
667
|
+
});
|
|
668
|
+
apiKey.grantRead(user);
|
|
669
|
+
```
|
|
670
|
+
|
|
671
|
+
### Adding an API Key to an imported WebSocketApi
|
|
672
|
+
|
|
673
|
+
API Keys for WebSocket APIs are associated through Usage Plans, not directly to stages. When you import a WebSocketApi, you need to create a Usage Plan that references the
|
|
674
|
+
imported stage and then associate the API key with that Usage Plan.
|
|
675
|
+
|
|
676
|
+
```ts
|
|
677
|
+
declare const webSocketApi: apigwv2.IWebSocketApi;
|
|
678
|
+
|
|
679
|
+
const importedStage = apigwv2.WebSocketStage.fromWebSocketStageAttributes(this, 'imported-stage', {
|
|
680
|
+
stageName: 'myStage',
|
|
681
|
+
api: webSocketApi,
|
|
682
|
+
});
|
|
683
|
+
|
|
684
|
+
const apiKey = new apigwv2.ApiKey(this, 'MyApiKey');
|
|
685
|
+
|
|
686
|
+
const usagePlan = new apigwv2.UsagePlan(this, 'MyUsagePlan', {
|
|
687
|
+
apiStages: [{ api: webSocketApi, stage: importedStage }],
|
|
688
|
+
});
|
|
689
|
+
|
|
690
|
+
usagePlan.addApiKey(apiKey);
|
|
691
|
+
```
|
|
692
|
+
|
|
693
|
+
### Multiple API Keys
|
|
694
|
+
|
|
695
|
+
It is possible to specify multiple API keys for a given Usage Plan, by calling `usagePlan.addApiKey()`.
|
|
696
|
+
|
|
697
|
+
When using multiple API keys, you may need to ensure that the CloudFormation logical ids of the API keys remain consistent across deployments. You can set the logical id as part of the `addApiKey()` method
|
|
698
|
+
|
|
699
|
+
```ts
|
|
700
|
+
declare const usagePlan: apigwv2.UsagePlan;
|
|
701
|
+
declare const apiKey: apigwv2.ApiKey;
|
|
702
|
+
|
|
703
|
+
usagePlan.addApiKey(apiKey, {
|
|
704
|
+
overrideLogicalId: 'MyCustomLogicalId',
|
|
705
|
+
});
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
### Rate Limited API Key
|
|
709
|
+
|
|
710
|
+
In scenarios where you need to create a single api key and configure rate limiting for it, you can use `RateLimitedApiKey`.
|
|
711
|
+
This construct lets you specify rate limiting properties which should be applied only to the api key being created.
|
|
712
|
+
The API key created has the specified rate limits, such as quota and throttles, applied.
|
|
713
|
+
|
|
714
|
+
The following example shows how to use a rate limited api key :
|
|
715
|
+
|
|
716
|
+
```ts
|
|
717
|
+
declare const api: apigwv2.WebSocketApi;
|
|
718
|
+
declare const stage: apigwv2.WebSocketStage;
|
|
719
|
+
|
|
720
|
+
const key = new apigwv2.RateLimitedApiKey(this, 'rate-limited-api-key', {
|
|
721
|
+
customerId: 'test-customer',
|
|
722
|
+
apiStages: [{
|
|
723
|
+
api: api,
|
|
724
|
+
stage: stage
|
|
725
|
+
}],
|
|
726
|
+
quota: {
|
|
727
|
+
limit: 10000,
|
|
728
|
+
period: apigwv2.Period.MONTH
|
|
729
|
+
},
|
|
730
|
+
throttle: {
|
|
731
|
+
rateLimit: 100,
|
|
732
|
+
burstLimit: 200
|
|
733
|
+
}
|
|
734
|
+
});
|
|
735
|
+
```
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.api-dualstack.ts
CHANGED
|
@@ -4,13 +4,14 @@ import * as cdk from 'aws-cdk-lib';
|
|
|
4
4
|
import * as apigw from 'aws-cdk-lib/aws-apigatewayv2';
|
|
5
5
|
|
|
6
6
|
const app = new cdk.App();
|
|
7
|
-
const stack = new cdk.Stack(app, '
|
|
7
|
+
const stack = new cdk.Stack(app, 'DualStackHttpApiStack');
|
|
8
8
|
|
|
9
|
-
new apigw.
|
|
9
|
+
new apigw.HttpApi(stack, 'HttpApi', {
|
|
10
|
+
routeSelectionExpression: true,
|
|
10
11
|
ipAddressType: apigw.IpAddressType.DUAL_STACK,
|
|
11
12
|
});
|
|
12
13
|
|
|
13
|
-
new IntegTest(app, '
|
|
14
|
+
new IntegTest(app, 'DualStackHttpApiInteg', {
|
|
14
15
|
testCases: [stack],
|
|
15
16
|
});
|
|
16
17
|
|
|
@@ -6,9 +6,11 @@ import * as apigw from 'aws-cdk-lib/aws-apigatewayv2';
|
|
|
6
6
|
const app = new cdk.App();
|
|
7
7
|
const stack = new cdk.Stack(app, 'aws-cdk-aws-apigatewayv2');
|
|
8
8
|
|
|
9
|
-
new apigw.
|
|
9
|
+
new apigw.HttpApi(stack, 'HttpApi', {
|
|
10
|
+
routeSelectionExpression: true,
|
|
11
|
+
});
|
|
10
12
|
|
|
11
|
-
new IntegTest(app, '
|
|
13
|
+
new IntegTest(app, 'http-api', {
|
|
12
14
|
testCases: [stack],
|
|
13
15
|
});
|
|
14
16
|
|
|
@@ -1,20 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
|
|
2
3
|
import * as cdk from 'aws-cdk-lib';
|
|
3
|
-
import * as
|
|
4
|
+
import * as apigwv2 from 'aws-cdk-lib/aws-apigatewayv2';
|
|
5
|
+
import * as apigw from 'aws-cdk-lib/aws-apigateway';
|
|
6
|
+
import * as logs from 'aws-cdk-lib/aws-logs';
|
|
4
7
|
|
|
5
8
|
const app = new cdk.App();
|
|
6
|
-
const stack = new cdk.Stack(app, 'aws-cdk-aws-apigatewayv2-
|
|
9
|
+
const stack = new cdk.Stack(app, 'aws-cdk-aws-apigatewayv2-http-stage');
|
|
7
10
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const testLogGroup = new logs.LogGroup(stack, 'MyLogGroup');
|
|
12
|
+
|
|
13
|
+
const httpApi = new apigwv2.HttpApi(stack, 'HttpApi', { createDefaultStage: false });
|
|
14
|
+
new apigwv2.HttpStage(stack, 'HttpStageWithProperties', {
|
|
15
|
+
httpApi,
|
|
12
16
|
throttle: {
|
|
13
17
|
rateLimit: 1000,
|
|
14
18
|
burstLimit: 1000,
|
|
15
19
|
},
|
|
16
20
|
detailedMetricsEnabled: true,
|
|
17
21
|
description: 'My Stage',
|
|
22
|
+
accessLogSettings: {
|
|
23
|
+
destination: new apigwv2.LogGroupLogDestination(testLogGroup),
|
|
24
|
+
format: apigw.AccessLogFormat.custom(JSON.stringify({
|
|
25
|
+
extendedRequestId: apigw.AccessLogField.contextExtendedRequestId(),
|
|
26
|
+
requestTime: apigw.AccessLogField.contextRequestTime(),
|
|
27
|
+
})),
|
|
28
|
+
},
|
|
18
29
|
});
|
|
19
30
|
|
|
20
|
-
app
|
|
31
|
+
new IntegTest(app, 'aws-cdk-aws-apigatewayv2-http-stage-test', {
|
|
32
|
+
testCases: [stack],
|
|
33
|
+
});
|
cdk_api_mcp_server/resources/aws-cdk/constructs/aws-cdk-lib/aws-apigatewayv2/integ.usage-plan.ts
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
2
|
+
import * as cdk from 'aws-cdk-lib';
|
|
3
|
+
import { WebSocketApi, WebSocketStage, UsagePlan, ApiKey, RateLimitedApiKey, Period } from 'aws-cdk-lib/aws-apigatewayv2';
|
|
4
|
+
|
|
5
|
+
const app = new cdk.App();
|
|
6
|
+
|
|
7
|
+
const stack = new cdk.Stack(app, 'aws-cdk-aws-apigatewayv2-websocket-usage-plan');
|
|
8
|
+
|
|
9
|
+
const webSocketApi = new WebSocketApi(stack, 'WebSocketApi');
|
|
10
|
+
|
|
11
|
+
const webSocketStage = new WebSocketStage(stack, 'WebSocketStage', {
|
|
12
|
+
webSocketApi,
|
|
13
|
+
stageName: 'dev',
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const apiKey = new ApiKey(stack, 'ApiKey', {
|
|
17
|
+
apiKeyName: 'my-api-key',
|
|
18
|
+
value: 'MyApiKeyThatIsAtLeast20Characters',
|
|
19
|
+
description: 'Basic api-key',
|
|
20
|
+
customerId: 'my-customer',
|
|
21
|
+
enabled: true,
|
|
22
|
+
generateDistinctId: true,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const usagePlan = new UsagePlan(stack, 'UsagePlan', {
|
|
26
|
+
apiStages: [{
|
|
27
|
+
api: webSocketApi,
|
|
28
|
+
stage: webSocketStage,
|
|
29
|
+
}],
|
|
30
|
+
description: 'Basic usage plan',
|
|
31
|
+
quota: {
|
|
32
|
+
limit: 10000,
|
|
33
|
+
offset: 1,
|
|
34
|
+
period: Period.MONTH,
|
|
35
|
+
},
|
|
36
|
+
throttle: {
|
|
37
|
+
rateLimit: 100,
|
|
38
|
+
burstLimit: 200,
|
|
39
|
+
},
|
|
40
|
+
usagePlanName: 'WebSocketUsagePlan',
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
const webSocketStage2 = new WebSocketStage(stack, 'WebSocketStage2', {
|
|
44
|
+
webSocketApi,
|
|
45
|
+
stageName: 'dev2',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
usagePlan.addApiKey(apiKey);
|
|
49
|
+
usagePlan.addApiStage({ api: webSocketApi, stage: webSocketStage2 });
|
|
50
|
+
|
|
51
|
+
const webSocketStage3 = new WebSocketStage(stack, 'WebSocketStage3', {
|
|
52
|
+
webSocketApi,
|
|
53
|
+
stageName: 'dev3',
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
new RateLimitedApiKey(stack, 'RateLimitedApiKey', {
|
|
57
|
+
apiKeyName: 'my-rate-limited-api-key',
|
|
58
|
+
value: 'MyRateLimitedApiKeyThatIsAtLeast20Characters',
|
|
59
|
+
description: 'Basic rate-limited-api-key',
|
|
60
|
+
customerId: 'my-customer',
|
|
61
|
+
enabled: true,
|
|
62
|
+
generateDistinctId: true,
|
|
63
|
+
apiStages: [{
|
|
64
|
+
api: webSocketApi,
|
|
65
|
+
stage: webSocketStage3,
|
|
66
|
+
}],
|
|
67
|
+
quota: {
|
|
68
|
+
limit: 10000,
|
|
69
|
+
offset: 1,
|
|
70
|
+
period: Period.MONTH,
|
|
71
|
+
},
|
|
72
|
+
throttle: {
|
|
73
|
+
rateLimit: 100,
|
|
74
|
+
burstLimit: 200,
|
|
75
|
+
},
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
new integ.IntegTest(app, 'WebSocketUsagePlanInteg', {
|
|
79
|
+
testCases: [stack],
|
|
80
|
+
});
|
|
@@ -1,53 +1,46 @@
|
|
|
1
1
|
import * as apigatewayv2 from 'aws-cdk-lib/aws-apigatewayv2';
|
|
2
|
-
import { WebSocketLambdaIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
3
2
|
import * as iam from 'aws-cdk-lib/aws-iam';
|
|
4
|
-
import { Code, Function, Runtime } from 'aws-cdk-lib/aws-lambda';
|
|
5
3
|
import * as cdk from 'aws-cdk-lib';
|
|
6
|
-
import {
|
|
7
|
-
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
8
|
-
import { WebSocketIamAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
|
|
4
|
+
import { HttpIamAuthorizer } from 'aws-cdk-lib/aws-apigatewayv2-authorizers';
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
class ExampleComIntegration extends apigatewayv2.HttpRouteIntegration {
|
|
7
|
+
public bind(): apigatewayv2.HttpRouteIntegrationConfig {
|
|
8
|
+
return {
|
|
9
|
+
type: apigatewayv2.HttpIntegrationType.HTTP_PROXY,
|
|
10
|
+
payloadFormatVersion: apigatewayv2.PayloadFormatVersion.VERSION_1_0,
|
|
11
|
+
method: apigatewayv2.HttpMethod.GET,
|
|
12
|
+
uri: 'https://www.example.com/',
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const app = new cdk.App();
|
|
15
18
|
const stack = new cdk.Stack(app, 'IntegApiGatewayV2Iam');
|
|
16
19
|
const user = new iam.User(stack, 'User');
|
|
17
20
|
const userAccessKey = new iam.AccessKey(stack, 'UserAccess', {
|
|
18
21
|
user,
|
|
19
22
|
});
|
|
20
23
|
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
code: Code.fromInline('exports.handler = () => {return true}'),
|
|
24
|
-
handler: 'index.handler',
|
|
24
|
+
const httpApi = new apigatewayv2.HttpApi(stack, 'HttpApi', {
|
|
25
|
+
defaultAuthorizer: new HttpIamAuthorizer(),
|
|
25
26
|
});
|
|
26
27
|
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
authorizer: new WebSocketIamAuthorizer(),
|
|
31
|
-
},
|
|
28
|
+
const [fooRoute] = httpApi.addRoutes({
|
|
29
|
+
integration: new ExampleComIntegration('examplecom'),
|
|
30
|
+
path: '/foo',
|
|
32
31
|
});
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
fooRoute.grantInvoke(user);
|
|
34
|
+
|
|
35
|
+
const [booksRoute] = httpApi.addRoutes({
|
|
36
|
+
integration: new ExampleComIntegration('examplecom'),
|
|
37
|
+
path: '/books/{book}',
|
|
37
38
|
});
|
|
38
39
|
|
|
39
|
-
|
|
40
|
-
statements: [
|
|
41
|
-
new iam.PolicyStatement({
|
|
42
|
-
actions: ['execute-api:Invoke'],
|
|
43
|
-
effect: iam.Effect.ALLOW,
|
|
44
|
-
resources: [arn],
|
|
45
|
-
}),
|
|
46
|
-
],
|
|
47
|
-
}));
|
|
40
|
+
booksRoute.grantInvoke(user);
|
|
48
41
|
|
|
49
|
-
new
|
|
50
|
-
|
|
42
|
+
new cdk.CfnOutput(stack, 'API', {
|
|
43
|
+
value: httpApi.url!,
|
|
51
44
|
});
|
|
52
45
|
|
|
53
46
|
new cdk.CfnOutput(stack, 'TESTACCESSKEYID', {
|
|
@@ -62,4 +55,15 @@ new cdk.CfnOutput(stack, 'TESTREGION', {
|
|
|
62
55
|
value: stack.region,
|
|
63
56
|
});
|
|
64
57
|
|
|
65
|
-
|
|
58
|
+
/*
|
|
59
|
+
* Stack verification steps:
|
|
60
|
+
* * Get cURL version 7.75.0 or later so you can use the --aws-sigv4 option
|
|
61
|
+
* * Curl <url>/foo without sigv4 and expect a 403
|
|
62
|
+
* * Curl <url>/books/something without sigv4 and expect a 403
|
|
63
|
+
* * Curl <url>/foo with sigv4 from the authorized user and expect 200
|
|
64
|
+
* * Curl <url>/books/something with sigv4 from the authorized user and expect 200
|
|
65
|
+
*
|
|
66
|
+
* Reference:
|
|
67
|
+
* * Using cURL 7.75.0 or later via the official docker image: docker run --rm curlimages/curl -s -o/dev/null -w"%{http_code}" <url>
|
|
68
|
+
* * Args to enable sigv4 with authorized credentials: --user "$TESTACCESSKEYID:$TESTSECRETACCESSKEY" --aws-sigv4 "aws:amz:$TESTREGION:execute-api"
|
|
69
|
+
*/
|
|
@@ -1,72 +1,85 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as apigwv2 from 'aws-cdk-lib/aws-apigatewayv2';
|
|
2
2
|
import * as sqs from 'aws-cdk-lib/aws-sqs';
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
6
|
-
import { IntegTest } from '@aws-cdk/integ-tests-alpha';
|
|
7
|
-
|
|
8
|
-
/*
|
|
9
|
-
* Stack verification steps:
|
|
10
|
-
* 1. Verify manually that the integration has type "AWS"
|
|
11
|
-
*/
|
|
3
|
+
import { App, Stack } from 'aws-cdk-lib';
|
|
4
|
+
import { HttpSqsIntegration } from 'aws-cdk-lib/aws-apigatewayv2-integrations';
|
|
5
|
+
import * as integ from '@aws-cdk/integ-tests-alpha';
|
|
12
6
|
|
|
13
7
|
const app = new App();
|
|
14
|
-
const stack = new Stack(app, '
|
|
8
|
+
const stack = new Stack(app, 'sqs-integration');
|
|
15
9
|
|
|
16
|
-
const
|
|
17
|
-
fifo: true,
|
|
18
|
-
queueName: 'MessageSQSQueue.fifo',
|
|
19
|
-
});
|
|
10
|
+
const queue = new sqs.Queue(stack, 'Queue');
|
|
20
11
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
12
|
+
const httpApi = new apigwv2.HttpApi(stack, 'Api');
|
|
13
|
+
httpApi.addRoutes({
|
|
14
|
+
path: '/default',
|
|
15
|
+
methods: [apigwv2.HttpMethod.POST],
|
|
16
|
+
integration: new HttpSqsIntegration('defaultIntegration', {
|
|
17
|
+
queue,
|
|
18
|
+
}),
|
|
25
19
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
20
|
+
httpApi.addRoutes({
|
|
21
|
+
path: '/send-message',
|
|
22
|
+
methods: [apigwv2.HttpMethod.POST],
|
|
23
|
+
integration: new HttpSqsIntegration('sendMessageIntegration', {
|
|
24
|
+
queue,
|
|
25
|
+
subtype: apigwv2.HttpIntegrationSubtype.SQS_SEND_MESSAGE,
|
|
26
|
+
}),
|
|
32
27
|
});
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
httpApi.addRoutes({
|
|
29
|
+
path: '/receive-message',
|
|
30
|
+
methods: [apigwv2.HttpMethod.POST],
|
|
31
|
+
integration: new HttpSqsIntegration('receiveMessageIntegration', {
|
|
32
|
+
queue,
|
|
33
|
+
subtype: apigwv2.HttpIntegrationSubtype.SQS_RECEIVE_MESSAGE,
|
|
34
|
+
}),
|
|
37
35
|
});
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
httpApi.addRoutes({
|
|
37
|
+
path: '/delete-message',
|
|
38
|
+
methods: [apigwv2.HttpMethod.POST],
|
|
39
|
+
integration: new HttpSqsIntegration('deleteMessageIntegration', {
|
|
40
|
+
queue,
|
|
41
|
+
subtype: apigwv2.HttpIntegrationSubtype.SQS_DELETE_MESSAGE,
|
|
44
42
|
}),
|
|
45
|
-
);
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
passthroughBehavior: PassthroughBehavior.NEVER,
|
|
53
|
-
templateSelectionExpression: '\\$default',
|
|
54
|
-
requestTemplates: {
|
|
55
|
-
$default: 'Action=SendMessage&MessageGroupId=$input.path(\'$.MessageGroupId\')&MessageDeduplicationId=$context.requestId&MessageAttribute.1.Name=connectionId&MessageAttribute.1.Value.StringValue=$context.connectionId&MessageAttribute.1.Value.DataType=String&MessageAttribute.2.Name=requestId&MessageAttribute.2.Value.StringValue=$context.requestId&MessageAttribute.2.Value.DataType=String&MessageBody=$input.json(\'$\')',
|
|
56
|
-
},
|
|
57
|
-
requestParameters: {
|
|
58
|
-
'integration.request.header.Content-Type': '\'application/x-www-form-urlencoded\'',
|
|
59
|
-
},
|
|
43
|
+
});
|
|
44
|
+
httpApi.addRoutes({
|
|
45
|
+
path: '/purge-queue',
|
|
46
|
+
methods: [apigwv2.HttpMethod.POST],
|
|
47
|
+
integration: new HttpSqsIntegration('purgeQueueIntegration', {
|
|
48
|
+
queue,
|
|
49
|
+
subtype: apigwv2.HttpIntegrationSubtype.SQS_PURGE_QUEUE,
|
|
60
50
|
}),
|
|
61
51
|
});
|
|
62
52
|
|
|
63
|
-
new IntegTest(app, '
|
|
53
|
+
const integTest = new integ.IntegTest(app, 'SqsIntegrationIntegTest', {
|
|
64
54
|
testCases: [stack],
|
|
65
|
-
cdkCommandOptions: {
|
|
66
|
-
deploy: {
|
|
67
|
-
args: {
|
|
68
|
-
rollback: true,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
55
|
});
|
|
56
|
+
|
|
57
|
+
const defaultAssertion = integTest.assertions.httpApiCall(
|
|
58
|
+
`${httpApi.apiEndpoint}/default`, {
|
|
59
|
+
body: JSON.stringify({ MessageBody: 'Hello World!' }),
|
|
60
|
+
method: 'POST',
|
|
61
|
+
},
|
|
62
|
+
);
|
|
63
|
+
defaultAssertion.expect(integ.ExpectedResult.objectLike({ status: 200, statusText: 'OK' }));
|
|
64
|
+
|
|
65
|
+
const sendMessageAssertion = integTest.assertions.httpApiCall(
|
|
66
|
+
`${httpApi.apiEndpoint}/send-message`, {
|
|
67
|
+
body: JSON.stringify({ MessageBody: 'Hello World!' }),
|
|
68
|
+
method: 'POST',
|
|
69
|
+
},
|
|
70
|
+
);
|
|
71
|
+
sendMessageAssertion.expect(integ.ExpectedResult.objectLike({ status: 200, statusText: 'OK' }));
|
|
72
|
+
|
|
73
|
+
const receiveMessageAssertion = integTest.assertions.httpApiCall(
|
|
74
|
+
`${httpApi.apiEndpoint}/receive-message`, {
|
|
75
|
+
method: 'POST',
|
|
76
|
+
},
|
|
77
|
+
);
|
|
78
|
+
receiveMessageAssertion.expect(integ.ExpectedResult.objectLike({ status: 200, statusText: 'OK' }));
|
|
79
|
+
|
|
80
|
+
const purgeQueueAssertion = integTest.assertions.httpApiCall(
|
|
81
|
+
`${httpApi.apiEndpoint}/purge-queue`, {
|
|
82
|
+
method: 'POST',
|
|
83
|
+
},
|
|
84
|
+
);
|
|
85
|
+
purgeQueueAssertion.expect(integ.ExpectedResult.objectLike({ status: 200, statusText: 'OK' }));
|
|
@@ -531,7 +531,7 @@ about allowing connections between resources backed by instances.
|
|
|
531
531
|
## Max Instance Lifetime
|
|
532
532
|
|
|
533
533
|
To enable the max instance lifetime support, specify `maxInstanceLifetime` property
|
|
534
|
-
for the `AutoscalingGroup` resource. The value must be between
|
|
534
|
+
for the `AutoscalingGroup` resource. The value must be between 1 and 365 days(inclusive).
|
|
535
535
|
To clear a previously set value, leave this property undefined.
|
|
536
536
|
|
|
537
537
|
## Instance Monitoring
|
|
@@ -2,17 +2,28 @@ 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
|
-
|
|
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');
|
|
7
11
|
|
|
8
|
-
new codedeploy.
|
|
12
|
+
new codedeploy.LambdaDeploymentConfig(stack, 'LinearConfig', {
|
|
9
13
|
trafficRouting: codedeploy.TrafficRouting.timeBasedLinear({
|
|
10
14
|
interval: cdk.Duration.minutes(1),
|
|
11
15
|
percentage: 5,
|
|
12
16
|
}),
|
|
13
17
|
});
|
|
14
18
|
|
|
15
|
-
new
|
|
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', {
|
|
16
27
|
testCases: [stack],
|
|
17
28
|
});
|
|
18
29
|
|