aws-cdk-lib 2.114.0__py3-none-any.whl → 2.115.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.
Potentially problematic release.
This version of aws-cdk-lib might be problematic. Click here for more details.
- aws_cdk/__init__.py +7 -1
- aws_cdk/_jsii/__init__.py +1 -1
- aws_cdk/_jsii/{aws-cdk-lib@2.114.0.jsii.tgz → aws-cdk-lib@2.115.0.jsii.tgz} +0 -0
- aws_cdk/aws_apigateway/__init__.py +6 -0
- aws_cdk/aws_apigatewayv2/__init__.py +223 -574
- aws_cdk/aws_autoscaling/__init__.py +99 -86
- aws_cdk/aws_bedrock/__init__.py +355 -0
- aws_cdk/aws_billingconductor/__init__.py +41 -0
- aws_cdk/aws_cleanrooms/__init__.py +46 -20
- aws_cdk/aws_cloudformation/__init__.py +5 -1
- aws_cdk/aws_cloudtrail/__init__.py +89 -0
- aws_cdk/aws_codedeploy/__init__.py +233 -1
- aws_cdk/aws_connect/__init__.py +49 -2
- aws_cdk/aws_dlm/__init__.py +8 -11
- aws_cdk/aws_dms/__init__.py +3861 -1643
- aws_cdk/aws_ec2/__init__.py +91 -47
- aws_cdk/aws_ecs/__init__.py +18 -0
- aws_cdk/aws_efs/__init__.py +1 -1
- aws_cdk/aws_eks/__init__.py +26 -13
- aws_cdk/aws_elasticloadbalancingv2/__init__.py +110 -54
- aws_cdk/aws_emr/__init__.py +287 -18
- aws_cdk/aws_eventschemas/__init__.py +1 -1
- aws_cdk/aws_fis/__init__.py +466 -34
- aws_cdk/aws_iam/__init__.py +47 -35
- aws_cdk/aws_internetmonitor/__init__.py +10 -12
- aws_cdk/aws_lightsail/__init__.py +4 -2
- aws_cdk/aws_logs/__init__.py +5 -4
- aws_cdk/aws_opensearchservice/__init__.py +47 -0
- aws_cdk/aws_osis/__init__.py +272 -32
- aws_cdk/aws_rds/__init__.py +205 -87
- aws_cdk/aws_resiliencehub/__init__.py +9 -14
- aws_cdk/aws_rolesanywhere/__init__.py +41 -53
- aws_cdk/aws_route53/__init__.py +3 -3
- aws_cdk/aws_route53_targets/__init__.py +2 -2
- aws_cdk/aws_s3/__init__.py +2 -6
- aws_cdk/aws_s3express/__init__.py +3 -3
- aws_cdk/aws_sagemaker/__init__.py +82 -11
- aws_cdk/aws_sns/__init__.py +181 -0
- aws_cdk/aws_stepfunctions/__init__.py +16 -8
- aws_cdk/aws_stepfunctions_tasks/__init__.py +975 -139
- aws_cdk/aws_workspacesthinclient/__init__.py +44 -35
- {aws_cdk_lib-2.114.0.dist-info → aws_cdk_lib-2.115.0.dist-info}/METADATA +2 -2
- {aws_cdk_lib-2.114.0.dist-info → aws_cdk_lib-2.115.0.dist-info}/RECORD +47 -46
- {aws_cdk_lib-2.114.0.dist-info → aws_cdk_lib-2.115.0.dist-info}/LICENSE +0 -0
- {aws_cdk_lib-2.114.0.dist-info → aws_cdk_lib-2.115.0.dist-info}/NOTICE +0 -0
- {aws_cdk_lib-2.114.0.dist-info → aws_cdk_lib-2.115.0.dist-info}/WHEEL +0 -0
- {aws_cdk_lib-2.114.0.dist-info → aws_cdk_lib-2.115.0.dist-info}/top_level.txt +0 -0
|
@@ -1,451 +1,34 @@
|
|
|
1
1
|
'''
|
|
2
|
-
# AWS::
|
|
2
|
+
# AWS::ApiGatewayV2 Construct Library
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
* [Introduction](#introduction)
|
|
7
|
-
* [HTTP API](#http-api)
|
|
8
|
-
|
|
9
|
-
* [Defining HTTP APIs](#defining-http-apis)
|
|
10
|
-
* [Cross Origin Resource Sharing (CORS)](#cross-origin-resource-sharing-cors)
|
|
11
|
-
* [Publishing HTTP APIs](#publishing-http-apis)
|
|
12
|
-
* [Custom Domain](#custom-domain)
|
|
13
|
-
* [Mutual TLS](#mutual-tls-mtls)
|
|
14
|
-
* [Managing access to HTTP APIs](#managing-access-to-http-apis)
|
|
15
|
-
* [Metrics](#metrics)
|
|
16
|
-
* [VPC Link](#vpc-link)
|
|
17
|
-
* [Private Integration](#private-integration)
|
|
18
|
-
* [WebSocket API](#websocket-api)
|
|
19
|
-
|
|
20
|
-
* [Manage Connections Permission](#manage-connections-permission)
|
|
21
|
-
* [Managing access to WebSocket APIs](#managing-access-to-websocket-apis)
|
|
22
|
-
|
|
23
|
-
## Introduction
|
|
24
|
-
|
|
25
|
-
Amazon API Gateway is an AWS service for creating, publishing, maintaining, monitoring, and securing REST, HTTP, and WebSocket
|
|
26
|
-
APIs at any scale. API developers can create APIs that access AWS or other web services, as well as data stored in the AWS Cloud.
|
|
27
|
-
As an API Gateway API developer, you can create APIs for use in your own client applications. Read the
|
|
28
|
-
[Amazon API Gateway Developer Guide](https://docs.aws.amazon.com/apigateway/latest/developerguide/welcome.html).
|
|
29
|
-
|
|
30
|
-
This module supports features under [API Gateway v2](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGatewayV2.html)
|
|
31
|
-
that lets users set up Websocket and HTTP APIs.
|
|
32
|
-
REST APIs can be created using the `aws-cdk-lib/aws-apigateway` module.
|
|
33
|
-
|
|
34
|
-
## HTTP API
|
|
35
|
-
|
|
36
|
-
HTTP APIs enable creation of RESTful APIs that integrate with AWS Lambda functions, known as Lambda proxy integration,
|
|
37
|
-
or to any routable HTTP endpoint, known as HTTP proxy integration.
|
|
38
|
-
|
|
39
|
-
### Defining HTTP APIs
|
|
40
|
-
|
|
41
|
-
HTTP APIs have two fundamental concepts - Routes and Integrations.
|
|
42
|
-
|
|
43
|
-
Routes direct incoming API requests to backend resources. Routes consist of two parts: an HTTP method and a resource
|
|
44
|
-
path, such as, `GET /books`. Learn more at [Working with
|
|
45
|
-
routes](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-routes.html). Use the `ANY` method
|
|
46
|
-
to match any methods for a route that are not explicitly defined.
|
|
47
|
-
|
|
48
|
-
Integrations define how the HTTP API responds when a client reaches a specific Route. HTTP APIs support Lambda proxy
|
|
49
|
-
integration, HTTP proxy integration and, AWS service integrations, also known as private integrations. Learn more at
|
|
50
|
-
[Configuring integrations](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-develop-integrations.html).
|
|
51
|
-
|
|
52
|
-
Integrations are available at the `aws-apigatewayv2-integrations` module and more information is available in that module.
|
|
53
|
-
As an early example, the following code snippet configures a route `GET /books` with an HTTP proxy integration all
|
|
54
|
-
configures all other HTTP method calls to `/books` to a lambda proxy.
|
|
55
|
-
|
|
56
|
-
```python
|
|
57
|
-
from aws_cdk.aws_apigatewayv2_integrations import HttpUrlIntegration, HttpLambdaIntegration
|
|
58
|
-
|
|
59
|
-
# books_default_fn: lambda.Function
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
get_books_integration = HttpUrlIntegration("GetBooksIntegration", "https://get-books-proxy.example.com")
|
|
63
|
-
books_default_integration = HttpLambdaIntegration("BooksIntegration", books_default_fn)
|
|
64
|
-
|
|
65
|
-
http_api = apigwv2.HttpApi(self, "HttpApi")
|
|
66
|
-
|
|
67
|
-
http_api.add_routes(
|
|
68
|
-
path="/books",
|
|
69
|
-
methods=[apigwv2.HttpMethod.GET],
|
|
70
|
-
integration=get_books_integration
|
|
71
|
-
)
|
|
72
|
-
http_api.add_routes(
|
|
73
|
-
path="/books",
|
|
74
|
-
methods=[apigwv2.HttpMethod.ANY],
|
|
75
|
-
integration=books_default_integration
|
|
76
|
-
)
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
The URL to the endpoint can be retrieved via the `apiEndpoint` attribute. By default this URL is enabled for clients. Use `disableExecuteApiEndpoint` to disable it.
|
|
80
|
-
|
|
81
|
-
```python
|
|
82
|
-
http_api = apigwv2.HttpApi(self, "HttpApi",
|
|
83
|
-
disable_execute_api_endpoint=True
|
|
84
|
-
)
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
The `defaultIntegration` option while defining HTTP APIs lets you create a default catch-all integration that is
|
|
88
|
-
matched when a client reaches a route that is not explicitly defined.
|
|
89
|
-
|
|
90
|
-
```python
|
|
91
|
-
from aws_cdk.aws_apigatewayv2_integrations import HttpUrlIntegration
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
apigwv2.HttpApi(self, "HttpProxyApi",
|
|
95
|
-
default_integration=HttpUrlIntegration("DefaultIntegration", "https://example.com")
|
|
96
|
-
)
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### Cross Origin Resource Sharing (CORS)
|
|
100
|
-
|
|
101
|
-
[Cross-origin resource sharing (CORS)](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) is a browser security
|
|
102
|
-
feature that restricts HTTP requests that are initiated from scripts running in the browser. Enabling CORS will allow
|
|
103
|
-
requests to your API from a web application hosted in a domain different from your API domain.
|
|
104
|
-
|
|
105
|
-
When configured CORS for an HTTP API, API Gateway automatically sends a response to preflight `OPTIONS` requests, even
|
|
106
|
-
if there isn't an `OPTIONS` route configured. Note that, when this option is used, API Gateway will ignore CORS headers
|
|
107
|
-
returned from your backend integration. Learn more about [Configuring CORS for an HTTP
|
|
108
|
-
API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-cors.html).
|
|
109
|
-
|
|
110
|
-
The `corsPreflight` option lets you specify a CORS configuration for an API.
|
|
111
|
-
|
|
112
|
-
```python
|
|
113
|
-
apigwv2.HttpApi(self, "HttpProxyApi",
|
|
114
|
-
cors_preflight=apigwv2.CorsPreflightOptions(
|
|
115
|
-
allow_headers=["Authorization"],
|
|
116
|
-
allow_methods=[apigwv2.CorsHttpMethod.GET, apigwv2.CorsHttpMethod.HEAD, apigwv2.CorsHttpMethod.OPTIONS, apigwv2.CorsHttpMethod.POST
|
|
117
|
-
],
|
|
118
|
-
allow_origins=["*"],
|
|
119
|
-
max_age=Duration.days(10)
|
|
120
|
-
)
|
|
121
|
-
)
|
|
122
|
-
```
|
|
123
|
-
|
|
124
|
-
### Publishing HTTP APIs
|
|
125
|
-
|
|
126
|
-
A Stage is a logical reference to a lifecycle state of your API (for example, `dev`, `prod`, `beta`, or `v2`). API
|
|
127
|
-
stages are identified by their stage name. Each stage is a named reference to a deployment of the API made available for
|
|
128
|
-
client applications to call.
|
|
129
|
-
|
|
130
|
-
Use `HttpStage` to create a Stage resource for HTTP APIs. The following code sets up a Stage, whose URL is available at
|
|
131
|
-
`https://{api_id}.execute-api.{region}.amazonaws.com/beta`.
|
|
132
|
-
|
|
133
|
-
```python
|
|
134
|
-
# api: apigwv2.HttpApi
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
apigwv2.HttpStage(self, "Stage",
|
|
138
|
-
http_api=api,
|
|
139
|
-
stage_name="beta"
|
|
140
|
-
)
|
|
141
|
-
```
|
|
142
|
-
|
|
143
|
-
If you omit the `stageName` will create a `$default` stage. A `$default` stage is one that is served from the base of
|
|
144
|
-
the API's URL - `https://{api_id}.execute-api.{region}.amazonaws.com/`.
|
|
145
|
-
|
|
146
|
-
Note that, `HttpApi` will always creates a `$default` stage, unless the `createDefaultStage` property is unset.
|
|
147
|
-
|
|
148
|
-
### Custom Domain
|
|
149
|
-
|
|
150
|
-
Custom domain names are simpler and more intuitive URLs that you can provide to your API users. Custom domain name are associated to API stages.
|
|
151
|
-
|
|
152
|
-
The code snippet below creates a custom domain and configures a default domain mapping for your API that maps the
|
|
153
|
-
custom domain to the `$default` stage of the API.
|
|
154
|
-
|
|
155
|
-
```python
|
|
156
|
-
import aws_cdk.aws_certificatemanager as acm
|
|
157
|
-
from aws_cdk.aws_apigatewayv2_integrations import HttpLambdaIntegration
|
|
158
|
-
|
|
159
|
-
# handler: lambda.Function
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
cert_arn = "arn:aws:acm:us-east-1:111111111111:certificate"
|
|
163
|
-
domain_name = "example.com"
|
|
164
|
-
|
|
165
|
-
dn = apigwv2.DomainName(self, "DN",
|
|
166
|
-
domain_name=domain_name,
|
|
167
|
-
certificate=acm.Certificate.from_certificate_arn(self, "cert", cert_arn)
|
|
168
|
-
)
|
|
169
|
-
api = apigwv2.HttpApi(self, "HttpProxyProdApi",
|
|
170
|
-
default_integration=HttpLambdaIntegration("DefaultIntegration", handler),
|
|
171
|
-
# https://${dn.domainName}/foo goes to prodApi $default stage
|
|
172
|
-
default_domain_mapping=apigwv2.DomainMappingOptions(
|
|
173
|
-
domain_name=dn,
|
|
174
|
-
mapping_key="foo"
|
|
175
|
-
)
|
|
176
|
-
)
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
To migrate a domain endpoint from one type to another, you can add a new endpoint configuration via `addEndpoint()`
|
|
180
|
-
and then configure DNS records to route traffic to the new endpoint. After that, you can remove the previous endpoint configuration.
|
|
181
|
-
Learn more at [Migrating a custom domain name](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-regional-api-custom-domain-migrate.html)
|
|
182
|
-
|
|
183
|
-
To associate a specific `Stage` to a custom domain mapping -
|
|
184
|
-
|
|
185
|
-
```python
|
|
186
|
-
# api: apigwv2.HttpApi
|
|
187
|
-
# dn: apigwv2.DomainName
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
api.add_stage("beta",
|
|
191
|
-
stage_name="beta",
|
|
192
|
-
auto_deploy=True,
|
|
193
|
-
# https://${dn.domainName}/bar goes to the beta stage
|
|
194
|
-
domain_mapping=apigwv2.DomainMappingOptions(
|
|
195
|
-
domain_name=dn,
|
|
196
|
-
mapping_key="bar"
|
|
197
|
-
)
|
|
198
|
-
)
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
The same domain name can be associated with stages across different `HttpApi` as so -
|
|
202
|
-
|
|
203
|
-
```python
|
|
204
|
-
from aws_cdk.aws_apigatewayv2_integrations import HttpLambdaIntegration
|
|
205
|
-
|
|
206
|
-
# handler: lambda.Function
|
|
207
|
-
# dn: apigwv2.DomainName
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
api_demo = apigwv2.HttpApi(self, "DemoApi",
|
|
211
|
-
default_integration=HttpLambdaIntegration("DefaultIntegration", handler),
|
|
212
|
-
# https://${dn.domainName}/demo goes to apiDemo $default stage
|
|
213
|
-
default_domain_mapping=apigwv2.DomainMappingOptions(
|
|
214
|
-
domain_name=dn,
|
|
215
|
-
mapping_key="demo"
|
|
216
|
-
)
|
|
217
|
-
)
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
The `mappingKey` determines the base path of the URL with the custom domain. Each custom domain is only allowed
|
|
221
|
-
to have one API mapping with undefined `mappingKey`. If more than one API mappings are specified, `mappingKey` will be required for all of them. In the sample above, the custom domain is associated
|
|
222
|
-
with 3 API mapping resources across different APIs and Stages.
|
|
223
|
-
|
|
224
|
-
| API | Stage | URL |
|
|
225
|
-
| :------------: | :---------: | :----: |
|
|
226
|
-
| api | $default | `https://${domainName}/foo` |
|
|
227
|
-
| api | beta | `https://${domainName}/bar` |
|
|
228
|
-
| apiDemo | $default | `https://${domainName}/demo` |
|
|
229
|
-
|
|
230
|
-
You can retrieve the full domain URL with mapping key using the `domainUrl` property as so -
|
|
231
|
-
|
|
232
|
-
```python
|
|
233
|
-
# api_demo: apigwv2.HttpApi
|
|
234
|
-
|
|
235
|
-
demo_domain_url = api_demo.default_stage.domain_url
|
|
236
|
-
```
|
|
237
|
-
|
|
238
|
-
### Mutual TLS (mTLS)
|
|
239
|
-
|
|
240
|
-
Mutual TLS can be configured to limit access to your API based by using client certificates instead of (or as an extension of) using authorization headers.
|
|
241
|
-
|
|
242
|
-
```python
|
|
243
|
-
import aws_cdk.aws_s3 as s3
|
|
244
|
-
import aws_cdk.aws_certificatemanager as acm
|
|
245
|
-
# bucket: s3.Bucket
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
cert_arn = "arn:aws:acm:us-east-1:111111111111:certificate"
|
|
249
|
-
domain_name = "example.com"
|
|
250
|
-
|
|
251
|
-
apigwv2.DomainName(self, "DomainName",
|
|
252
|
-
domain_name=domain_name,
|
|
253
|
-
certificate=acm.Certificate.from_certificate_arn(self, "cert", cert_arn),
|
|
254
|
-
mtls=apigwv2.MTLSConfig(
|
|
255
|
-
bucket=bucket,
|
|
256
|
-
key="someca.pem",
|
|
257
|
-
version="version"
|
|
258
|
-
)
|
|
259
|
-
)
|
|
260
|
-
```
|
|
261
|
-
|
|
262
|
-
Instructions for configuring your trust store can be found [here](https://aws.amazon.com/blogs/compute/introducing-mutual-tls-authentication-for-amazon-api-gateway/)
|
|
263
|
-
|
|
264
|
-
### Managing access to HTTP APIs
|
|
265
|
-
|
|
266
|
-
API Gateway supports multiple mechanisms for [controlling and managing access to your HTTP
|
|
267
|
-
API](https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-access-control.html) through authorizers.
|
|
268
|
-
|
|
269
|
-
These authorizers can be found in the [APIGatewayV2-Authorizers](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-apigatewayv2-authorizers-readme.html) constructs library.
|
|
270
|
-
|
|
271
|
-
### Metrics
|
|
272
|
-
|
|
273
|
-
The API Gateway v2 service sends metrics around the performance of HTTP APIs to Amazon CloudWatch.
|
|
274
|
-
These metrics can be referred to using the metric APIs available on the `HttpApi` construct.
|
|
275
|
-
The APIs with the `metric` prefix can be used to get reference to specific metrics for this API. For example,
|
|
276
|
-
the method below refers to the client side errors metric for this API.
|
|
277
|
-
|
|
278
|
-
```python
|
|
279
|
-
api = apigwv2.HttpApi(self, "my-api")
|
|
280
|
-
client_error_metric = api.metric_client_error()
|
|
281
|
-
```
|
|
282
|
-
|
|
283
|
-
Please note that this will return a metric for all the stages defined in the api. It is also possible to refer to metrics for a specific Stage using
|
|
284
|
-
the `metric` methods from the `Stage` construct.
|
|
285
|
-
|
|
286
|
-
```python
|
|
287
|
-
api = apigwv2.HttpApi(self, "my-api")
|
|
288
|
-
stage = apigwv2.HttpStage(self, "Stage",
|
|
289
|
-
http_api=api
|
|
290
|
-
)
|
|
291
|
-
client_error_metric = stage.metric_client_error()
|
|
292
|
-
```
|
|
293
|
-
|
|
294
|
-
### VPC Link
|
|
295
|
-
|
|
296
|
-
Private integrations let HTTP APIs connect with AWS resources that are placed behind a VPC. These are usually Application
|
|
297
|
-
Load Balancers, Network Load Balancers or a Cloud Map service. The `VpcLink` construct enables this integration.
|
|
298
|
-
The following code creates a `VpcLink` to a private VPC.
|
|
299
|
-
|
|
300
|
-
```python
|
|
301
|
-
import aws_cdk.aws_ec2 as ec2
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
vpc = ec2.Vpc(self, "VPC")
|
|
305
|
-
vpc_link = apigwv2.VpcLink(self, "VpcLink", vpc=vpc)
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
Any existing `VpcLink` resource can be imported into the CDK app via the `VpcLink.fromVpcLinkAttributes()`.
|
|
309
|
-
|
|
310
|
-
```python
|
|
311
|
-
import aws_cdk.aws_ec2 as ec2
|
|
312
|
-
|
|
313
|
-
# vpc: ec2.Vpc
|
|
314
|
-
|
|
315
|
-
awesome_link = apigwv2.VpcLink.from_vpc_link_attributes(self, "awesome-vpc-link",
|
|
316
|
-
vpc_link_id="us-east-1_oiuR12Abd",
|
|
317
|
-
vpc=vpc
|
|
318
|
-
)
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
### Private Integration
|
|
322
|
-
|
|
323
|
-
Private integrations enable integrating an HTTP API route with private resources in a VPC, such as Application Load Balancers or
|
|
324
|
-
Amazon ECS container-based applications. Using private integrations, resources in a VPC can be exposed for access by
|
|
325
|
-
clients outside of the VPC.
|
|
326
|
-
|
|
327
|
-
These integrations can be found in the [aws-apigatewayv2-integrations](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-apigatewayv2-integrations-readme.html) constructs library.
|
|
328
|
-
|
|
329
|
-
## WebSocket API
|
|
330
|
-
|
|
331
|
-
A WebSocket API in API Gateway is a collection of WebSocket routes that are integrated with backend HTTP endpoints,
|
|
332
|
-
Lambda functions, or other AWS services. You can use API Gateway features to help you with all aspects of the API
|
|
333
|
-
lifecycle, from creation through monitoring your production APIs. [Read more](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-overview.html)
|
|
334
|
-
|
|
335
|
-
WebSocket APIs have two fundamental concepts - Routes and Integrations.
|
|
336
|
-
|
|
337
|
-
WebSocket APIs direct JSON messages to backend integrations based on configured routes. (Non-JSON messages are directed
|
|
338
|
-
to the configured `$default` route.)
|
|
339
|
-
|
|
340
|
-
Integrations define how the WebSocket API behaves when a client reaches a specific Route. Learn more at
|
|
341
|
-
[Configuring integrations](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integration-requests.html).
|
|
342
|
-
|
|
343
|
-
Integrations are available in the `aws-apigatewayv2-integrations` module and more information is available in that module.
|
|
344
|
-
|
|
345
|
-
To add the default WebSocket routes supported by API Gateway (`$connect`, `$disconnect` and `$default`), configure them as part of api props:
|
|
346
|
-
|
|
347
|
-
```python
|
|
348
|
-
from aws_cdk.aws_apigatewayv2_integrations import WebSocketLambdaIntegration
|
|
349
|
-
|
|
350
|
-
# connect_handler: lambda.Function
|
|
351
|
-
# disconnect_handler: lambda.Function
|
|
352
|
-
# default_handler: lambda.Function
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
web_socket_api = apigwv2.WebSocketApi(self, "mywsapi",
|
|
356
|
-
connect_route_options=apigwv2.WebSocketRouteOptions(integration=WebSocketLambdaIntegration("ConnectIntegration", connect_handler)),
|
|
357
|
-
disconnect_route_options=apigwv2.WebSocketRouteOptions(integration=WebSocketLambdaIntegration("DisconnectIntegration", disconnect_handler)),
|
|
358
|
-
default_route_options=apigwv2.WebSocketRouteOptions(integration=WebSocketLambdaIntegration("DefaultIntegration", default_handler))
|
|
359
|
-
)
|
|
360
|
-
|
|
361
|
-
apigwv2.WebSocketStage(self, "mystage",
|
|
362
|
-
web_socket_api=web_socket_api,
|
|
363
|
-
stage_name="dev",
|
|
364
|
-
auto_deploy=True
|
|
365
|
-
)
|
|
366
|
-
```
|
|
367
|
-
|
|
368
|
-
To retrieve a websocket URL and a callback URL:
|
|
369
|
-
|
|
370
|
-
```python
|
|
371
|
-
# web_socket_stage: apigwv2.WebSocketStage
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
web_socket_uRL = web_socket_stage.url
|
|
375
|
-
# wss://${this.api.apiId}.execute-api.${s.region}.${s.urlSuffix}/${urlPath}
|
|
376
|
-
callback_uRL = web_socket_stage.callback_url
|
|
377
|
-
```
|
|
378
|
-
|
|
379
|
-
To add any other route:
|
|
380
|
-
|
|
381
|
-
```python
|
|
382
|
-
from aws_cdk.aws_apigatewayv2_integrations import WebSocketLambdaIntegration
|
|
383
|
-
|
|
384
|
-
# message_handler: lambda.Function
|
|
385
|
-
|
|
386
|
-
web_socket_api = apigwv2.WebSocketApi(self, "mywsapi")
|
|
387
|
-
web_socket_api.add_route("sendmessage",
|
|
388
|
-
integration=WebSocketLambdaIntegration("SendMessageIntegration", message_handler)
|
|
389
|
-
)
|
|
390
|
-
```
|
|
391
|
-
|
|
392
|
-
To add a route that can return a result:
|
|
393
|
-
|
|
394
|
-
```python
|
|
395
|
-
from aws_cdk.aws_apigatewayv2_integrations import WebSocketLambdaIntegration
|
|
396
|
-
|
|
397
|
-
# message_handler: lambda.Function
|
|
398
|
-
|
|
399
|
-
web_socket_api = apigwv2.WebSocketApi(self, "mywsapi")
|
|
400
|
-
web_socket_api.add_route("sendmessage",
|
|
401
|
-
integration=WebSocketLambdaIntegration("SendMessageIntegration", message_handler),
|
|
402
|
-
return_response=True
|
|
403
|
-
)
|
|
404
|
-
```
|
|
405
|
-
|
|
406
|
-
To import an existing WebSocketApi:
|
|
4
|
+
This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aws-cdk) project.
|
|
407
5
|
|
|
408
6
|
```python
|
|
409
|
-
|
|
7
|
+
import aws_cdk.aws_apigatewayv2 as apigateway
|
|
410
8
|
```
|
|
411
9
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
Grant permission to use API Gateway Management API of a WebSocket API by calling the `grantManageConnections` API.
|
|
415
|
-
You can use Management API to send a callback message to a connected client, get connection information, or disconnect the client. Learn more at [Use @connections commands in your backend service](https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html).
|
|
416
|
-
|
|
417
|
-
```python
|
|
418
|
-
# fn: lambda.Function
|
|
419
|
-
|
|
10
|
+
<!--BEGIN CFNONLY DISCLAIMER-->
|
|
420
11
|
|
|
421
|
-
|
|
422
|
-
stage = apigwv2.WebSocketStage(self, "mystage",
|
|
423
|
-
web_socket_api=web_socket_api,
|
|
424
|
-
stage_name="dev"
|
|
425
|
-
)
|
|
426
|
-
# per stage permission
|
|
427
|
-
stage.grant_management_api_access(fn)
|
|
428
|
-
# for all the stages permission
|
|
429
|
-
web_socket_api.grant_manage_connections(fn)
|
|
430
|
-
```
|
|
12
|
+
There are no official hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet. Here are some suggestions on how to proceed:
|
|
431
13
|
|
|
432
|
-
|
|
14
|
+
* Search [Construct Hub for ApiGatewayV2 construct libraries](https://constructs.dev/search?q=apigatewayv2)
|
|
15
|
+
* Use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, in the same way you would use [the CloudFormation AWS::ApiGatewayV2 resources](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGatewayV2.html) directly.
|
|
433
16
|
|
|
434
|
-
|
|
17
|
+
> An experimental construct library for this service is available in preview. Since it is not stable yet, it is distributed
|
|
18
|
+
> as a separate package so that you can pin its version independently of the rest of the CDK. See the package:
|
|
19
|
+
>
|
|
20
|
+
> <span class="package-reference">aws-cdk-lib/aws-apigatewayv2</span>
|
|
435
21
|
|
|
436
|
-
|
|
22
|
+
<!--BEGIN CFNONLY DISCLAIMER-->
|
|
437
23
|
|
|
438
|
-
|
|
24
|
+
There are no hand-written ([L2](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_lib)) constructs for this service yet.
|
|
25
|
+
However, you can still use the automatically generated [L1](https://docs.aws.amazon.com/cdk/latest/guide/constructs.html#constructs_l1_using) constructs, and use this service exactly as you would using CloudFormation directly.
|
|
439
26
|
|
|
440
|
-
|
|
27
|
+
For more information on the resources and properties available for this service, see the [CloudFormation documentation for AWS::ApiGatewayV2](https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/AWS_ApiGatewayV2.html).
|
|
441
28
|
|
|
442
|
-
|
|
29
|
+
(Read the [CDK Contributing Guide](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and submit an RFC if you are interested in contributing to this construct library.)
|
|
443
30
|
|
|
444
|
-
|
|
445
|
-
web_socket_api = apigwv2.WebSocketApi(self, "mywsapi",
|
|
446
|
-
api_key_selection_expression=apigwv2.WebSocketApiKeySelectionExpression.HEADER_X_API_KEY
|
|
447
|
-
)
|
|
448
|
-
```
|
|
31
|
+
<!--END CFNONLY DISCLAIMER-->
|
|
449
32
|
'''
|
|
450
33
|
import abc
|
|
451
34
|
import builtins
|
|
@@ -8191,22 +7774,7 @@ class CfnVpcLinkProps:
|
|
|
8191
7774
|
|
|
8192
7775
|
@jsii.enum(jsii_type="aws-cdk-lib.aws_apigatewayv2.CorsHttpMethod")
|
|
8193
7776
|
class CorsHttpMethod(enum.Enum):
|
|
8194
|
-
'''Supported CORS HTTP methods.
|
|
8195
|
-
|
|
8196
|
-
:exampleMetadata: infused
|
|
8197
|
-
|
|
8198
|
-
Example::
|
|
8199
|
-
|
|
8200
|
-
apigwv2.HttpApi(self, "HttpProxyApi",
|
|
8201
|
-
cors_preflight=apigwv2.CorsPreflightOptions(
|
|
8202
|
-
allow_headers=["Authorization"],
|
|
8203
|
-
allow_methods=[apigwv2.CorsHttpMethod.GET, apigwv2.CorsHttpMethod.HEAD, apigwv2.CorsHttpMethod.OPTIONS, apigwv2.CorsHttpMethod.POST
|
|
8204
|
-
],
|
|
8205
|
-
allow_origins=["*"],
|
|
8206
|
-
max_age=Duration.days(10)
|
|
8207
|
-
)
|
|
8208
|
-
)
|
|
8209
|
-
'''
|
|
7777
|
+
'''Supported CORS HTTP methods.'''
|
|
8210
7778
|
|
|
8211
7779
|
ANY = "ANY"
|
|
8212
7780
|
'''HTTP ANY.'''
|
|
@@ -8258,18 +7826,22 @@ class CorsPreflightOptions:
|
|
|
8258
7826
|
:param expose_headers: Represents a collection of exposed headers. Default: - No Expose Headers are allowed.
|
|
8259
7827
|
:param max_age: The duration that the browser should cache preflight request results. Default: Duration.seconds(0)
|
|
8260
7828
|
|
|
8261
|
-
:exampleMetadata:
|
|
7829
|
+
:exampleMetadata: fixture=_generated
|
|
8262
7830
|
|
|
8263
7831
|
Example::
|
|
8264
7832
|
|
|
8265
|
-
|
|
8266
|
-
|
|
8267
|
-
|
|
8268
|
-
|
|
8269
|
-
|
|
8270
|
-
|
|
8271
|
-
|
|
8272
|
-
|
|
7833
|
+
# The code below shows an example of how to instantiate this type.
|
|
7834
|
+
# The values are placeholders you should change.
|
|
7835
|
+
import aws_cdk as cdk
|
|
7836
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
7837
|
+
|
|
7838
|
+
cors_preflight_options = apigatewayv2.CorsPreflightOptions(
|
|
7839
|
+
allow_credentials=False,
|
|
7840
|
+
allow_headers=["allowHeaders"],
|
|
7841
|
+
allow_methods=[apigatewayv2.CorsHttpMethod.ANY],
|
|
7842
|
+
allow_origins=["allowOrigins"],
|
|
7843
|
+
expose_headers=["exposeHeaders"],
|
|
7844
|
+
max_age=cdk.Duration.minutes(30)
|
|
8273
7845
|
)
|
|
8274
7846
|
'''
|
|
8275
7847
|
if __debug__:
|
|
@@ -8377,23 +7949,21 @@ class DomainMappingOptions:
|
|
|
8377
7949
|
:param domain_name: The domain name for the mapping.
|
|
8378
7950
|
:param mapping_key: The API mapping key. Leave it undefined for the root path mapping. Default: - empty key for the root path mapping
|
|
8379
7951
|
|
|
8380
|
-
:exampleMetadata:
|
|
7952
|
+
:exampleMetadata: fixture=_generated
|
|
8381
7953
|
|
|
8382
7954
|
Example::
|
|
8383
7955
|
|
|
8384
|
-
|
|
7956
|
+
# The code below shows an example of how to instantiate this type.
|
|
7957
|
+
# The values are placeholders you should change.
|
|
7958
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
8385
7959
|
|
|
8386
|
-
#
|
|
8387
|
-
# dn: apigwv2.DomainName
|
|
7960
|
+
# domain_name: apigatewayv2.DomainName
|
|
8388
7961
|
|
|
7962
|
+
domain_mapping_options = apigatewayv2.DomainMappingOptions(
|
|
7963
|
+
domain_name=domain_name,
|
|
8389
7964
|
|
|
8390
|
-
|
|
8391
|
-
|
|
8392
|
-
# https://${dn.domainName}/demo goes to apiDemo $default stage
|
|
8393
|
-
default_domain_mapping=apigwv2.DomainMappingOptions(
|
|
8394
|
-
domain_name=dn,
|
|
8395
|
-
mapping_key="demo"
|
|
8396
|
-
)
|
|
7965
|
+
# the properties below are optional
|
|
7966
|
+
mapping_key="mappingKey"
|
|
8397
7967
|
)
|
|
8398
7968
|
'''
|
|
8399
7969
|
if __debug__:
|
|
@@ -8833,17 +8403,16 @@ class HttpApiProps:
|
|
|
8833
8403
|
|
|
8834
8404
|
from aws_cdk.aws_apigatewayv2_integrations import HttpAlbIntegration
|
|
8835
8405
|
|
|
8836
|
-
# lb: elbv2.ApplicationLoadBalancer
|
|
8837
8406
|
|
|
8407
|
+
vpc = ec2.Vpc(self, "VPC")
|
|
8408
|
+
lb = elbv2.ApplicationLoadBalancer(self, "lb", vpc=vpc)
|
|
8838
8409
|
listener = lb.add_listener("listener", port=80)
|
|
8839
8410
|
listener.add_targets("target",
|
|
8840
8411
|
port=80
|
|
8841
8412
|
)
|
|
8842
8413
|
|
|
8843
8414
|
http_endpoint = apigwv2.HttpApi(self, "HttpProxyPrivateApi",
|
|
8844
|
-
default_integration=HttpAlbIntegration("DefaultIntegration", listener
|
|
8845
|
-
parameter_mapping=apigwv2.ParameterMapping().custom("myKey", "myValue")
|
|
8846
|
-
)
|
|
8415
|
+
default_integration=HttpAlbIntegration("DefaultIntegration", listener)
|
|
8847
8416
|
)
|
|
8848
8417
|
'''
|
|
8849
8418
|
if isinstance(cors_preflight, dict):
|
|
@@ -9583,25 +9152,18 @@ class HttpMethod(enum.Enum):
|
|
|
9583
9152
|
|
|
9584
9153
|
Example::
|
|
9585
9154
|
|
|
9586
|
-
from aws_cdk.aws_apigatewayv2_integrations import
|
|
9155
|
+
from aws_cdk.aws_apigatewayv2_integrations import HttpLambdaIntegration
|
|
9587
9156
|
|
|
9588
9157
|
# books_default_fn: lambda.Function
|
|
9589
9158
|
|
|
9590
|
-
|
|
9591
|
-
get_books_integration = HttpUrlIntegration("GetBooksIntegration", "https://get-books-proxy.example.com")
|
|
9592
|
-
books_default_integration = HttpLambdaIntegration("BooksIntegration", books_default_fn)
|
|
9159
|
+
books_integration = HttpLambdaIntegration("BooksIntegration", books_default_fn)
|
|
9593
9160
|
|
|
9594
9161
|
http_api = apigwv2.HttpApi(self, "HttpApi")
|
|
9595
9162
|
|
|
9596
9163
|
http_api.add_routes(
|
|
9597
9164
|
path="/books",
|
|
9598
9165
|
methods=[apigwv2.HttpMethod.GET],
|
|
9599
|
-
integration=
|
|
9600
|
-
)
|
|
9601
|
-
http_api.add_routes(
|
|
9602
|
-
path="/books",
|
|
9603
|
-
methods=[apigwv2.HttpMethod.ANY],
|
|
9604
|
-
integration=books_default_integration
|
|
9166
|
+
integration=books_integration
|
|
9605
9167
|
)
|
|
9606
9168
|
'''
|
|
9607
9169
|
|
|
@@ -11768,26 +11330,23 @@ class MTLSConfig:
|
|
|
11768
11330
|
:param key: The key in S3 to look at for the trust store.
|
|
11769
11331
|
:param version: The version of the S3 object that contains your truststore. To specify a version, you must have versioning enabled for the S3 bucket. Default: - latest version
|
|
11770
11332
|
|
|
11771
|
-
:exampleMetadata:
|
|
11333
|
+
:exampleMetadata: fixture=_generated
|
|
11772
11334
|
|
|
11773
11335
|
Example::
|
|
11774
11336
|
|
|
11775
|
-
|
|
11776
|
-
|
|
11777
|
-
|
|
11337
|
+
# The code below shows an example of how to instantiate this type.
|
|
11338
|
+
# The values are placeholders you should change.
|
|
11339
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
11340
|
+
from aws_cdk import aws_s3 as s3
|
|
11778
11341
|
|
|
11342
|
+
# bucket: s3.Bucket
|
|
11779
11343
|
|
|
11780
|
-
|
|
11781
|
-
|
|
11344
|
+
m_tLSConfig = apigatewayv2.MTLSConfig(
|
|
11345
|
+
bucket=bucket,
|
|
11346
|
+
key="key",
|
|
11782
11347
|
|
|
11783
|
-
|
|
11784
|
-
|
|
11785
|
-
certificate=acm.Certificate.from_certificate_arn(self, "cert", cert_arn),
|
|
11786
|
-
mtls=apigwv2.MTLSConfig(
|
|
11787
|
-
bucket=bucket,
|
|
11788
|
-
key="someca.pem",
|
|
11789
|
-
version="version"
|
|
11790
|
-
)
|
|
11348
|
+
# the properties below are optional
|
|
11349
|
+
version="version"
|
|
11791
11350
|
)
|
|
11792
11351
|
'''
|
|
11793
11352
|
if __debug__:
|
|
@@ -12440,11 +11999,23 @@ class VpcLink(
|
|
|
12440
11999
|
|
|
12441
12000
|
Example::
|
|
12442
12001
|
|
|
12443
|
-
import aws_cdk.
|
|
12002
|
+
import aws_cdk.aws_servicediscovery as servicediscovery
|
|
12003
|
+
from aws_cdk.aws_apigatewayv2_integrations import HttpServiceDiscoveryIntegration
|
|
12444
12004
|
|
|
12445
12005
|
|
|
12446
12006
|
vpc = ec2.Vpc(self, "VPC")
|
|
12447
12007
|
vpc_link = apigwv2.VpcLink(self, "VpcLink", vpc=vpc)
|
|
12008
|
+
namespace = servicediscovery.PrivateDnsNamespace(self, "Namespace",
|
|
12009
|
+
name="boobar.com",
|
|
12010
|
+
vpc=vpc
|
|
12011
|
+
)
|
|
12012
|
+
service = namespace.create_service("Service")
|
|
12013
|
+
|
|
12014
|
+
http_endpoint = apigwv2.HttpApi(self, "HttpProxyPrivateApi",
|
|
12015
|
+
default_integration=HttpServiceDiscoveryIntegration("DefaultIntegration", service,
|
|
12016
|
+
vpc_link=vpc_link
|
|
12017
|
+
)
|
|
12018
|
+
)
|
|
12448
12019
|
'''
|
|
12449
12020
|
|
|
12450
12021
|
def __init__(
|
|
@@ -12550,17 +12121,20 @@ class VpcLinkAttributes:
|
|
|
12550
12121
|
:param vpc: The VPC to which this VPC link is associated with.
|
|
12551
12122
|
:param vpc_link_id: The VPC Link id.
|
|
12552
12123
|
|
|
12553
|
-
:exampleMetadata:
|
|
12124
|
+
:exampleMetadata: fixture=_generated
|
|
12554
12125
|
|
|
12555
12126
|
Example::
|
|
12556
12127
|
|
|
12557
|
-
|
|
12128
|
+
# The code below shows an example of how to instantiate this type.
|
|
12129
|
+
# The values are placeholders you should change.
|
|
12130
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
12131
|
+
from aws_cdk import aws_ec2 as ec2
|
|
12558
12132
|
|
|
12559
12133
|
# vpc: ec2.Vpc
|
|
12560
12134
|
|
|
12561
|
-
|
|
12562
|
-
|
|
12563
|
-
|
|
12135
|
+
vpc_link_attributes = apigatewayv2.VpcLinkAttributes(
|
|
12136
|
+
vpc=vpc,
|
|
12137
|
+
vpc_link_id="vpcLinkId"
|
|
12564
12138
|
)
|
|
12565
12139
|
'''
|
|
12566
12140
|
if __debug__:
|
|
@@ -12628,11 +12202,23 @@ class VpcLinkProps:
|
|
|
12628
12202
|
|
|
12629
12203
|
Example::
|
|
12630
12204
|
|
|
12631
|
-
import aws_cdk.
|
|
12205
|
+
import aws_cdk.aws_servicediscovery as servicediscovery
|
|
12206
|
+
from aws_cdk.aws_apigatewayv2_integrations import HttpServiceDiscoveryIntegration
|
|
12632
12207
|
|
|
12633
12208
|
|
|
12634
12209
|
vpc = ec2.Vpc(self, "VPC")
|
|
12635
12210
|
vpc_link = apigwv2.VpcLink(self, "VpcLink", vpc=vpc)
|
|
12211
|
+
namespace = servicediscovery.PrivateDnsNamespace(self, "Namespace",
|
|
12212
|
+
name="boobar.com",
|
|
12213
|
+
vpc=vpc
|
|
12214
|
+
)
|
|
12215
|
+
service = namespace.create_service("Service")
|
|
12216
|
+
|
|
12217
|
+
http_endpoint = apigwv2.HttpApi(self, "HttpProxyPrivateApi",
|
|
12218
|
+
default_integration=HttpServiceDiscoveryIntegration("DefaultIntegration", service,
|
|
12219
|
+
vpc_link=vpc_link
|
|
12220
|
+
)
|
|
12221
|
+
)
|
|
12636
12222
|
'''
|
|
12637
12223
|
if isinstance(subnets, dict):
|
|
12638
12224
|
subnets = _SubnetSelection_e57d76df(**subnets)
|
|
@@ -12916,11 +12502,20 @@ class WebSocketApiAttributes:
|
|
|
12916
12502
|
:param web_socket_id: The identifier of the WebSocketApi.
|
|
12917
12503
|
:param api_endpoint: The endpoint URL of the WebSocketApi. Default: - throw san error if apiEndpoint is accessed.
|
|
12918
12504
|
|
|
12919
|
-
:exampleMetadata:
|
|
12505
|
+
:exampleMetadata: fixture=_generated
|
|
12920
12506
|
|
|
12921
12507
|
Example::
|
|
12922
12508
|
|
|
12923
|
-
|
|
12509
|
+
# The code below shows an example of how to instantiate this type.
|
|
12510
|
+
# The values are placeholders you should change.
|
|
12511
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
12512
|
+
|
|
12513
|
+
web_socket_api_attributes = apigatewayv2.WebSocketApiAttributes(
|
|
12514
|
+
web_socket_id="webSocketId",
|
|
12515
|
+
|
|
12516
|
+
# the properties below are optional
|
|
12517
|
+
api_endpoint="apiEndpoint"
|
|
12518
|
+
)
|
|
12924
12519
|
'''
|
|
12925
12520
|
if __debug__:
|
|
12926
12521
|
type_hints = typing.get_type_hints(_typecheckingstub__87a97aaa032b92280dce0e4e2727c8d585344d985b7a83ba0c265ed022a4f143)
|
|
@@ -12966,13 +12561,15 @@ class WebSocketApiKeySelectionExpression(
|
|
|
12966
12561
|
):
|
|
12967
12562
|
'''Represents the currently available API Key Selection Expressions.
|
|
12968
12563
|
|
|
12969
|
-
:exampleMetadata:
|
|
12564
|
+
:exampleMetadata: fixture=_generated
|
|
12970
12565
|
|
|
12971
12566
|
Example::
|
|
12972
12567
|
|
|
12973
|
-
|
|
12974
|
-
|
|
12975
|
-
|
|
12568
|
+
# The code below shows an example of how to instantiate this type.
|
|
12569
|
+
# The values are placeholders you should change.
|
|
12570
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
12571
|
+
|
|
12572
|
+
web_socket_api_key_selection_expression = apigatewayv2.WebSocketApiKeySelectionExpression("customApiKeySelector")
|
|
12976
12573
|
'''
|
|
12977
12574
|
|
|
12978
12575
|
def __init__(self, custom_api_key_selector: builtins.str) -> None:
|
|
@@ -14960,30 +14557,35 @@ class DomainName(
|
|
|
14960
14557
|
):
|
|
14961
14558
|
'''Custom domain resource for the API.
|
|
14962
14559
|
|
|
14963
|
-
:exampleMetadata:
|
|
14560
|
+
:exampleMetadata: fixture=_generated
|
|
14964
14561
|
|
|
14965
14562
|
Example::
|
|
14966
14563
|
|
|
14967
|
-
|
|
14968
|
-
|
|
14564
|
+
# The code below shows an example of how to instantiate this type.
|
|
14565
|
+
# The values are placeholders you should change.
|
|
14566
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
14567
|
+
from aws_cdk import aws_certificatemanager as certificatemanager
|
|
14568
|
+
from aws_cdk import aws_s3 as s3
|
|
14969
14569
|
|
|
14970
|
-
#
|
|
14570
|
+
# bucket: s3.Bucket
|
|
14571
|
+
# certificate: certificatemanager.Certificate
|
|
14971
14572
|
|
|
14573
|
+
domain_name = apigatewayv2.DomainName(self, "MyDomainName",
|
|
14574
|
+
certificate=certificate,
|
|
14575
|
+
domain_name="domainName",
|
|
14972
14576
|
|
|
14973
|
-
|
|
14974
|
-
|
|
14577
|
+
# the properties below are optional
|
|
14578
|
+
certificate_name="certificateName",
|
|
14579
|
+
endpoint_type=apigatewayv2.EndpointType.EDGE,
|
|
14580
|
+
mtls=apigatewayv2.MTLSConfig(
|
|
14581
|
+
bucket=bucket,
|
|
14582
|
+
key="key",
|
|
14975
14583
|
|
|
14976
|
-
|
|
14977
|
-
|
|
14978
|
-
|
|
14979
|
-
|
|
14980
|
-
|
|
14981
|
-
default_integration=HttpLambdaIntegration("DefaultIntegration", handler),
|
|
14982
|
-
# https://${dn.domainName}/foo goes to prodApi $default stage
|
|
14983
|
-
default_domain_mapping=apigwv2.DomainMappingOptions(
|
|
14984
|
-
domain_name=dn,
|
|
14985
|
-
mapping_key="foo"
|
|
14986
|
-
)
|
|
14584
|
+
# the properties below are optional
|
|
14585
|
+
version="version"
|
|
14586
|
+
),
|
|
14587
|
+
ownership_certificate=certificate,
|
|
14588
|
+
security_policy=apigatewayv2.SecurityPolicy.TLS_1_0
|
|
14987
14589
|
)
|
|
14988
14590
|
'''
|
|
14989
14591
|
|
|
@@ -15140,30 +14742,35 @@ class DomainNameProps(EndpointOptions):
|
|
|
15140
14742
|
:param domain_name: The custom domain name.
|
|
15141
14743
|
:param mtls: The mutual TLS authentication configuration for a custom domain name. Default: - mTLS is not configured.
|
|
15142
14744
|
|
|
15143
|
-
:exampleMetadata:
|
|
14745
|
+
:exampleMetadata: fixture=_generated
|
|
15144
14746
|
|
|
15145
14747
|
Example::
|
|
15146
14748
|
|
|
15147
|
-
|
|
15148
|
-
|
|
14749
|
+
# The code below shows an example of how to instantiate this type.
|
|
14750
|
+
# The values are placeholders you should change.
|
|
14751
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
14752
|
+
from aws_cdk import aws_certificatemanager as certificatemanager
|
|
14753
|
+
from aws_cdk import aws_s3 as s3
|
|
15149
14754
|
|
|
15150
|
-
#
|
|
14755
|
+
# bucket: s3.Bucket
|
|
14756
|
+
# certificate: certificatemanager.Certificate
|
|
15151
14757
|
|
|
14758
|
+
domain_name_props = apigatewayv2.DomainNameProps(
|
|
14759
|
+
certificate=certificate,
|
|
14760
|
+
domain_name="domainName",
|
|
15152
14761
|
|
|
15153
|
-
|
|
15154
|
-
|
|
14762
|
+
# the properties below are optional
|
|
14763
|
+
certificate_name="certificateName",
|
|
14764
|
+
endpoint_type=apigatewayv2.EndpointType.EDGE,
|
|
14765
|
+
mtls=apigatewayv2.MTLSConfig(
|
|
14766
|
+
bucket=bucket,
|
|
14767
|
+
key="key",
|
|
15155
14768
|
|
|
15156
|
-
|
|
15157
|
-
|
|
15158
|
-
|
|
15159
|
-
|
|
15160
|
-
|
|
15161
|
-
default_integration=HttpLambdaIntegration("DefaultIntegration", handler),
|
|
15162
|
-
# https://${dn.domainName}/foo goes to prodApi $default stage
|
|
15163
|
-
default_domain_mapping=apigwv2.DomainMappingOptions(
|
|
15164
|
-
domain_name=dn,
|
|
15165
|
-
mapping_key="foo"
|
|
15166
|
-
)
|
|
14769
|
+
# the properties below are optional
|
|
14770
|
+
version="version"
|
|
14771
|
+
),
|
|
14772
|
+
ownership_certificate=certificate,
|
|
14773
|
+
security_policy=apigatewayv2.SecurityPolicy.TLS_1_0
|
|
15167
14774
|
)
|
|
15168
14775
|
'''
|
|
15169
14776
|
if isinstance(mtls, dict):
|
|
@@ -15283,18 +14890,19 @@ class HttpApi(
|
|
|
15283
14890
|
|
|
15284
14891
|
Example::
|
|
15285
14892
|
|
|
15286
|
-
from aws_cdk.aws_apigatewayv2_integrations import
|
|
15287
|
-
|
|
15288
|
-
# books_default_fn: lambda.Function
|
|
14893
|
+
from aws_cdk.aws_apigatewayv2_integrations import HttpAlbIntegration
|
|
15289
14894
|
|
|
15290
|
-
|
|
14895
|
+
# lb: elbv2.ApplicationLoadBalancer
|
|
15291
14896
|
|
|
15292
|
-
|
|
14897
|
+
listener = lb.add_listener("listener", port=80)
|
|
14898
|
+
listener.add_targets("target",
|
|
14899
|
+
port=80
|
|
14900
|
+
)
|
|
15293
14901
|
|
|
15294
|
-
|
|
15295
|
-
|
|
15296
|
-
|
|
15297
|
-
|
|
14902
|
+
http_endpoint = apigwv2.HttpApi(self, "HttpProxyPrivateApi",
|
|
14903
|
+
default_integration=HttpAlbIntegration("DefaultIntegration", listener,
|
|
14904
|
+
parameter_mapping=apigwv2.ParameterMapping().custom("myKey", "myValue")
|
|
14905
|
+
)
|
|
15298
14906
|
)
|
|
15299
14907
|
'''
|
|
15300
14908
|
|
|
@@ -16069,21 +15677,28 @@ class HttpStageOptions(StageOptions):
|
|
|
16069
15677
|
:param throttle: Throttle settings for the routes of this stage. Default: - no throttling configuration
|
|
16070
15678
|
:param stage_name: The name of the stage. See ``StageName`` class for more details. Default: '$default' the default stage of the API. This stage will have the URL at the root of the API endpoint.
|
|
16071
15679
|
|
|
16072
|
-
:exampleMetadata:
|
|
15680
|
+
:exampleMetadata: fixture=_generated
|
|
16073
15681
|
|
|
16074
15682
|
Example::
|
|
16075
15683
|
|
|
16076
|
-
#
|
|
16077
|
-
#
|
|
15684
|
+
# The code below shows an example of how to instantiate this type.
|
|
15685
|
+
# The values are placeholders you should change.
|
|
15686
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
15687
|
+
|
|
15688
|
+
# domain_name: apigatewayv2.DomainName
|
|
16078
15689
|
|
|
15690
|
+
http_stage_options = apigatewayv2.HttpStageOptions(
|
|
15691
|
+
auto_deploy=False,
|
|
15692
|
+
domain_mapping=apigatewayv2.DomainMappingOptions(
|
|
15693
|
+
domain_name=domain_name,
|
|
16079
15694
|
|
|
16080
|
-
|
|
16081
|
-
|
|
16082
|
-
|
|
16083
|
-
|
|
16084
|
-
|
|
16085
|
-
|
|
16086
|
-
|
|
15695
|
+
# the properties below are optional
|
|
15696
|
+
mapping_key="mappingKey"
|
|
15697
|
+
),
|
|
15698
|
+
stage_name="stageName",
|
|
15699
|
+
throttle=apigatewayv2.ThrottleSettings(
|
|
15700
|
+
burst_limit=123,
|
|
15701
|
+
rate_limit=123
|
|
16087
15702
|
)
|
|
16088
15703
|
)
|
|
16089
15704
|
'''
|
|
@@ -16186,16 +15801,33 @@ class HttpStageProps(HttpStageOptions):
|
|
|
16186
15801
|
:param stage_name: The name of the stage. See ``StageName`` class for more details. Default: '$default' the default stage of the API. This stage will have the URL at the root of the API endpoint.
|
|
16187
15802
|
:param http_api: The HTTP API to which this stage is associated.
|
|
16188
15803
|
|
|
16189
|
-
:exampleMetadata:
|
|
15804
|
+
:exampleMetadata: fixture=_generated
|
|
16190
15805
|
|
|
16191
15806
|
Example::
|
|
16192
15807
|
|
|
16193
|
-
#
|
|
15808
|
+
# The code below shows an example of how to instantiate this type.
|
|
15809
|
+
# The values are placeholders you should change.
|
|
15810
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
16194
15811
|
|
|
15812
|
+
# domain_name: apigatewayv2.DomainName
|
|
15813
|
+
# http_api: apigatewayv2.HttpApi
|
|
15814
|
+
|
|
15815
|
+
http_stage_props = apigatewayv2.HttpStageProps(
|
|
15816
|
+
http_api=http_api,
|
|
15817
|
+
|
|
15818
|
+
# the properties below are optional
|
|
15819
|
+
auto_deploy=False,
|
|
15820
|
+
domain_mapping=apigatewayv2.DomainMappingOptions(
|
|
15821
|
+
domain_name=domain_name,
|
|
16195
15822
|
|
|
16196
|
-
|
|
16197
|
-
|
|
16198
|
-
|
|
15823
|
+
# the properties below are optional
|
|
15824
|
+
mapping_key="mappingKey"
|
|
15825
|
+
),
|
|
15826
|
+
stage_name="stageName",
|
|
15827
|
+
throttle=apigatewayv2.ThrottleSettings(
|
|
15828
|
+
burst_limit=123,
|
|
15829
|
+
rate_limit=123
|
|
15830
|
+
)
|
|
16199
15831
|
)
|
|
16200
15832
|
'''
|
|
16201
15833
|
if isinstance(domain_mapping, dict):
|
|
@@ -17076,16 +16708,33 @@ class HttpStage(
|
|
|
17076
16708
|
'''Represents a stage where an instance of the API is deployed.
|
|
17077
16709
|
|
|
17078
16710
|
:resource: AWS::ApiGatewayV2::Stage
|
|
17079
|
-
:exampleMetadata:
|
|
16711
|
+
:exampleMetadata: fixture=_generated
|
|
17080
16712
|
|
|
17081
16713
|
Example::
|
|
17082
16714
|
|
|
17083
|
-
#
|
|
16715
|
+
# The code below shows an example of how to instantiate this type.
|
|
16716
|
+
# The values are placeholders you should change.
|
|
16717
|
+
from aws_cdk import aws_apigatewayv2 as apigatewayv2
|
|
16718
|
+
|
|
16719
|
+
# domain_name: apigatewayv2.DomainName
|
|
16720
|
+
# http_api: apigatewayv2.HttpApi
|
|
16721
|
+
|
|
16722
|
+
http_stage = apigatewayv2.HttpStage(self, "MyHttpStage",
|
|
16723
|
+
http_api=http_api,
|
|
17084
16724
|
|
|
16725
|
+
# the properties below are optional
|
|
16726
|
+
auto_deploy=False,
|
|
16727
|
+
domain_mapping=apigatewayv2.DomainMappingOptions(
|
|
16728
|
+
domain_name=domain_name,
|
|
17085
16729
|
|
|
17086
|
-
|
|
17087
|
-
|
|
17088
|
-
|
|
16730
|
+
# the properties below are optional
|
|
16731
|
+
mapping_key="mappingKey"
|
|
16732
|
+
),
|
|
16733
|
+
stage_name="stageName",
|
|
16734
|
+
throttle=apigatewayv2.ThrottleSettings(
|
|
16735
|
+
burst_limit=123,
|
|
16736
|
+
rate_limit=123
|
|
16737
|
+
)
|
|
17089
16738
|
)
|
|
17090
16739
|
'''
|
|
17091
16740
|
|