aws-cdk-lib 2.191.0__py3-none-any.whl → 2.192.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 +18 -21
- aws_cdk/_jsii/__init__.py +1 -1
- aws_cdk/_jsii/{aws-cdk-lib@2.191.0.jsii.tgz → aws-cdk-lib@2.192.0.jsii.tgz} +0 -0
- aws_cdk/aws_apigateway/__init__.py +90 -19
- aws_cdk/aws_codepipeline/__init__.py +16 -0
- aws_cdk/aws_cognito_identitypool/__init__.py +9 -1
- aws_cdk/aws_ec2/__init__.py +39 -39
- aws_cdk/aws_ecs/__init__.py +230 -155
- aws_cdk/aws_events/__init__.py +38 -0
- aws_cdk/aws_iam/__init__.py +178 -0
- aws_cdk/aws_rds/__init__.py +12 -0
- aws_cdk/aws_servicediscovery/__init__.py +66 -36
- aws_cdk/aws_ses/__init__.py +44 -0
- {aws_cdk_lib-2.191.0.dist-info → aws_cdk_lib-2.192.0.dist-info}/METADATA +1 -1
- {aws_cdk_lib-2.191.0.dist-info → aws_cdk_lib-2.192.0.dist-info}/RECORD +19 -19
- {aws_cdk_lib-2.191.0.dist-info → aws_cdk_lib-2.192.0.dist-info}/LICENSE +0 -0
- {aws_cdk_lib-2.191.0.dist-info → aws_cdk_lib-2.192.0.dist-info}/NOTICE +0 -0
- {aws_cdk_lib-2.191.0.dist-info → aws_cdk_lib-2.192.0.dist-info}/WHEEL +0 -0
- {aws_cdk_lib-2.191.0.dist-info → aws_cdk_lib-2.192.0.dist-info}/top_level.txt +0 -0
aws_cdk/aws_ecs/__init__.py
CHANGED
|
@@ -19995,28 +19995,43 @@ class ClusterProps:
|
|
|
19995
19995
|
|
|
19996
19996
|
Example::
|
|
19997
19997
|
|
|
19998
|
-
vpc
|
|
19999
|
-
|
|
19998
|
+
# vpc: ec2.Vpc
|
|
19999
|
+
|
|
20000
|
+
|
|
20001
|
+
cluster = ecs.Cluster(self, "Cluster",
|
|
20002
|
+
vpc=vpc
|
|
20000
20003
|
)
|
|
20001
|
-
cluster = ecs.Cluster(self, "ECSCluster", vpc=vpc)
|
|
20002
20004
|
|
|
20003
|
-
|
|
20004
|
-
|
|
20005
|
-
|
|
20006
|
-
|
|
20005
|
+
auto_scaling_group = autoscaling.AutoScalingGroup(self, "ASG",
|
|
20006
|
+
vpc=vpc,
|
|
20007
|
+
instance_type=ec2.InstanceType("t2.micro"),
|
|
20008
|
+
machine_image=ecs.EcsOptimizedImage.amazon_linux2(),
|
|
20009
|
+
min_capacity=0,
|
|
20010
|
+
max_capacity=100
|
|
20007
20011
|
)
|
|
20008
20012
|
|
|
20009
|
-
|
|
20010
|
-
|
|
20013
|
+
capacity_provider = ecs.AsgCapacityProvider(self, "AsgCapacityProvider",
|
|
20014
|
+
auto_scaling_group=auto_scaling_group,
|
|
20015
|
+
instance_warmup_period=300
|
|
20011
20016
|
)
|
|
20017
|
+
cluster.add_asg_capacity_provider(capacity_provider)
|
|
20012
20018
|
|
|
20013
|
-
|
|
20014
|
-
|
|
20019
|
+
task_definition = ecs.Ec2TaskDefinition(self, "TaskDef")
|
|
20020
|
+
|
|
20021
|
+
task_definition.add_container("web",
|
|
20022
|
+
image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
|
|
20023
|
+
memory_reservation_mi_b=256
|
|
20024
|
+
)
|
|
20025
|
+
|
|
20026
|
+
ecs.Ec2Service(self, "EC2Service",
|
|
20015
20027
|
cluster=cluster,
|
|
20016
20028
|
task_definition=task_definition,
|
|
20017
|
-
|
|
20018
|
-
|
|
20019
|
-
|
|
20029
|
+
min_healthy_percent=100,
|
|
20030
|
+
capacity_provider_strategies=[ecs.CapacityProviderStrategy(
|
|
20031
|
+
capacity_provider=capacity_provider.capacity_provider_name,
|
|
20032
|
+
weight=1
|
|
20033
|
+
)
|
|
20034
|
+
]
|
|
20020
20035
|
)
|
|
20021
20036
|
'''
|
|
20022
20037
|
if isinstance(capacity, dict):
|
|
@@ -21173,26 +21188,34 @@ class ContainerDefinitionOptions:
|
|
|
21173
21188
|
|
|
21174
21189
|
Example::
|
|
21175
21190
|
|
|
21191
|
+
# task_definition: ecs.TaskDefinition
|
|
21176
21192
|
# cluster: ecs.Cluster
|
|
21177
|
-
# vpc: ec2.Vpc
|
|
21178
21193
|
|
|
21179
|
-
|
|
21194
|
+
|
|
21195
|
+
# Add a container to the task definition
|
|
21196
|
+
specific_container = task_definition.add_container("Container",
|
|
21197
|
+
image=ecs.ContainerImage.from_registry("/aws/aws-example-app"),
|
|
21198
|
+
memory_limit_mi_b=2048
|
|
21199
|
+
)
|
|
21200
|
+
|
|
21201
|
+
# Add a port mapping
|
|
21202
|
+
specific_container.add_port_mappings(
|
|
21203
|
+
container_port=7600,
|
|
21204
|
+
protocol=ecs.Protocol.TCP
|
|
21205
|
+
)
|
|
21206
|
+
|
|
21207
|
+
ecs.Ec2Service(self, "Service",
|
|
21180
21208
|
cluster=cluster,
|
|
21181
|
-
|
|
21182
|
-
desired_count=1,
|
|
21209
|
+
task_definition=task_definition,
|
|
21183
21210
|
min_healthy_percent=100,
|
|
21184
|
-
|
|
21185
|
-
|
|
21186
|
-
|
|
21187
|
-
|
|
21188
|
-
|
|
21189
|
-
|
|
21211
|
+
cloud_map_options=ecs.CloudMapOptions(
|
|
21212
|
+
# Create SRV records - useful for bridge networking
|
|
21213
|
+
dns_record_type=cloudmap.DnsRecordType.SRV,
|
|
21214
|
+
# Targets port TCP port 7600 `specificContainer`
|
|
21215
|
+
container=specific_container,
|
|
21216
|
+
container_port=7600
|
|
21190
21217
|
)
|
|
21191
21218
|
)
|
|
21192
|
-
|
|
21193
|
-
service.task_definition.add_container("Sidecar",
|
|
21194
|
-
image=ecs.ContainerImage.from_registry("example/metrics-sidecar")
|
|
21195
|
-
)
|
|
21196
21219
|
'''
|
|
21197
21220
|
if isinstance(health_check, dict):
|
|
21198
21221
|
health_check = HealthCheck(**health_check)
|
|
@@ -22674,32 +22697,24 @@ class ContainerImage(
|
|
|
22674
22697
|
|
|
22675
22698
|
Example::
|
|
22676
22699
|
|
|
22677
|
-
#
|
|
22700
|
+
# my_file_system: efs.IFileSystem
|
|
22701
|
+
# my_job_role: iam.Role
|
|
22678
22702
|
|
|
22703
|
+
my_file_system.grant_read(my_job_role)
|
|
22679
22704
|
|
|
22680
|
-
|
|
22681
|
-
|
|
22682
|
-
|
|
22683
|
-
|
|
22684
|
-
|
|
22685
|
-
|
|
22686
|
-
|
|
22687
|
-
|
|
22688
|
-
|
|
22689
|
-
|
|
22690
|
-
|
|
22691
|
-
|
|
22692
|
-
cluster=cluster,
|
|
22693
|
-
task_definition=task_definition,
|
|
22694
|
-
min_healthy_percent=100,
|
|
22695
|
-
capacity_provider_strategies=[ecs.CapacityProviderStrategy(
|
|
22696
|
-
capacity_provider="FARGATE_SPOT",
|
|
22697
|
-
weight=2
|
|
22698
|
-
), ecs.CapacityProviderStrategy(
|
|
22699
|
-
capacity_provider="FARGATE",
|
|
22700
|
-
weight=1
|
|
22705
|
+
job_defn = batch.EcsJobDefinition(self, "JobDefn",
|
|
22706
|
+
container=batch.EcsEc2ContainerDefinition(self, "containerDefn",
|
|
22707
|
+
image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
|
|
22708
|
+
memory=cdk.Size.mebibytes(2048),
|
|
22709
|
+
cpu=256,
|
|
22710
|
+
volumes=[batch.EcsVolume.efs(
|
|
22711
|
+
name="myVolume",
|
|
22712
|
+
file_system=my_file_system,
|
|
22713
|
+
container_path="/Volumes/myVolume",
|
|
22714
|
+
use_job_role=True
|
|
22715
|
+
)],
|
|
22716
|
+
job_role=my_job_role
|
|
22701
22717
|
)
|
|
22702
|
-
]
|
|
22703
22718
|
)
|
|
22704
22719
|
'''
|
|
22705
22720
|
|
|
@@ -24372,18 +24387,31 @@ class Ec2ServiceProps(BaseServiceOptions):
|
|
|
24372
24387
|
|
|
24373
24388
|
Example::
|
|
24374
24389
|
|
|
24375
|
-
# cluster: ecs.Cluster
|
|
24376
|
-
# task_definition: ecs.TaskDefinition
|
|
24377
24390
|
# vpc: ec2.Vpc
|
|
24378
24391
|
|
|
24379
|
-
service = ecs.Ec2Service(self, "Service", cluster=cluster, task_definition=task_definition, min_healthy_percent=100)
|
|
24380
24392
|
|
|
24381
|
-
|
|
24382
|
-
|
|
24383
|
-
|
|
24384
|
-
|
|
24385
|
-
|
|
24386
|
-
|
|
24393
|
+
# Create an ECS cluster
|
|
24394
|
+
cluster = ecs.Cluster(self, "Cluster", vpc=vpc)
|
|
24395
|
+
|
|
24396
|
+
# Add capacity to it
|
|
24397
|
+
cluster.add_capacity("DefaultAutoScalingGroupCapacity",
|
|
24398
|
+
instance_type=ec2.InstanceType("t2.xlarge"),
|
|
24399
|
+
desired_capacity=3
|
|
24400
|
+
)
|
|
24401
|
+
|
|
24402
|
+
task_definition = ecs.Ec2TaskDefinition(self, "TaskDef")
|
|
24403
|
+
|
|
24404
|
+
task_definition.add_container("DefaultContainer",
|
|
24405
|
+
image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
|
|
24406
|
+
memory_limit_mi_b=512
|
|
24407
|
+
)
|
|
24408
|
+
|
|
24409
|
+
# Instantiate an Amazon ECS Service
|
|
24410
|
+
ecs_service = ecs.Ec2Service(self, "Service",
|
|
24411
|
+
cluster=cluster,
|
|
24412
|
+
task_definition=task_definition,
|
|
24413
|
+
min_healthy_percent=100
|
|
24414
|
+
)
|
|
24387
24415
|
'''
|
|
24388
24416
|
if isinstance(circuit_breaker, dict):
|
|
24389
24417
|
circuit_breaker = DeploymentCircuitBreaker(**circuit_breaker)
|
|
@@ -24927,13 +24955,14 @@ class Ec2TaskDefinitionProps(CommonTaskDefinitionProps):
|
|
|
24927
24955
|
|
|
24928
24956
|
Example::
|
|
24929
24957
|
|
|
24930
|
-
|
|
24931
|
-
|
|
24932
|
-
|
|
24933
|
-
}]
|
|
24958
|
+
ec2_task_definition = ecs.Ec2TaskDefinition(self, "TaskDef",
|
|
24959
|
+
network_mode=ecs.NetworkMode.BRIDGE
|
|
24960
|
+
)
|
|
24934
24961
|
|
|
24935
|
-
|
|
24936
|
-
|
|
24962
|
+
container = ec2_task_definition.add_container("WebContainer",
|
|
24963
|
+
# Use an image from DockerHub
|
|
24964
|
+
image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
|
|
24965
|
+
memory_limit_mi_b=1024
|
|
24937
24966
|
)
|
|
24938
24967
|
'''
|
|
24939
24968
|
if __debug__:
|
|
@@ -27180,21 +27209,39 @@ class FargateServiceProps(BaseServiceOptions):
|
|
|
27180
27209
|
|
|
27181
27210
|
Example::
|
|
27182
27211
|
|
|
27212
|
+
import aws_cdk.aws_cloudwatch as cw
|
|
27213
|
+
|
|
27183
27214
|
# cluster: ecs.Cluster
|
|
27184
27215
|
# task_definition: ecs.TaskDefinition
|
|
27185
|
-
# vpc: ec2.Vpc
|
|
27186
27216
|
|
|
27187
|
-
|
|
27217
|
+
service_name = "MyFargateService"
|
|
27218
|
+
service = ecs.FargateService(self, "Service",
|
|
27219
|
+
service_name=service_name,
|
|
27220
|
+
cluster=cluster,
|
|
27221
|
+
task_definition=task_definition,
|
|
27222
|
+
min_healthy_percent=100
|
|
27223
|
+
)
|
|
27188
27224
|
|
|
27189
|
-
|
|
27190
|
-
|
|
27191
|
-
|
|
27192
|
-
|
|
27193
|
-
|
|
27194
|
-
|
|
27195
|
-
|
|
27196
|
-
|
|
27197
|
-
|
|
27225
|
+
cpu_metric = cw.Metric(
|
|
27226
|
+
metric_name="CPUUtilization",
|
|
27227
|
+
namespace="AWS/ECS",
|
|
27228
|
+
period=Duration.minutes(5),
|
|
27229
|
+
statistic="Average",
|
|
27230
|
+
dimensions_map={
|
|
27231
|
+
"ClusterName": cluster.cluster_name,
|
|
27232
|
+
# Using `service.serviceName` here will cause a circular dependency
|
|
27233
|
+
"ServiceName": service_name
|
|
27234
|
+
}
|
|
27235
|
+
)
|
|
27236
|
+
my_alarm = cw.Alarm(self, "CPUAlarm",
|
|
27237
|
+
alarm_name="cpuAlarmName",
|
|
27238
|
+
metric=cpu_metric,
|
|
27239
|
+
evaluation_periods=2,
|
|
27240
|
+
threshold=80
|
|
27241
|
+
)
|
|
27242
|
+
|
|
27243
|
+
service.enable_deployment_alarms([my_alarm.alarm_name],
|
|
27244
|
+
behavior=ecs.AlarmBehavior.FAIL_ON_ALARM
|
|
27198
27245
|
)
|
|
27199
27246
|
'''
|
|
27200
27247
|
if isinstance(circuit_breaker, dict):
|
|
@@ -27699,14 +27746,20 @@ class FargateTaskDefinitionProps(CommonTaskDefinitionProps):
|
|
|
27699
27746
|
|
|
27700
27747
|
Example::
|
|
27701
27748
|
|
|
27702
|
-
|
|
27749
|
+
# Create a Task Definition for the Windows container to start
|
|
27750
|
+
task_definition = ecs.FargateTaskDefinition(self, "TaskDef",
|
|
27703
27751
|
runtime_platform=ecs.RuntimePlatform(
|
|
27704
|
-
operating_system_family=ecs.OperatingSystemFamily.
|
|
27705
|
-
cpu_architecture=ecs.CpuArchitecture.
|
|
27752
|
+
operating_system_family=ecs.OperatingSystemFamily.WINDOWS_SERVER_2019_CORE,
|
|
27753
|
+
cpu_architecture=ecs.CpuArchitecture.X86_64
|
|
27706
27754
|
),
|
|
27707
|
-
|
|
27708
|
-
|
|
27709
|
-
|
|
27755
|
+
cpu=1024,
|
|
27756
|
+
memory_limit_mi_b=2048
|
|
27757
|
+
)
|
|
27758
|
+
|
|
27759
|
+
task_definition.add_container("windowsservercore",
|
|
27760
|
+
logging=ecs.LogDriver.aws_logs(stream_prefix="win-iis-on-fargate"),
|
|
27761
|
+
port_mappings=[ecs.PortMapping(container_port=80)],
|
|
27762
|
+
image=ecs.ContainerImage.from_registry("mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019")
|
|
27710
27763
|
)
|
|
27711
27764
|
'''
|
|
27712
27765
|
if isinstance(runtime_platform, dict):
|
|
@@ -35281,22 +35334,29 @@ class ServiceConnectProps:
|
|
|
35281
35334
|
|
|
35282
35335
|
# cluster: ecs.Cluster
|
|
35283
35336
|
# task_definition: ecs.TaskDefinition
|
|
35337
|
+
# container_options: ecs.ContainerDefinitionOptions
|
|
35338
|
+
|
|
35339
|
+
|
|
35340
|
+
container = task_definition.add_container("MyContainer", container_options)
|
|
35341
|
+
|
|
35342
|
+
container.add_port_mappings(
|
|
35343
|
+
name="api",
|
|
35344
|
+
container_port=8080
|
|
35345
|
+
)
|
|
35284
35346
|
|
|
35347
|
+
cluster.add_default_cloud_map_namespace(
|
|
35348
|
+
name="local"
|
|
35349
|
+
)
|
|
35285
35350
|
|
|
35286
|
-
|
|
35351
|
+
service = ecs.FargateService(self, "Service",
|
|
35287
35352
|
cluster=cluster,
|
|
35288
35353
|
task_definition=task_definition,
|
|
35289
35354
|
min_healthy_percent=100,
|
|
35290
35355
|
service_connect_configuration=ecs.ServiceConnectProps(
|
|
35291
|
-
log_driver=ecs.LogDrivers.aws_logs(
|
|
35292
|
-
stream_prefix="sc-traffic"
|
|
35293
|
-
),
|
|
35294
35356
|
services=[ecs.ServiceConnectService(
|
|
35295
35357
|
port_mapping_name="api",
|
|
35296
|
-
dns_name="
|
|
35297
|
-
port=80
|
|
35298
|
-
ingress_port_override=20040,
|
|
35299
|
-
discovery_name="custom"
|
|
35358
|
+
dns_name="http-api",
|
|
35359
|
+
port=80
|
|
35300
35360
|
)
|
|
35301
35361
|
]
|
|
35302
35362
|
)
|
|
@@ -37234,28 +37294,21 @@ class TaskDefinition(
|
|
|
37234
37294
|
|
|
37235
37295
|
Example::
|
|
37236
37296
|
|
|
37237
|
-
import aws_cdk.aws_cloudwatch as cw
|
|
37238
|
-
|
|
37239
37297
|
# cluster: ecs.Cluster
|
|
37240
37298
|
# task_definition: ecs.TaskDefinition
|
|
37299
|
+
# vpc: ec2.Vpc
|
|
37241
37300
|
|
|
37301
|
+
service = ecs.FargateService(self, "Service", cluster=cluster, task_definition=task_definition, min_healthy_percent=100)
|
|
37242
37302
|
|
|
37243
|
-
|
|
37244
|
-
|
|
37245
|
-
|
|
37246
|
-
|
|
37247
|
-
|
|
37248
|
-
|
|
37249
|
-
|
|
37250
|
-
|
|
37251
|
-
|
|
37252
|
-
evaluation_periods=2,
|
|
37253
|
-
threshold=80
|
|
37254
|
-
)
|
|
37255
|
-
|
|
37256
|
-
# Using `myAlarm.alarmName` here will cause a circular dependency
|
|
37257
|
-
service.enable_deployment_alarms([cpu_alarm_name],
|
|
37258
|
-
behavior=ecs.AlarmBehavior.FAIL_ON_ALARM
|
|
37303
|
+
lb = elbv2.ApplicationLoadBalancer(self, "LB", vpc=vpc, internet_facing=True)
|
|
37304
|
+
listener = lb.add_listener("Listener", port=80)
|
|
37305
|
+
service.register_load_balancer_targets(
|
|
37306
|
+
container_name="web",
|
|
37307
|
+
container_port=80,
|
|
37308
|
+
new_target_group_id="ECS",
|
|
37309
|
+
listener=ecs.ListenerConfig.application_listener(listener,
|
|
37310
|
+
protocol=elbv2.ApplicationProtocol.HTTPS
|
|
37311
|
+
)
|
|
37259
37312
|
)
|
|
37260
37313
|
'''
|
|
37261
37314
|
|
|
@@ -39648,31 +39701,24 @@ class Cluster(
|
|
|
39648
39701
|
|
|
39649
39702
|
Example::
|
|
39650
39703
|
|
|
39651
|
-
|
|
39704
|
+
from aws_cdk import Tags
|
|
39652
39705
|
|
|
39653
39706
|
|
|
39654
|
-
|
|
39655
|
-
vpc = ec2.Vpc(self, "Vpc",
|
|
39656
|
-
ip_protocol=ec2.IpProtocol.DUAL_STACK
|
|
39657
|
-
)
|
|
39707
|
+
vpc = ec2.Vpc(self, "Vpc", max_azs=1)
|
|
39658
39708
|
cluster = ecs.Cluster(self, "EcsCluster", vpc=vpc)
|
|
39659
|
-
|
|
39660
|
-
|
|
39661
|
-
|
|
39662
|
-
task_image_options=ecsPatterns.ApplicationLoadBalancedTaskImageOptions(
|
|
39663
|
-
image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample")
|
|
39664
|
-
),
|
|
39665
|
-
min_healthy_percent=100,
|
|
39666
|
-
ip_address_type=elbv2.IpAddressType.DUAL_STACK
|
|
39709
|
+
task_definition = ecs.FargateTaskDefinition(self, "TaskDef",
|
|
39710
|
+
memory_limit_mi_b=512,
|
|
39711
|
+
cpu=256
|
|
39667
39712
|
)
|
|
39668
|
-
|
|
39669
|
-
|
|
39713
|
+
task_definition.add_container("WebContainer",
|
|
39714
|
+
image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample")
|
|
39715
|
+
)
|
|
39716
|
+
Tags.of(task_definition).add("my-tag", "my-tag-value")
|
|
39717
|
+
scheduled_fargate_task = ecs_patterns.ScheduledFargateTask(self, "ScheduledFargateTask",
|
|
39670
39718
|
cluster=cluster,
|
|
39671
|
-
|
|
39672
|
-
|
|
39673
|
-
|
|
39674
|
-
min_healthy_percent=100,
|
|
39675
|
-
ip_address_type=elbv2.IpAddressType.DUAL_STACK
|
|
39719
|
+
task_definition=task_definition,
|
|
39720
|
+
schedule=appscaling.Schedule.expression("rate(1 minute)"),
|
|
39721
|
+
propagate_tags=ecs.PropagatedTagSource.TASK_DEFINITION
|
|
39676
39722
|
)
|
|
39677
39723
|
'''
|
|
39678
39724
|
|
|
@@ -41663,18 +41709,31 @@ class Ec2Service(
|
|
|
41663
41709
|
|
|
41664
41710
|
Example::
|
|
41665
41711
|
|
|
41666
|
-
# cluster: ecs.Cluster
|
|
41667
|
-
# task_definition: ecs.TaskDefinition
|
|
41668
41712
|
# vpc: ec2.Vpc
|
|
41669
41713
|
|
|
41670
|
-
service = ecs.Ec2Service(self, "Service", cluster=cluster, task_definition=task_definition, min_healthy_percent=100)
|
|
41671
41714
|
|
|
41672
|
-
|
|
41673
|
-
|
|
41674
|
-
|
|
41675
|
-
|
|
41676
|
-
|
|
41677
|
-
|
|
41715
|
+
# Create an ECS cluster
|
|
41716
|
+
cluster = ecs.Cluster(self, "Cluster", vpc=vpc)
|
|
41717
|
+
|
|
41718
|
+
# Add capacity to it
|
|
41719
|
+
cluster.add_capacity("DefaultAutoScalingGroupCapacity",
|
|
41720
|
+
instance_type=ec2.InstanceType("t2.xlarge"),
|
|
41721
|
+
desired_capacity=3
|
|
41722
|
+
)
|
|
41723
|
+
|
|
41724
|
+
task_definition = ecs.Ec2TaskDefinition(self, "TaskDef")
|
|
41725
|
+
|
|
41726
|
+
task_definition.add_container("DefaultContainer",
|
|
41727
|
+
image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
|
|
41728
|
+
memory_limit_mi_b=512
|
|
41729
|
+
)
|
|
41730
|
+
|
|
41731
|
+
# Instantiate an Amazon ECS Service
|
|
41732
|
+
ecs_service = ecs.Ec2Service(self, "Service",
|
|
41733
|
+
cluster=cluster,
|
|
41734
|
+
task_definition=task_definition,
|
|
41735
|
+
min_healthy_percent=100
|
|
41736
|
+
)
|
|
41678
41737
|
'''
|
|
41679
41738
|
|
|
41680
41739
|
def __init__(
|
|
@@ -41879,17 +41938,15 @@ class Ec2TaskDefinition(
|
|
|
41879
41938
|
|
|
41880
41939
|
Example::
|
|
41881
41940
|
|
|
41882
|
-
# secret: ecs.Secret
|
|
41883
|
-
|
|
41884
|
-
|
|
41885
41941
|
# Create a Task Definition for the container to start
|
|
41886
41942
|
task_definition = ecs.Ec2TaskDefinition(self, "TaskDef")
|
|
41887
41943
|
task_definition.add_container("TheContainer",
|
|
41888
41944
|
image=ecs.ContainerImage.from_registry("example-image"),
|
|
41889
41945
|
memory_limit_mi_b=256,
|
|
41890
|
-
logging=ecs.LogDrivers.
|
|
41891
|
-
|
|
41892
|
-
|
|
41946
|
+
logging=ecs.LogDrivers.aws_logs(
|
|
41947
|
+
stream_prefix="EventDemo",
|
|
41948
|
+
mode=ecs.AwsLogDriverMode.NON_BLOCKING,
|
|
41949
|
+
max_buffer_size=Size.mebibytes(25)
|
|
41893
41950
|
)
|
|
41894
41951
|
)
|
|
41895
41952
|
'''
|
|
@@ -42593,21 +42650,39 @@ class FargateService(
|
|
|
42593
42650
|
|
|
42594
42651
|
Example::
|
|
42595
42652
|
|
|
42653
|
+
import aws_cdk.aws_cloudwatch as cw
|
|
42654
|
+
|
|
42596
42655
|
# cluster: ecs.Cluster
|
|
42597
42656
|
# task_definition: ecs.TaskDefinition
|
|
42598
|
-
# vpc: ec2.Vpc
|
|
42599
42657
|
|
|
42600
|
-
|
|
42658
|
+
service_name = "MyFargateService"
|
|
42659
|
+
service = ecs.FargateService(self, "Service",
|
|
42660
|
+
service_name=service_name,
|
|
42661
|
+
cluster=cluster,
|
|
42662
|
+
task_definition=task_definition,
|
|
42663
|
+
min_healthy_percent=100
|
|
42664
|
+
)
|
|
42601
42665
|
|
|
42602
|
-
|
|
42603
|
-
|
|
42604
|
-
|
|
42605
|
-
|
|
42606
|
-
|
|
42607
|
-
|
|
42608
|
-
|
|
42609
|
-
|
|
42610
|
-
|
|
42666
|
+
cpu_metric = cw.Metric(
|
|
42667
|
+
metric_name="CPUUtilization",
|
|
42668
|
+
namespace="AWS/ECS",
|
|
42669
|
+
period=Duration.minutes(5),
|
|
42670
|
+
statistic="Average",
|
|
42671
|
+
dimensions_map={
|
|
42672
|
+
"ClusterName": cluster.cluster_name,
|
|
42673
|
+
# Using `service.serviceName` here will cause a circular dependency
|
|
42674
|
+
"ServiceName": service_name
|
|
42675
|
+
}
|
|
42676
|
+
)
|
|
42677
|
+
my_alarm = cw.Alarm(self, "CPUAlarm",
|
|
42678
|
+
alarm_name="cpuAlarmName",
|
|
42679
|
+
metric=cpu_metric,
|
|
42680
|
+
evaluation_periods=2,
|
|
42681
|
+
threshold=80
|
|
42682
|
+
)
|
|
42683
|
+
|
|
42684
|
+
service.enable_deployment_alarms([my_alarm.alarm_name],
|
|
42685
|
+
behavior=ecs.AlarmBehavior.FAIL_ON_ALARM
|
|
42611
42686
|
)
|
|
42612
42687
|
'''
|
|
42613
42688
|
|
aws_cdk/aws_events/__init__.py
CHANGED
|
@@ -89,6 +89,22 @@ on_commit_rule.add_target(targets.SnsTopic(topic,
|
|
|
89
89
|
))
|
|
90
90
|
```
|
|
91
91
|
|
|
92
|
+
### Role
|
|
93
|
+
|
|
94
|
+
You can specify an IAM Role:
|
|
95
|
+
|
|
96
|
+
```python
|
|
97
|
+
# role: iam.IRole
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
events.Rule(self, "MyRule",
|
|
101
|
+
schedule=events.Schedule.cron(minute="0", hour="4"),
|
|
102
|
+
role=role
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
**Note**: If you're setting an event bus in another account as the target and that account granted permission to your account through an organization instead of directly by the account ID, you must specify a RoleArn with proper permissions in the Target structure, instead of here in this parameter.
|
|
107
|
+
|
|
92
108
|
### Matchers
|
|
93
109
|
|
|
94
110
|
To define a pattern, use the `Match` class, which provides a number of factory methods to declare
|
|
@@ -10518,6 +10534,7 @@ class Rule(
|
|
|
10518
10534
|
*,
|
|
10519
10535
|
enabled: typing.Optional[builtins.bool] = None,
|
|
10520
10536
|
event_bus: typing.Optional[IEventBus] = None,
|
|
10537
|
+
role: typing.Optional[_IRole_235f5d8e] = None,
|
|
10521
10538
|
schedule: typing.Optional["Schedule"] = None,
|
|
10522
10539
|
targets: typing.Optional[typing.Sequence[IRuleTarget]] = None,
|
|
10523
10540
|
cross_stack_scope: typing.Optional[_constructs_77d1e7e8.Construct] = None,
|
|
@@ -10530,6 +10547,7 @@ class Rule(
|
|
|
10530
10547
|
:param id: -
|
|
10531
10548
|
:param enabled: Indicates whether the rule is enabled. Default: true
|
|
10532
10549
|
:param event_bus: The event bus to associate with this rule. Default: - The default event bus.
|
|
10550
|
+
:param role: The role that is used for target invocation. Must be assumable by principal ``events.amazonaws.com``. Default: - No role associated
|
|
10533
10551
|
:param schedule: The schedule or rate (frequency) that determines when EventBridge runs the rule. You must specify this property, the ``eventPattern`` property, or both. For more information, see Schedule Expression Syntax for Rules in the Amazon EventBridge User Guide. Default: - None.
|
|
10534
10552
|
:param targets: Targets to invoke when this rule matches an event. Input will be the full matched event. If you wish to specify custom target input, use ``addTarget(target[, inputOptions])``. Default: - No targets.
|
|
10535
10553
|
:param cross_stack_scope: The scope to use if the source of the rule and its target are in different Stacks (but in the same account & region). This helps dealing with cycles that often arise in these situations. Default: - none (the main scope will be used, even for cross-stack Events)
|
|
@@ -10544,6 +10562,7 @@ class Rule(
|
|
|
10544
10562
|
props = RuleProps(
|
|
10545
10563
|
enabled=enabled,
|
|
10546
10564
|
event_bus=event_bus,
|
|
10565
|
+
role=role,
|
|
10547
10566
|
schedule=schedule,
|
|
10548
10567
|
targets=targets,
|
|
10549
10568
|
cross_stack_scope=cross_stack_scope,
|
|
@@ -10686,6 +10705,7 @@ class Rule(
|
|
|
10686
10705
|
"rule_name": "ruleName",
|
|
10687
10706
|
"enabled": "enabled",
|
|
10688
10707
|
"event_bus": "eventBus",
|
|
10708
|
+
"role": "role",
|
|
10689
10709
|
"schedule": "schedule",
|
|
10690
10710
|
"targets": "targets",
|
|
10691
10711
|
},
|
|
@@ -10700,6 +10720,7 @@ class RuleProps(EventCommonOptions):
|
|
|
10700
10720
|
rule_name: typing.Optional[builtins.str] = None,
|
|
10701
10721
|
enabled: typing.Optional[builtins.bool] = None,
|
|
10702
10722
|
event_bus: typing.Optional[IEventBus] = None,
|
|
10723
|
+
role: typing.Optional[_IRole_235f5d8e] = None,
|
|
10703
10724
|
schedule: typing.Optional["Schedule"] = None,
|
|
10704
10725
|
targets: typing.Optional[typing.Sequence[IRuleTarget]] = None,
|
|
10705
10726
|
) -> None:
|
|
@@ -10711,6 +10732,7 @@ class RuleProps(EventCommonOptions):
|
|
|
10711
10732
|
:param rule_name: A name for the rule. Default: AWS CloudFormation generates a unique physical ID.
|
|
10712
10733
|
:param enabled: Indicates whether the rule is enabled. Default: true
|
|
10713
10734
|
:param event_bus: The event bus to associate with this rule. Default: - The default event bus.
|
|
10735
|
+
:param role: The role that is used for target invocation. Must be assumable by principal ``events.amazonaws.com``. Default: - No role associated
|
|
10714
10736
|
:param schedule: The schedule or rate (frequency) that determines when EventBridge runs the rule. You must specify this property, the ``eventPattern`` property, or both. For more information, see Schedule Expression Syntax for Rules in the Amazon EventBridge User Guide. Default: - None.
|
|
10715
10737
|
:param targets: Targets to invoke when this rule matches an event. Input will be the full matched event. If you wish to specify custom target input, use ``addTarget(target[, inputOptions])``. Default: - No targets.
|
|
10716
10738
|
|
|
@@ -10745,6 +10767,7 @@ class RuleProps(EventCommonOptions):
|
|
|
10745
10767
|
check_type(argname="argument rule_name", value=rule_name, expected_type=type_hints["rule_name"])
|
|
10746
10768
|
check_type(argname="argument enabled", value=enabled, expected_type=type_hints["enabled"])
|
|
10747
10769
|
check_type(argname="argument event_bus", value=event_bus, expected_type=type_hints["event_bus"])
|
|
10770
|
+
check_type(argname="argument role", value=role, expected_type=type_hints["role"])
|
|
10748
10771
|
check_type(argname="argument schedule", value=schedule, expected_type=type_hints["schedule"])
|
|
10749
10772
|
check_type(argname="argument targets", value=targets, expected_type=type_hints["targets"])
|
|
10750
10773
|
self._values: typing.Dict[builtins.str, typing.Any] = {}
|
|
@@ -10760,6 +10783,8 @@ class RuleProps(EventCommonOptions):
|
|
|
10760
10783
|
self._values["enabled"] = enabled
|
|
10761
10784
|
if event_bus is not None:
|
|
10762
10785
|
self._values["event_bus"] = event_bus
|
|
10786
|
+
if role is not None:
|
|
10787
|
+
self._values["role"] = role
|
|
10763
10788
|
if schedule is not None:
|
|
10764
10789
|
self._values["schedule"] = schedule
|
|
10765
10790
|
if targets is not None:
|
|
@@ -10827,6 +10852,17 @@ class RuleProps(EventCommonOptions):
|
|
|
10827
10852
|
result = self._values.get("event_bus")
|
|
10828
10853
|
return typing.cast(typing.Optional[IEventBus], result)
|
|
10829
10854
|
|
|
10855
|
+
@builtins.property
|
|
10856
|
+
def role(self) -> typing.Optional[_IRole_235f5d8e]:
|
|
10857
|
+
'''The role that is used for target invocation.
|
|
10858
|
+
|
|
10859
|
+
Must be assumable by principal ``events.amazonaws.com``.
|
|
10860
|
+
|
|
10861
|
+
:default: - No role associated
|
|
10862
|
+
'''
|
|
10863
|
+
result = self._values.get("role")
|
|
10864
|
+
return typing.cast(typing.Optional[_IRole_235f5d8e], result)
|
|
10865
|
+
|
|
10830
10866
|
@builtins.property
|
|
10831
10867
|
def schedule(self) -> typing.Optional["Schedule"]:
|
|
10832
10868
|
'''The schedule or rate (frequency) that determines when EventBridge runs the rule.
|
|
@@ -13564,6 +13600,7 @@ def _typecheckingstub__15ada85ef5f1cb4f0237eff6253e200138049f1bebbea7163294d28f9
|
|
|
13564
13600
|
*,
|
|
13565
13601
|
enabled: typing.Optional[builtins.bool] = None,
|
|
13566
13602
|
event_bus: typing.Optional[IEventBus] = None,
|
|
13603
|
+
role: typing.Optional[_IRole_235f5d8e] = None,
|
|
13567
13604
|
schedule: typing.Optional[Schedule] = None,
|
|
13568
13605
|
targets: typing.Optional[typing.Sequence[IRuleTarget]] = None,
|
|
13569
13606
|
cross_stack_scope: typing.Optional[_constructs_77d1e7e8.Construct] = None,
|
|
@@ -13596,6 +13633,7 @@ def _typecheckingstub__26677a946da4037892c1c589c005b7536d8ffed632ca92c5c52a92586
|
|
|
13596
13633
|
rule_name: typing.Optional[builtins.str] = None,
|
|
13597
13634
|
enabled: typing.Optional[builtins.bool] = None,
|
|
13598
13635
|
event_bus: typing.Optional[IEventBus] = None,
|
|
13636
|
+
role: typing.Optional[_IRole_235f5d8e] = None,
|
|
13599
13637
|
schedule: typing.Optional[Schedule] = None,
|
|
13600
13638
|
targets: typing.Optional[typing.Sequence[IRuleTarget]] = None,
|
|
13601
13639
|
) -> None:
|