aws-cdk-lib 2.141.0__py3-none-any.whl → 2.142.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.

@@ -24,7 +24,8 @@ autoscaling.AutoScalingGroup(self, "ASG",
24
24
  Creating an `AutoScalingGroup` from a Launch Configuration has been deprecated. All new accounts created after December 31, 2023 will no longer be able to create Launch Configurations. With the `@aws-cdk/aws-autoscaling:generateLaunchTemplateInsteadOfLaunchConfig` feature flag set to true, `AutoScalingGroup` properties used to create a Launch Configuration will now be used to create a `LaunchTemplate` using a [Launch Configuration to `LaunchTemplate` mapping](https://docs.aws.amazon.com/autoscaling/ec2/userguide/migrate-launch-configurations-with-cloudformation.html#launch-configuration-mapping-reference). Specifically, the following `AutoScalingGroup` properties will be used to generate a `LaunchTemplate`:
25
25
 
26
26
  * machineImage
27
- * keyName
27
+ * keyName (deprecated, prefer keyPair)
28
+ * keyPair
28
29
  * instanceType
29
30
  * instanceMonitoring
30
31
  * securityGroup
@@ -753,6 +754,31 @@ autoscaling.AutoScalingGroup(self, "ASG",
753
754
  )
754
755
  ```
755
756
 
757
+ ## Configuring KeyPair for instances
758
+
759
+ You can use a keyPair to build your asg when you decide not to use a ready-made LanchTemplate.
760
+
761
+ To configure KeyPair for an autoscaling group, pass the `keyPair` as a prop:
762
+
763
+ ```python
764
+ # vpc: ec2.Vpc
765
+ # instance_type: ec2.InstanceType
766
+ # machine_image: ec2.IMachineImage
767
+
768
+
769
+ my_key_pair = ec2.KeyPair(self, "MyKeyPair")
770
+
771
+ autoscaling.AutoScalingGroup(self, "ASG",
772
+ vpc=vpc,
773
+ instance_type=instance_type,
774
+ machine_image=machine_image,
775
+
776
+ # ...
777
+
778
+ key_pair=my_key_pair
779
+ )
780
+ ```
781
+
756
782
  ## Future work
757
783
 
758
784
  * [ ] CloudWatch Events (impossible to add currently as the AutoScalingGroup ARN is
@@ -794,6 +820,7 @@ from ..aws_ec2 import (
794
820
  CloudFormationInit as _CloudFormationInit_2bb1d1b2,
795
821
  Connections as _Connections_0f31fce8,
796
822
  IConnectable as _IConnectable_10015a05,
823
+ IKeyPair as _IKeyPair_bc344eda,
797
824
  ILaunchTemplate as _ILaunchTemplate_f32c0fd7,
798
825
  IMachineImage as _IMachineImage_0e8bd50b,
799
826
  ISecurityGroup as _ISecurityGroup_acf8a799,
@@ -11884,6 +11911,7 @@ class CfnWarmPoolProps:
11884
11911
  "ignore_unmodified_size_properties": "ignoreUnmodifiedSizeProperties",
11885
11912
  "instance_monitoring": "instanceMonitoring",
11886
11913
  "key_name": "keyName",
11914
+ "key_pair": "keyPair",
11887
11915
  "max_capacity": "maxCapacity",
11888
11916
  "max_instance_lifetime": "maxInstanceLifetime",
11889
11917
  "min_capacity": "minCapacity",
@@ -11915,6 +11943,7 @@ class CommonAutoScalingGroupProps:
11915
11943
  ignore_unmodified_size_properties: typing.Optional[builtins.bool] = None,
11916
11944
  instance_monitoring: typing.Optional["Monitoring"] = None,
11917
11945
  key_name: typing.Optional[builtins.str] = None,
11946
+ key_pair: typing.Optional[_IKeyPair_bc344eda] = None,
11918
11947
  max_capacity: typing.Optional[jsii.Number] = None,
11919
11948
  max_instance_lifetime: typing.Optional[_Duration_4839e8c3] = None,
11920
11949
  min_capacity: typing.Optional[jsii.Number] = None,
@@ -11945,7 +11974,8 @@ class CommonAutoScalingGroupProps:
11945
11974
  :param health_check: Configuration for health checks. Default: - HealthCheck.ec2 with no grace period
11946
11975
  :param ignore_unmodified_size_properties: If the ASG has scheduled actions, don't reset unchanged group sizes. Only used if the ASG has scheduled actions (which may scale your ASG up or down regardless of cdk deployments). If true, the size of the group will only be reset if it has been changed in the CDK app. If false, the sizes will always be changed back to what they were in the CDK app on deployment. Default: true
11947
11976
  :param instance_monitoring: Controls whether instances in this group are launched with detailed or basic monitoring. When detailed monitoring is enabled, Amazon CloudWatch generates metrics every minute and your account is charged a fee. When you disable detailed monitoring, CloudWatch generates metrics every 5 minutes. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified Default: - Monitoring.DETAILED
11948
- :param key_name: Name of SSH keypair to grant access to instances. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified Default: - No SSH access will be possible.
11977
+ :param key_name: (deprecated) Name of SSH keypair to grant access to instances. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified You can either specify ``keyPair`` or ``keyName``, not both. Default: - No SSH access will be possible.
11978
+ :param key_pair: The SSH keypair to grant access to the instance. Feature flag ``AUTOSCALING_GENERATE_LAUNCH_TEMPLATE`` must be enabled to use this property. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified. You can either specify ``keyPair`` or ``keyName``, not both. Default: - No SSH access will be possible.
11949
11979
  :param max_capacity: Maximum number of instances in the fleet. Default: desiredCapacity
11950
11980
  :param max_instance_lifetime: The maximum amount of time that an instance can be in service. The maximum duration applies to all current and future instances in the group. As an instance approaches its maximum duration, it is terminated and replaced, and cannot be used again. You must specify a value of at least 604,800 seconds (7 days). To clear a previously set value, leave this property undefined. Default: none
11951
11981
  :param min_capacity: Minimum number of instances in the fleet. Default: 1
@@ -11973,6 +12003,7 @@ class CommonAutoScalingGroupProps:
11973
12003
  # block_device_volume: autoscaling.BlockDeviceVolume
11974
12004
  # group_metrics: autoscaling.GroupMetrics
11975
12005
  # health_check: autoscaling.HealthCheck
12006
+ # key_pair: ec2.KeyPair
11976
12007
  # scaling_events: autoscaling.ScalingEvents
11977
12008
  # signals: autoscaling.Signals
11978
12009
  # subnet: ec2.Subnet
@@ -11997,6 +12028,7 @@ class CommonAutoScalingGroupProps:
11997
12028
  ignore_unmodified_size_properties=False,
11998
12029
  instance_monitoring=autoscaling.Monitoring.BASIC,
11999
12030
  key_name="keyName",
12031
+ key_pair=key_pair,
12000
12032
  max_capacity=123,
12001
12033
  max_instance_lifetime=cdk.Duration.minutes(30),
12002
12034
  min_capacity=123,
@@ -12040,6 +12072,7 @@ class CommonAutoScalingGroupProps:
12040
12072
  check_type(argname="argument ignore_unmodified_size_properties", value=ignore_unmodified_size_properties, expected_type=type_hints["ignore_unmodified_size_properties"])
12041
12073
  check_type(argname="argument instance_monitoring", value=instance_monitoring, expected_type=type_hints["instance_monitoring"])
12042
12074
  check_type(argname="argument key_name", value=key_name, expected_type=type_hints["key_name"])
12075
+ check_type(argname="argument key_pair", value=key_pair, expected_type=type_hints["key_pair"])
12043
12076
  check_type(argname="argument max_capacity", value=max_capacity, expected_type=type_hints["max_capacity"])
12044
12077
  check_type(argname="argument max_instance_lifetime", value=max_instance_lifetime, expected_type=type_hints["max_instance_lifetime"])
12045
12078
  check_type(argname="argument min_capacity", value=min_capacity, expected_type=type_hints["min_capacity"])
@@ -12079,6 +12112,8 @@ class CommonAutoScalingGroupProps:
12079
12112
  self._values["instance_monitoring"] = instance_monitoring
12080
12113
  if key_name is not None:
12081
12114
  self._values["key_name"] = key_name
12115
+ if key_pair is not None:
12116
+ self._values["key_pair"] = key_pair
12082
12117
  if max_capacity is not None:
12083
12118
  self._values["max_capacity"] = max_capacity
12084
12119
  if max_instance_lifetime is not None:
@@ -12265,15 +12300,36 @@ class CommonAutoScalingGroupProps:
12265
12300
 
12266
12301
  @builtins.property
12267
12302
  def key_name(self) -> typing.Optional[builtins.str]:
12268
- '''Name of SSH keypair to grant access to instances.
12303
+ '''(deprecated) Name of SSH keypair to grant access to instances.
12269
12304
 
12270
12305
  ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified
12271
12306
 
12307
+ You can either specify ``keyPair`` or ``keyName``, not both.
12308
+
12272
12309
  :default: - No SSH access will be possible.
12310
+
12311
+ :deprecated: - Use ``keyPair`` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair
12312
+
12313
+ :stability: deprecated
12273
12314
  '''
12274
12315
  result = self._values.get("key_name")
12275
12316
  return typing.cast(typing.Optional[builtins.str], result)
12276
12317
 
12318
+ @builtins.property
12319
+ def key_pair(self) -> typing.Optional[_IKeyPair_bc344eda]:
12320
+ '''The SSH keypair to grant access to the instance.
12321
+
12322
+ Feature flag ``AUTOSCALING_GENERATE_LAUNCH_TEMPLATE`` must be enabled to use this property.
12323
+
12324
+ ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified.
12325
+
12326
+ You can either specify ``keyPair`` or ``keyName``, not both.
12327
+
12328
+ :default: - No SSH access will be possible.
12329
+ '''
12330
+ result = self._values.get("key_pair")
12331
+ return typing.cast(typing.Optional[_IKeyPair_bc344eda], result)
12332
+
12277
12333
  @builtins.property
12278
12334
  def max_capacity(self) -> typing.Optional[jsii.Number]:
12279
12335
  '''Maximum number of instances in the fleet.
@@ -16376,7 +16432,7 @@ class StepScalingAction(
16376
16432
  :param id: -
16377
16433
  :param auto_scaling_group: The auto scaling group.
16378
16434
  :param adjustment_type: How the adjustment numbers are interpreted. Default: ChangeInCapacity
16379
- :param cooldown: Period after a scaling completes before another scaling activity can start. Default: The default cooldown configured on the AutoScalingGroup
16435
+ :param cooldown: (deprecated) Period after a scaling completes before another scaling activity can start. Default: The default cooldown configured on the AutoScalingGroup
16380
16436
  :param estimated_instance_warmup: Estimated time until a newly launched instance can send metrics to CloudWatch. Default: Same as the cooldown
16381
16437
  :param metric_aggregation_type: The aggregation type for the CloudWatch metrics. Default: Average
16382
16438
  :param min_adjustment_magnitude: Minimum absolute number to adjust capacity with as result of percentage scaling. Only when using AdjustmentType = PercentChangeInCapacity, this number controls the minimum absolute effect size. Default: No minimum scaling effect
@@ -16450,7 +16506,7 @@ class StepScalingActionProps:
16450
16506
 
16451
16507
  :param auto_scaling_group: The auto scaling group.
16452
16508
  :param adjustment_type: How the adjustment numbers are interpreted. Default: ChangeInCapacity
16453
- :param cooldown: Period after a scaling completes before another scaling activity can start. Default: The default cooldown configured on the AutoScalingGroup
16509
+ :param cooldown: (deprecated) Period after a scaling completes before another scaling activity can start. Default: The default cooldown configured on the AutoScalingGroup
16454
16510
  :param estimated_instance_warmup: Estimated time until a newly launched instance can send metrics to CloudWatch. Default: Same as the cooldown
16455
16511
  :param metric_aggregation_type: The aggregation type for the CloudWatch metrics. Default: Average
16456
16512
  :param min_adjustment_magnitude: Minimum absolute number to adjust capacity with as result of percentage scaling. Only when using AdjustmentType = PercentChangeInCapacity, this number controls the minimum absolute effect size. Default: No minimum scaling effect
@@ -16517,9 +16573,13 @@ class StepScalingActionProps:
16517
16573
 
16518
16574
  @builtins.property
16519
16575
  def cooldown(self) -> typing.Optional[_Duration_4839e8c3]:
16520
- '''Period after a scaling completes before another scaling activity can start.
16576
+ '''(deprecated) Period after a scaling completes before another scaling activity can start.
16521
16577
 
16522
16578
  :default: The default cooldown configured on the AutoScalingGroup
16579
+
16580
+ :deprecated: cooldown is not valid with step scaling action
16581
+
16582
+ :stability: deprecated
16523
16583
  '''
16524
16584
  result = self._values.get("cooldown")
16525
16585
  return typing.cast(typing.Optional[_Duration_4839e8c3], result)
@@ -17627,24 +17687,15 @@ class AutoScalingGroup(
17627
17687
 
17628
17688
  Example::
17629
17689
 
17630
- # vpc: ec2.Vpc
17631
- # instance_type: ec2.InstanceType
17632
- # machine_image: ec2.IMachineImage
17633
-
17634
-
17635
- autoscaling.AutoScalingGroup(self, "ASG",
17636
- vpc=vpc,
17637
- instance_type=instance_type,
17638
- machine_image=machine_image,
17690
+ # cluster: eks.Cluster
17691
+ # asg: autoscaling.AutoScalingGroup
17639
17692
 
17640
- # ...
17641
-
17642
- init=ec2.CloudFormationInit.from_elements(
17643
- ec2.InitFile.from_string("/etc/my_instance", "This got written during instance startup")),
17644
- signals=autoscaling.Signals.wait_for_all(
17645
- timeout=Duration.minutes(10)
17646
- )
17693
+ imported_cluster = eks.Cluster.from_cluster_attributes(self, "ImportedCluster",
17694
+ cluster_name=cluster.cluster_name,
17695
+ cluster_security_group_id=cluster.cluster_security_group_id
17647
17696
  )
17697
+
17698
+ imported_cluster.connect_auto_scaling_group_capacity(asg)
17648
17699
  '''
17649
17700
 
17650
17701
  def __init__(
@@ -17678,6 +17729,7 @@ class AutoScalingGroup(
17678
17729
  ignore_unmodified_size_properties: typing.Optional[builtins.bool] = None,
17679
17730
  instance_monitoring: typing.Optional[Monitoring] = None,
17680
17731
  key_name: typing.Optional[builtins.str] = None,
17732
+ key_pair: typing.Optional[_IKeyPair_bc344eda] = None,
17681
17733
  max_capacity: typing.Optional[jsii.Number] = None,
17682
17734
  max_instance_lifetime: typing.Optional[_Duration_4839e8c3] = None,
17683
17735
  min_capacity: typing.Optional[jsii.Number] = None,
@@ -17719,7 +17771,8 @@ class AutoScalingGroup(
17719
17771
  :param health_check: Configuration for health checks. Default: - HealthCheck.ec2 with no grace period
17720
17772
  :param ignore_unmodified_size_properties: If the ASG has scheduled actions, don't reset unchanged group sizes. Only used if the ASG has scheduled actions (which may scale your ASG up or down regardless of cdk deployments). If true, the size of the group will only be reset if it has been changed in the CDK app. If false, the sizes will always be changed back to what they were in the CDK app on deployment. Default: true
17721
17773
  :param instance_monitoring: Controls whether instances in this group are launched with detailed or basic monitoring. When detailed monitoring is enabled, Amazon CloudWatch generates metrics every minute and your account is charged a fee. When you disable detailed monitoring, CloudWatch generates metrics every 5 minutes. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified Default: - Monitoring.DETAILED
17722
- :param key_name: Name of SSH keypair to grant access to instances. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified Default: - No SSH access will be possible.
17774
+ :param key_name: (deprecated) Name of SSH keypair to grant access to instances. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified You can either specify ``keyPair`` or ``keyName``, not both. Default: - No SSH access will be possible.
17775
+ :param key_pair: The SSH keypair to grant access to the instance. Feature flag ``AUTOSCALING_GENERATE_LAUNCH_TEMPLATE`` must be enabled to use this property. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified. You can either specify ``keyPair`` or ``keyName``, not both. Default: - No SSH access will be possible.
17723
17776
  :param max_capacity: Maximum number of instances in the fleet. Default: desiredCapacity
17724
17777
  :param max_instance_lifetime: The maximum amount of time that an instance can be in service. The maximum duration applies to all current and future instances in the group. As an instance approaches its maximum duration, it is terminated and replaced, and cannot be used again. You must specify a value of at least 604,800 seconds (7 days). To clear a previously set value, leave this property undefined. Default: none
17725
17778
  :param min_capacity: Minimum number of instances in the fleet. Default: 1
@@ -17764,6 +17817,7 @@ class AutoScalingGroup(
17764
17817
  ignore_unmodified_size_properties=ignore_unmodified_size_properties,
17765
17818
  instance_monitoring=instance_monitoring,
17766
17819
  key_name=key_name,
17820
+ key_pair=key_pair,
17767
17821
  max_capacity=max_capacity,
17768
17822
  max_instance_lifetime=max_instance_lifetime,
17769
17823
  min_capacity=min_capacity,
@@ -18356,6 +18410,7 @@ class AutoScalingGroup(
18356
18410
  "ignore_unmodified_size_properties": "ignoreUnmodifiedSizeProperties",
18357
18411
  "instance_monitoring": "instanceMonitoring",
18358
18412
  "key_name": "keyName",
18413
+ "key_pair": "keyPair",
18359
18414
  "max_capacity": "maxCapacity",
18360
18415
  "max_instance_lifetime": "maxInstanceLifetime",
18361
18416
  "min_capacity": "minCapacity",
@@ -18400,6 +18455,7 @@ class AutoScalingGroupProps(CommonAutoScalingGroupProps):
18400
18455
  ignore_unmodified_size_properties: typing.Optional[builtins.bool] = None,
18401
18456
  instance_monitoring: typing.Optional[Monitoring] = None,
18402
18457
  key_name: typing.Optional[builtins.str] = None,
18458
+ key_pair: typing.Optional[_IKeyPair_bc344eda] = None,
18403
18459
  max_capacity: typing.Optional[jsii.Number] = None,
18404
18460
  max_instance_lifetime: typing.Optional[_Duration_4839e8c3] = None,
18405
18461
  min_capacity: typing.Optional[jsii.Number] = None,
@@ -18440,7 +18496,8 @@ class AutoScalingGroupProps(CommonAutoScalingGroupProps):
18440
18496
  :param health_check: Configuration for health checks. Default: - HealthCheck.ec2 with no grace period
18441
18497
  :param ignore_unmodified_size_properties: If the ASG has scheduled actions, don't reset unchanged group sizes. Only used if the ASG has scheduled actions (which may scale your ASG up or down regardless of cdk deployments). If true, the size of the group will only be reset if it has been changed in the CDK app. If false, the sizes will always be changed back to what they were in the CDK app on deployment. Default: true
18442
18498
  :param instance_monitoring: Controls whether instances in this group are launched with detailed or basic monitoring. When detailed monitoring is enabled, Amazon CloudWatch generates metrics every minute and your account is charged a fee. When you disable detailed monitoring, CloudWatch generates metrics every 5 minutes. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified Default: - Monitoring.DETAILED
18443
- :param key_name: Name of SSH keypair to grant access to instances. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified Default: - No SSH access will be possible.
18499
+ :param key_name: (deprecated) Name of SSH keypair to grant access to instances. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified You can either specify ``keyPair`` or ``keyName``, not both. Default: - No SSH access will be possible.
18500
+ :param key_pair: The SSH keypair to grant access to the instance. Feature flag ``AUTOSCALING_GENERATE_LAUNCH_TEMPLATE`` must be enabled to use this property. ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified. You can either specify ``keyPair`` or ``keyName``, not both. Default: - No SSH access will be possible.
18444
18501
  :param max_capacity: Maximum number of instances in the fleet. Default: desiredCapacity
18445
18502
  :param max_instance_lifetime: The maximum amount of time that an instance can be in service. The maximum duration applies to all current and future instances in the group. As an instance approaches its maximum duration, it is terminated and replaced, and cannot be used again. You must specify a value of at least 604,800 seconds (7 days). To clear a previously set value, leave this property undefined. Default: none
18446
18503
  :param min_capacity: Minimum number of instances in the fleet. Default: 1
@@ -18511,6 +18568,7 @@ class AutoScalingGroupProps(CommonAutoScalingGroupProps):
18511
18568
  check_type(argname="argument ignore_unmodified_size_properties", value=ignore_unmodified_size_properties, expected_type=type_hints["ignore_unmodified_size_properties"])
18512
18569
  check_type(argname="argument instance_monitoring", value=instance_monitoring, expected_type=type_hints["instance_monitoring"])
18513
18570
  check_type(argname="argument key_name", value=key_name, expected_type=type_hints["key_name"])
18571
+ check_type(argname="argument key_pair", value=key_pair, expected_type=type_hints["key_pair"])
18514
18572
  check_type(argname="argument max_capacity", value=max_capacity, expected_type=type_hints["max_capacity"])
18515
18573
  check_type(argname="argument max_instance_lifetime", value=max_instance_lifetime, expected_type=type_hints["max_instance_lifetime"])
18516
18574
  check_type(argname="argument min_capacity", value=min_capacity, expected_type=type_hints["min_capacity"])
@@ -18565,6 +18623,8 @@ class AutoScalingGroupProps(CommonAutoScalingGroupProps):
18565
18623
  self._values["instance_monitoring"] = instance_monitoring
18566
18624
  if key_name is not None:
18567
18625
  self._values["key_name"] = key_name
18626
+ if key_pair is not None:
18627
+ self._values["key_pair"] = key_pair
18568
18628
  if max_capacity is not None:
18569
18629
  self._values["max_capacity"] = max_capacity
18570
18630
  if max_instance_lifetime is not None:
@@ -18775,15 +18835,36 @@ class AutoScalingGroupProps(CommonAutoScalingGroupProps):
18775
18835
 
18776
18836
  @builtins.property
18777
18837
  def key_name(self) -> typing.Optional[builtins.str]:
18778
- '''Name of SSH keypair to grant access to instances.
18838
+ '''(deprecated) Name of SSH keypair to grant access to instances.
18779
18839
 
18780
18840
  ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified
18781
18841
 
18842
+ You can either specify ``keyPair`` or ``keyName``, not both.
18843
+
18782
18844
  :default: - No SSH access will be possible.
18845
+
18846
+ :deprecated: - Use ``keyPair`` instead - https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ec2-readme.html#using-an-existing-ec2-key-pair
18847
+
18848
+ :stability: deprecated
18783
18849
  '''
18784
18850
  result = self._values.get("key_name")
18785
18851
  return typing.cast(typing.Optional[builtins.str], result)
18786
18852
 
18853
+ @builtins.property
18854
+ def key_pair(self) -> typing.Optional[_IKeyPair_bc344eda]:
18855
+ '''The SSH keypair to grant access to the instance.
18856
+
18857
+ Feature flag ``AUTOSCALING_GENERATE_LAUNCH_TEMPLATE`` must be enabled to use this property.
18858
+
18859
+ ``launchTemplate`` and ``mixedInstancesPolicy`` must not be specified when this property is specified.
18860
+
18861
+ You can either specify ``keyPair`` or ``keyName``, not both.
18862
+
18863
+ :default: - No SSH access will be possible.
18864
+ '''
18865
+ result = self._values.get("key_pair")
18866
+ return typing.cast(typing.Optional[_IKeyPair_bc344eda], result)
18867
+
18787
18868
  @builtins.property
18788
18869
  def max_capacity(self) -> typing.Optional[jsii.Number]:
18789
18870
  '''Maximum number of instances in the fleet.
@@ -20873,6 +20954,7 @@ def _typecheckingstub__e7df3cbef8de53a463241b6e60846fac6e519118c7118785f8f4efb6d
20873
20954
  ignore_unmodified_size_properties: typing.Optional[builtins.bool] = None,
20874
20955
  instance_monitoring: typing.Optional[Monitoring] = None,
20875
20956
  key_name: typing.Optional[builtins.str] = None,
20957
+ key_pair: typing.Optional[_IKeyPair_bc344eda] = None,
20876
20958
  max_capacity: typing.Optional[jsii.Number] = None,
20877
20959
  max_instance_lifetime: typing.Optional[_Duration_4839e8c3] = None,
20878
20960
  min_capacity: typing.Optional[jsii.Number] = None,
@@ -21418,6 +21500,7 @@ def _typecheckingstub__82981fc74407321badee3133fda3bd0a016f4ab7634f761219c1c808c
21418
21500
  ignore_unmodified_size_properties: typing.Optional[builtins.bool] = None,
21419
21501
  instance_monitoring: typing.Optional[Monitoring] = None,
21420
21502
  key_name: typing.Optional[builtins.str] = None,
21503
+ key_pair: typing.Optional[_IKeyPair_bc344eda] = None,
21421
21504
  max_capacity: typing.Optional[jsii.Number] = None,
21422
21505
  max_instance_lifetime: typing.Optional[_Duration_4839e8c3] = None,
21423
21506
  min_capacity: typing.Optional[jsii.Number] = None,
@@ -21624,6 +21707,7 @@ def _typecheckingstub__186ff14d58334848486a7ecd802c6b72a1b76f272f25349712b95361e
21624
21707
  ignore_unmodified_size_properties: typing.Optional[builtins.bool] = None,
21625
21708
  instance_monitoring: typing.Optional[Monitoring] = None,
21626
21709
  key_name: typing.Optional[builtins.str] = None,
21710
+ key_pair: typing.Optional[_IKeyPair_bc344eda] = None,
21627
21711
  max_capacity: typing.Optional[jsii.Number] = None,
21628
21712
  max_instance_lifetime: typing.Optional[_Duration_4839e8c3] = None,
21629
21713
  min_capacity: typing.Optional[jsii.Number] = None,
@@ -544,13 +544,12 @@ Additionally, you can load the function's code from a file using the `FunctionCo
544
544
 
545
545
  If you set `autoPublish` to false, the function will not be automatically published to the LIVE stage when it’s created.
546
546
 
547
- ``ts
548
- new cloudfront.Function(this, 'Function', {
549
- code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'),
550
- runtime: cloudfront.FunctionRuntime.JS_2_0,
551
- autoPublish: false
552
- });
553
-
547
+ ```python
548
+ cloudfront.Function(self, "Function",
549
+ code=cloudfront.FunctionCode.from_inline("function handler(event) { return event.request }"),
550
+ runtime=cloudfront.FunctionRuntime.JS_2_0,
551
+ auto_publish=False
552
+ )
554
553
  ```
555
554
 
556
555
  ### Key Value Store
@@ -560,8 +559,8 @@ by default.
560
559
 
561
560
  To create an empty Key Value Store:
562
561
 
563
- ```ts
564
- const store = new cloudfront.KeyValueStore(this, 'KeyValueStore');
562
+ ```python
563
+ store = cloudfront.KeyValueStore(self, "KeyValueStore")
565
564
  ```
566
565
 
567
566
  To also include an initial set of values, the `source` property can be specified, either from a
@@ -16480,20 +16479,12 @@ class FunctionCode(
16480
16479
 
16481
16480
  Example::
16482
16481
 
16483
- # s3_bucket: s3.Bucket
16484
- # Add a cloudfront Function to a Distribution
16485
- cf_function = cloudfront.Function(self, "Function",
16482
+ store = cloudfront.KeyValueStore(self, "KeyValueStore")
16483
+ cloudfront.Function(self, "Function",
16486
16484
  code=cloudfront.FunctionCode.from_inline("function handler(event) { return event.request }"),
16487
- runtime=cloudfront.FunctionRuntime.JS_2_0
16488
- )
16489
- cloudfront.Distribution(self, "distro",
16490
- default_behavior=cloudfront.BehaviorOptions(
16491
- origin=origins.S3Origin(s3_bucket),
16492
- function_associations=[cloudfront.FunctionAssociation(
16493
- function=cf_function,
16494
- event_type=cloudfront.FunctionEventType.VIEWER_REQUEST
16495
- )]
16496
- )
16485
+ # Note that JS_2_0 must be used for Key Value Store support
16486
+ runtime=cloudfront.FunctionRuntime.JS_2_0,
16487
+ key_value_store=store
16497
16488
  )
16498
16489
  '''
16499
16490
 
@@ -16611,20 +16602,12 @@ class FunctionProps:
16611
16602
 
16612
16603
  Example::
16613
16604
 
16614
- # s3_bucket: s3.Bucket
16615
- # Add a cloudfront Function to a Distribution
16616
- cf_function = cloudfront.Function(self, "Function",
16605
+ store = cloudfront.KeyValueStore(self, "KeyValueStore")
16606
+ cloudfront.Function(self, "Function",
16617
16607
  code=cloudfront.FunctionCode.from_inline("function handler(event) { return event.request }"),
16618
- runtime=cloudfront.FunctionRuntime.JS_2_0
16619
- )
16620
- cloudfront.Distribution(self, "distro",
16621
- default_behavior=cloudfront.BehaviorOptions(
16622
- origin=origins.S3Origin(s3_bucket),
16623
- function_associations=[cloudfront.FunctionAssociation(
16624
- function=cf_function,
16625
- event_type=cloudfront.FunctionEventType.VIEWER_REQUEST
16626
- )]
16627
- )
16608
+ # Note that JS_2_0 must be used for Key Value Store support
16609
+ runtime=cloudfront.FunctionRuntime.JS_2_0,
16610
+ key_value_store=store
16628
16611
  )
16629
16612
  '''
16630
16613
  if __debug__:
@@ -16726,20 +16709,12 @@ class FunctionRuntime(
16726
16709
 
16727
16710
  Example::
16728
16711
 
16729
- # s3_bucket: s3.Bucket
16730
- # Add a cloudfront Function to a Distribution
16731
- cf_function = cloudfront.Function(self, "Function",
16712
+ store = cloudfront.KeyValueStore(self, "KeyValueStore")
16713
+ cloudfront.Function(self, "Function",
16732
16714
  code=cloudfront.FunctionCode.from_inline("function handler(event) { return event.request }"),
16733
- runtime=cloudfront.FunctionRuntime.JS_2_0
16734
- )
16735
- cloudfront.Distribution(self, "distro",
16736
- default_behavior=cloudfront.BehaviorOptions(
16737
- origin=origins.S3Origin(s3_bucket),
16738
- function_associations=[cloudfront.FunctionAssociation(
16739
- function=cf_function,
16740
- event_type=cloudfront.FunctionEventType.VIEWER_REQUEST
16741
- )]
16742
- )
16715
+ # Note that JS_2_0 must be used for Key Value Store support
16716
+ runtime=cloudfront.FunctionRuntime.JS_2_0,
16717
+ key_value_store=store
16743
16718
  )
16744
16719
  '''
16745
16720
 
@@ -17941,23 +17916,12 @@ class KeyValueStore(
17941
17916
 
17942
17917
  Example::
17943
17918
 
17944
- store_asset = cloudfront.KeyValueStore(self, "KeyValueStoreAsset",
17945
- key_value_store_name="KeyValueStoreAsset",
17946
- source=cloudfront.ImportSource.from_asset("path-to-data.json")
17947
- )
17948
-
17949
- store_inline = cloudfront.KeyValueStore(self, "KeyValueStoreInline",
17950
- key_value_store_name="KeyValueStoreInline",
17951
- source=cloudfront.ImportSource.from_inline(JSON.stringify({
17952
- "data": [{
17953
- "key": "key1",
17954
- "value": "value1"
17955
- }, {
17956
- "key": "key2",
17957
- "value": "value2"
17958
- }
17959
- ]
17960
- }))
17919
+ store = cloudfront.KeyValueStore(self, "KeyValueStore")
17920
+ cloudfront.Function(self, "Function",
17921
+ code=cloudfront.FunctionCode.from_inline("function handler(event) { return event.request }"),
17922
+ # Note that JS_2_0 must be used for Key Value Store support
17923
+ runtime=cloudfront.FunctionRuntime.JS_2_0,
17924
+ key_value_store=store
17961
17925
  )
17962
17926
  '''
17963
17927
 
@@ -23802,20 +23766,12 @@ class Function(
23802
23766
 
23803
23767
  Example::
23804
23768
 
23805
- # s3_bucket: s3.Bucket
23806
- # Add a cloudfront Function to a Distribution
23807
- cf_function = cloudfront.Function(self, "Function",
23769
+ store = cloudfront.KeyValueStore(self, "KeyValueStore")
23770
+ cloudfront.Function(self, "Function",
23808
23771
  code=cloudfront.FunctionCode.from_inline("function handler(event) { return event.request }"),
23809
- runtime=cloudfront.FunctionRuntime.JS_2_0
23810
- )
23811
- cloudfront.Distribution(self, "distro",
23812
- default_behavior=cloudfront.BehaviorOptions(
23813
- origin=origins.S3Origin(s3_bucket),
23814
- function_associations=[cloudfront.FunctionAssociation(
23815
- function=cf_function,
23816
- event_type=cloudfront.FunctionEventType.VIEWER_REQUEST
23817
- )]
23818
- )
23772
+ # Note that JS_2_0 must be used for Key Value Store support
23773
+ runtime=cloudfront.FunctionRuntime.JS_2_0,
23774
+ key_value_store=store
23819
23775
  )
23820
23776
  '''
23821
23777