aws-cdk-lib 2.191.0__py3-none-any.whl → 2.193.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 CHANGED
@@ -22143,29 +22143,26 @@ class StackProps:
22143
22143
 
22144
22144
  Example::
22145
22145
 
22146
- stack1 = Stack(app, "Stack1",
22147
- env=Environment(
22148
- region="us-east-1"
22149
- ),
22150
- cross_region_references=True
22151
- )
22152
- cert = acm.Certificate(stack1, "Cert",
22153
- domain_name="*.example.com",
22154
- validation=acm.CertificateValidation.from_dns(route53.PublicHostedZone.from_hosted_zone_id(stack1, "Zone", "Z0329774B51CGXTDQV3X"))
22155
- )
22146
+ import aws_cdk as cdk
22147
+ import aws_cdk.aws_cloudwatch as cloudwatch
22156
22148
 
22157
- stack2 = Stack(app, "Stack2",
22158
- env=Environment(
22159
- region="us-east-2"
22160
- ),
22161
- cross_region_references=True
22149
+
22150
+ app = cdk.App()
22151
+ stack = cdk.Stack(app, "Stack", env=cdk.Environment(region="us-west-2"))
22152
+
22153
+ global_table = dynamodb.TableV2(stack, "GlobalTable",
22154
+ partition_key=dynamodb.Attribute(name="pk", type=dynamodb.AttributeType.STRING),
22155
+ replicas=[dynamodb.ReplicaTableProps(region="us-east-1"), dynamodb.ReplicaTableProps(region="us-east-2")
22156
+ ]
22162
22157
  )
22163
- cloudfront.Distribution(stack2, "Distribution",
22164
- default_behavior=cloudfront.BehaviorOptions(
22165
- origin=origins.HttpOrigin("example.com")
22166
- ),
22167
- domain_names=["dev.example.com"],
22168
- certificate=cert
22158
+
22159
+ # metric is only for the table in us-west-2
22160
+ metric = global_table.metric_consumed_read_capacity_units()
22161
+
22162
+ cloudwatch.Alarm(self, "Alarm",
22163
+ metric=metric,
22164
+ evaluation_periods=1,
22165
+ threshold=1
22169
22166
  )
22170
22167
  '''
22171
22168
  if isinstance(env, dict):
aws_cdk/_jsii/__init__.py CHANGED
@@ -34,7 +34,7 @@ import aws_cdk.cloud_assembly_schema._jsii
34
34
  import constructs._jsii
35
35
 
36
36
  __jsii_assembly__ = jsii.JSIIAssembly.load(
37
- "aws-cdk-lib", "2.191.0", __name__[0:-6], "aws-cdk-lib@2.191.0.jsii.tgz"
37
+ "aws-cdk-lib", "2.193.0", __name__[0:-6], "aws-cdk-lib@2.193.0.jsii.tgz"
38
38
  )
39
39
 
40
40
  __all__ = [
@@ -35,6 +35,11 @@ running on AWS Lambda, or any web application.
35
35
  * [Mutual TLS (mTLS)](#mutual-tls-mtls)
36
36
  * [Deployments](#deployments)
37
37
 
38
+ * [Deploying to an existing stage](#deploying-to-an-existing-stage)
39
+
40
+ * [Using RestApi](#using-restapi)
41
+ * [Using SpecRestApi](#using-specrestapi)
42
+ * [Controlled triggering of deployments](#controlled-triggering-of-deployments)
38
43
  * [Deep dive: Invalidation of deployments](#deep-dive-invalidation-of-deployments)
39
44
  * [Custom Domains](#custom-domains)
40
45
 
@@ -1806,6 +1811,26 @@ for more details.
1806
1811
  properties that can be configured directly in the OpenAPI specification file. This is to prevent people duplication
1807
1812
  of these properties and potential confusion.
1808
1813
 
1814
+ However, you can control how API Gateway handles resource updates using the `mode` property. Valid values are:
1815
+
1816
+ * `overwrite` - The new API definition replaces the existing one. The existing API identifier remains unchanged.
1817
+ * `merge` - The new API definition is merged with the existing API.
1818
+
1819
+ If you don't specify this property, a default value is chosen:
1820
+
1821
+ * For REST APIs created before March 29, 2021, the default is `overwrite`
1822
+ * For REST APIs created after March 29, 2021, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API.
1823
+
1824
+ Use the default mode to define top-level RestApi properties in addition to using OpenAPI.
1825
+ Generally, it's preferred to use API Gateway's OpenAPI extensions to model these properties.
1826
+
1827
+ ```python
1828
+ api = apigateway.SpecRestApi(self, "books-api",
1829
+ api_definition=apigateway.ApiDefinition.from_asset("path-to-file.json"),
1830
+ mode=apigateway.RestApiMode.MERGE
1831
+ )
1832
+ ```
1833
+
1809
1834
  ### Endpoint configuration
1810
1835
 
1811
1836
  By default, `SpecRestApi` will create an edge optimized endpoint.
@@ -24641,7 +24666,7 @@ class RestApiBaseProps:
24641
24666
  ) -> typing.Optional[_RemovalPolicy_9f93c814]:
24642
24667
  '''The removal policy applied to the AWS CloudWatch role when this resource is removed from the application.
24643
24668
 
24644
- Requires ``cloudWatchRole`` to be enabled.
24669
+ Requires ``cloudWatchRole`` to be enabled.
24645
24670
 
24646
24671
  :default: - RemovalPolicy.RETAIN
24647
24672
  '''
@@ -24811,6 +24836,26 @@ class RestApiBaseProps:
24811
24836
  )
24812
24837
 
24813
24838
 
24839
+ @jsii.enum(jsii_type="aws-cdk-lib.aws_apigateway.RestApiMode")
24840
+ class RestApiMode(enum.Enum):
24841
+ '''The Mode that determines how API Gateway handles resource updates when importing an OpenAPI definition.
24842
+
24843
+ :exampleMetadata: infused
24844
+
24845
+ Example::
24846
+
24847
+ api = apigateway.SpecRestApi(self, "books-api",
24848
+ api_definition=apigateway.ApiDefinition.from_asset("path-to-file.json"),
24849
+ mode=apigateway.RestApiMode.MERGE
24850
+ )
24851
+ '''
24852
+
24853
+ OVERWRITE = "OVERWRITE"
24854
+ '''The new API definition replaces the existing one.'''
24855
+ MERGE = "MERGE"
24856
+ '''The new API definition is merged with the existing API.'''
24857
+
24858
+
24814
24859
  @jsii.data_type(
24815
24860
  jsii_type="aws-cdk-lib.aws_apigateway.RestApiProps",
24816
24861
  jsii_struct_bases=[ResourceOptions, RestApiBaseProps],
@@ -25035,7 +25080,7 @@ class RestApiProps(ResourceOptions, RestApiBaseProps):
25035
25080
  ) -> typing.Optional[_RemovalPolicy_9f93c814]:
25036
25081
  '''The removal policy applied to the AWS CloudWatch role when this resource is removed from the application.
25037
25082
 
25038
- Requires ``cloudWatchRole`` to be enabled.
25083
+ Requires ``cloudWatchRole`` to be enabled.
25039
25084
 
25040
25085
  :default: - RemovalPolicy.RETAIN
25041
25086
  '''
@@ -25654,15 +25699,10 @@ class SpecRestApi(
25654
25699
 
25655
25700
  Example::
25656
25701
 
25657
- # integration: apigateway.Integration
25658
-
25659
-
25660
25702
  api = apigateway.SpecRestApi(self, "books-api",
25661
- api_definition=apigateway.ApiDefinition.from_asset("path-to-file.json")
25703
+ api_definition=apigateway.ApiDefinition.from_asset("path-to-file.json"),
25704
+ mode=apigateway.RestApiMode.MERGE
25662
25705
  )
25663
-
25664
- books_resource = api.root.add_resource("books")
25665
- books_resource.add_method("GET", integration)
25666
25706
  '''
25667
25707
 
25668
25708
  def __init__(
@@ -25672,6 +25712,7 @@ class SpecRestApi(
25672
25712
  *,
25673
25713
  api_definition: ApiDefinition,
25674
25714
  min_compression_size: typing.Optional[_Size_7b441c34] = None,
25715
+ mode: typing.Optional[RestApiMode] = None,
25675
25716
  cloud_watch_role: typing.Optional[builtins.bool] = None,
25676
25717
  cloud_watch_role_removal_policy: typing.Optional[_RemovalPolicy_9f93c814] = None,
25677
25718
  deploy: typing.Optional[builtins.bool] = None,
@@ -25693,6 +25734,7 @@ class SpecRestApi(
25693
25734
  :param id: -
25694
25735
  :param api_definition: An OpenAPI definition compatible with API Gateway.
25695
25736
  :param min_compression_size: A Size(in bytes, kibibytes, mebibytes etc) that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (when undefined) on an API. When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size. Default: - Compression is disabled.
25737
+ :param mode: The Mode that determines how API Gateway handles resource updates. Valid values are ``overwrite`` or ``merge``. For ``overwrite``, the new API definition replaces the existing one. The existing API identifier remains unchanged. For ``merge``, the new API definition is merged with the existing API. If you don't specify this property, a default value is chosen: - For REST APIs created before March 29, 2021, the default is ``overwrite`` - For REST APIs created after March 29, 2021, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API. Use the default mode to define top-level RestApi properties in addition to using OpenAPI. Generally, it's preferred to use API Gateway's OpenAPI extensions to model these properties. Default: - ``merge`` for REST APIs created after March 29, 2021, otherwise ``overwrite``
25696
25738
  :param cloud_watch_role: Automatically configure an AWS CloudWatch role for API Gateway. Default: - false if ``@aws-cdk/aws-apigateway:disableCloudWatchRole`` is enabled, true otherwise
25697
25739
  :param cloud_watch_role_removal_policy: The removal policy applied to the AWS CloudWatch role when this resource is removed from the application. Requires ``cloudWatchRole`` to be enabled. Default: - RemovalPolicy.RETAIN
25698
25740
  :param deploy: Indicates if a Deployment should be automatically created for this API, and recreated when the API model (resources, methods) changes. Since API Gateway deployments are immutable, When this option is enabled (by default), an AWS::ApiGateway::Deployment resource will automatically created with a logical ID that hashes the API model (methods, resources and options). This means that when the model changes, the logical ID of this CloudFormation resource will change, and a new deployment will be created. If this is set, ``latestDeployment`` will refer to the ``Deployment`` object and ``deploymentStage`` will refer to a ``Stage`` that points to this deployment. To customize the stage options, use the ``deployOptions`` property. A CloudFormation Output will also be defined with the root URL endpoint of this REST API. Default: true
@@ -25716,6 +25758,7 @@ class SpecRestApi(
25716
25758
  props = SpecRestApiProps(
25717
25759
  api_definition=api_definition,
25718
25760
  min_compression_size=min_compression_size,
25761
+ mode=mode,
25719
25762
  cloud_watch_role=cloud_watch_role,
25720
25763
  cloud_watch_role_removal_policy=cloud_watch_role_removal_policy,
25721
25764
  deploy=deploy,
@@ -25799,6 +25842,7 @@ class SpecRestApi(
25799
25842
  "retain_deployments": "retainDeployments",
25800
25843
  "api_definition": "apiDefinition",
25801
25844
  "min_compression_size": "minCompressionSize",
25845
+ "mode": "mode",
25802
25846
  },
25803
25847
  )
25804
25848
  class SpecRestApiProps(RestApiBaseProps):
@@ -25822,6 +25866,7 @@ class SpecRestApiProps(RestApiBaseProps):
25822
25866
  retain_deployments: typing.Optional[builtins.bool] = None,
25823
25867
  api_definition: ApiDefinition,
25824
25868
  min_compression_size: typing.Optional[_Size_7b441c34] = None,
25869
+ mode: typing.Optional[RestApiMode] = None,
25825
25870
  ) -> None:
25826
25871
  '''Props to instantiate a new SpecRestApi.
25827
25872
 
@@ -25842,20 +25887,16 @@ class SpecRestApiProps(RestApiBaseProps):
25842
25887
  :param retain_deployments: Retains old deployment resources when the API changes. This allows manually reverting stages to point to old deployments via the AWS Console. Default: false
25843
25888
  :param api_definition: An OpenAPI definition compatible with API Gateway.
25844
25889
  :param min_compression_size: A Size(in bytes, kibibytes, mebibytes etc) that is used to enable compression (with non-negative between 0 and 10485760 (10M) bytes, inclusive) or disable compression (when undefined) on an API. When compression is enabled, compression or decompression is not applied on the payload if the payload size is smaller than this value. Setting it to zero allows compression for any payload size. Default: - Compression is disabled.
25890
+ :param mode: The Mode that determines how API Gateway handles resource updates. Valid values are ``overwrite`` or ``merge``. For ``overwrite``, the new API definition replaces the existing one. The existing API identifier remains unchanged. For ``merge``, the new API definition is merged with the existing API. If you don't specify this property, a default value is chosen: - For REST APIs created before March 29, 2021, the default is ``overwrite`` - For REST APIs created after March 29, 2021, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API. Use the default mode to define top-level RestApi properties in addition to using OpenAPI. Generally, it's preferred to use API Gateway's OpenAPI extensions to model these properties. Default: - ``merge`` for REST APIs created after March 29, 2021, otherwise ``overwrite``
25845
25891
 
25846
25892
  :exampleMetadata: infused
25847
25893
 
25848
25894
  Example::
25849
25895
 
25850
- # integration: apigateway.Integration
25851
-
25852
-
25853
25896
  api = apigateway.SpecRestApi(self, "books-api",
25854
- api_definition=apigateway.ApiDefinition.from_asset("path-to-file.json")
25897
+ api_definition=apigateway.ApiDefinition.from_asset("path-to-file.json"),
25898
+ mode=apigateway.RestApiMode.MERGE
25855
25899
  )
25856
-
25857
- books_resource = api.root.add_resource("books")
25858
- books_resource.add_method("GET", integration)
25859
25900
  '''
25860
25901
  if isinstance(deploy_options, dict):
25861
25902
  deploy_options = StageOptions(**deploy_options)
@@ -25882,6 +25923,7 @@ class SpecRestApiProps(RestApiBaseProps):
25882
25923
  check_type(argname="argument retain_deployments", value=retain_deployments, expected_type=type_hints["retain_deployments"])
25883
25924
  check_type(argname="argument api_definition", value=api_definition, expected_type=type_hints["api_definition"])
25884
25925
  check_type(argname="argument min_compression_size", value=min_compression_size, expected_type=type_hints["min_compression_size"])
25926
+ check_type(argname="argument mode", value=mode, expected_type=type_hints["mode"])
25885
25927
  self._values: typing.Dict[builtins.str, typing.Any] = {
25886
25928
  "api_definition": api_definition,
25887
25929
  }
@@ -25917,6 +25959,8 @@ class SpecRestApiProps(RestApiBaseProps):
25917
25959
  self._values["retain_deployments"] = retain_deployments
25918
25960
  if min_compression_size is not None:
25919
25961
  self._values["min_compression_size"] = min_compression_size
25962
+ if mode is not None:
25963
+ self._values["mode"] = mode
25920
25964
 
25921
25965
  @builtins.property
25922
25966
  def cloud_watch_role(self) -> typing.Optional[builtins.bool]:
@@ -25933,7 +25977,7 @@ class SpecRestApiProps(RestApiBaseProps):
25933
25977
  ) -> typing.Optional[_RemovalPolicy_9f93c814]:
25934
25978
  '''The removal policy applied to the AWS CloudWatch role when this resource is removed from the application.
25935
25979
 
25936
- Requires ``cloudWatchRole`` to be enabled.
25980
+ Requires ``cloudWatchRole`` to be enabled.
25937
25981
 
25938
25982
  :default: - RemovalPolicy.RETAIN
25939
25983
  '''
@@ -26115,6 +26159,30 @@ class SpecRestApiProps(RestApiBaseProps):
26115
26159
  result = self._values.get("min_compression_size")
26116
26160
  return typing.cast(typing.Optional[_Size_7b441c34], result)
26117
26161
 
26162
+ @builtins.property
26163
+ def mode(self) -> typing.Optional[RestApiMode]:
26164
+ '''The Mode that determines how API Gateway handles resource updates.
26165
+
26166
+ Valid values are ``overwrite`` or ``merge``.
26167
+
26168
+ For ``overwrite``, the new API definition replaces the existing one.
26169
+ The existing API identifier remains unchanged.
26170
+
26171
+ For ``merge``, the new API definition is merged with the existing API.
26172
+
26173
+ If you don't specify this property, a default value is chosen:
26174
+
26175
+ - For REST APIs created before March 29, 2021, the default is ``overwrite``
26176
+ - For REST APIs created after March 29, 2021, the new API definition takes precedence, but any container types such as endpoint configurations and binary media types are merged with the existing API.
26177
+
26178
+ Use the default mode to define top-level RestApi properties in addition to using OpenAPI.
26179
+ Generally, it's preferred to use API Gateway's OpenAPI extensions to model these properties.
26180
+
26181
+ :default: - ``merge`` for REST APIs created after March 29, 2021, otherwise ``overwrite``
26182
+ '''
26183
+ result = self._values.get("mode")
26184
+ return typing.cast(typing.Optional[RestApiMode], result)
26185
+
26118
26186
  def __eq__(self, rhs: typing.Any) -> builtins.bool:
26119
26187
  return isinstance(rhs, self.__class__) and rhs._values == self._values
26120
26188
 
@@ -28277,7 +28345,7 @@ class StepFunctionsRestApiProps(RestApiProps):
28277
28345
  ) -> typing.Optional[_RemovalPolicy_9f93c814]:
28278
28346
  '''The removal policy applied to the AWS CloudWatch role when this resource is removed from the application.
28279
28347
 
28280
- Requires ``cloudWatchRole`` to be enabled.
28348
+ Requires ``cloudWatchRole`` to be enabled.
28281
28349
 
28282
28350
  :default: - RemovalPolicy.RETAIN
28283
28351
  '''
@@ -30993,7 +31061,7 @@ class LambdaRestApiProps(RestApiProps):
30993
31061
  ) -> typing.Optional[_RemovalPolicy_9f93c814]:
30994
31062
  '''The removal policy applied to the AWS CloudWatch role when this resource is removed from the application.
30995
31063
 
30996
- Requires ``cloudWatchRole`` to be enabled.
31064
+ Requires ``cloudWatchRole`` to be enabled.
30997
31065
 
30998
31066
  :default: - RemovalPolicy.RETAIN
30999
31067
  '''
@@ -33256,6 +33324,7 @@ __all__ = [
33256
33324
  "RestApiAttributes",
33257
33325
  "RestApiBase",
33258
33326
  "RestApiBaseProps",
33327
+ "RestApiMode",
33259
33328
  "RestApiProps",
33260
33329
  "S3ApiDefinition",
33261
33330
  "SagemakerIntegration",
@@ -36422,6 +36491,7 @@ def _typecheckingstub__4722b635be09e87466169ef31b6610061f0fa16d1cff99382f0584fde
36422
36491
  *,
36423
36492
  api_definition: ApiDefinition,
36424
36493
  min_compression_size: typing.Optional[_Size_7b441c34] = None,
36494
+ mode: typing.Optional[RestApiMode] = None,
36425
36495
  cloud_watch_role: typing.Optional[builtins.bool] = None,
36426
36496
  cloud_watch_role_removal_policy: typing.Optional[_RemovalPolicy_9f93c814] = None,
36427
36497
  deploy: typing.Optional[builtins.bool] = None,
@@ -36466,6 +36536,7 @@ def _typecheckingstub__4506705cb637aa3098ad358d76fa29dd7a218f7542020d2e9dbfe8182
36466
36536
  retain_deployments: typing.Optional[builtins.bool] = None,
36467
36537
  api_definition: ApiDefinition,
36468
36538
  min_compression_size: typing.Optional[_Size_7b441c34] = None,
36539
+ mode: typing.Optional[RestApiMode] = None,
36469
36540
  ) -> None:
36470
36541
  """Type checking stubs"""
36471
36542
  pass