3737 type = str ,
3838 help = "Output file name. When not set, the template will be printed to stdout" )
3939cli_parser .add_argument ("-t" , "--launch-type" ,
40- choices = ["FARGATE " , "EC2 " ],
41- default = "FARGATE " ,
42- help = "ESC Launch type. Default: FARGATE " )
40+ choices = ["fargate " , "ec2 " ],
41+ default = "fargate " ,
42+ help = "ESC Launch type. Default: fargate " )
4343cli_parser .add_argument ("-s" , "--subnets-number" ,
4444 type = int ,
4545 default = 3 ,
5353
5454args = cli_parser .parse_args ()
5555
56- if args .no_cluster and args .launch_type == "EC2 " and not args .no_network :
57- cli_parser .error ("--no-cluster combined with --launch-type EC2 requires --no-network" )
56+ if args .no_cluster and args .launch_type == "ec2 " and not args .no_network :
57+ cli_parser .error ("--no-cluster combined with --launch-type=ec2 requires --no-network" )
5858
5959template = Template ()
6060template .set_version ("2010-09-09" )
@@ -142,7 +142,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
142142 template .add_parameter_to_group (vpc , network_params_group )
143143 template .set_parameter_label (vpc , "VPC ID" )
144144
145- if not args .no_cluster or args .launch_type == "FARGATE " :
145+ if not args .no_cluster or args .launch_type == "fargate " :
146146 subnets = template .add_parameter (Parameter (
147147 "SubnetIds" ,
148148 Type = "List<AWS::EC2::Subnet::Id>" ,
@@ -171,7 +171,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
171171
172172# Cluster ----------------------------------------------------------------------
173173
174- if args .launch_type == "EC2 " and not args .no_cluster :
174+ if args .launch_type == "ec2 " and not args .no_cluster :
175175 cluster_instance_type = template .add_parameter (Parameter (
176176 "ClusterInstanceType" ,
177177 Type = "String" ,
@@ -309,8 +309,8 @@ def __init__(self, value_one: object, value_two: object) -> None:
309309 "ContainerMemory" ,
310310 Type = "Number" ,
311311 Description = "Amount of memory in megabytes to give to the container" ,
312- Default = 2048 if args .launch_type == "FARGATE " else 1536 ,
313- MinValue = 2048 if args .launch_type == "FARGATE " else 512 ,
312+ Default = 2048 if args .launch_type == "fargate " else 1536 ,
313+ MinValue = 2048 if args .launch_type == "fargate " else 512 ,
314314))
315315template .add_parameter_to_group (container_memory , service_params_group )
316316template .set_parameter_label (container_memory , "Memory per task" )
@@ -486,7 +486,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
486486# CONDITIONS
487487# ==============================================================================
488488
489- if args .launch_type == "EC2 " and not args .no_cluster :
489+ if args .launch_type == "ec2 " and not args .no_cluster :
490490 cluster_use_spot = template .add_condition (
491491 "ClusterOnDemandOnly" ,
492492 Not (Equals (Ref (cluster_on_demand_percentage ), 100 )),
@@ -547,7 +547,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
547547# RULES
548548# ==============================================================================
549549
550- if args .launch_type == "EC2 " and not args .no_cluster :
550+ if args .launch_type == "ec2 " and not args .no_cluster :
551551 template .add_rule (
552552 "testWarmPoolAndNoSpot" ,
553553 {
@@ -710,7 +710,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
710710 ],
711711 ))
712712
713- elif not args .no_cluster or args .launch_type == "FARGATE " :
713+ elif not args .no_cluster or args .launch_type == "fargate " :
714714 subnet_refs = Ref (subnets )
715715
716716# ==============================================================================
@@ -730,7 +730,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
730730ecs_capacity_provider_associations = None
731731
732732if not args .no_cluster :
733- if args .launch_type == "EC2 " :
733+ if args .launch_type == "ec2 " :
734734 ec2_instance_role = template .add_resource (iam .Role (
735735 "EC2InstanceRole" ,
736736 RoleName = Join ("-" , [StackName , "ec2-instance" ]),
@@ -879,7 +879,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
879879 )],
880880 ))
881881
882- else : # if args.launch_type == "EC2 "
882+ else : # if args.launch_type == "ec2 "
883883 ecs_capacity_provider_associations = template .add_resource (ecs .ClusterCapacityProviderAssociations (
884884 "ECSClusterCapacityProviderAssociations" ,
885885 Cluster = Ref (ecs_cluster ),
@@ -1055,21 +1055,21 @@ def __init__(self, value_one: object, value_two: object) -> None:
10551055 "ECSTaskDefinition" ,
10561056 Family = StackName ,
10571057 Cpu = Ref (container_cpu ),
1058- Memory = Ref (container_memory ) if args .launch_type == "FARGATE " else NoValue ,
1058+ Memory = Ref (container_memory ) if args .launch_type == "fargate " else NoValue ,
10591059 RuntimePlatform = ecs .RuntimePlatform (
10601060 CpuArchitecture = FindInMap ("Architectures" , Ref (cpu_arch ), "Arch" ),
10611061 OperatingSystemFamily = "LINUX" ,
10621062 ),
1063- NetworkMode = "awsvpc" if args .launch_type == "FARGATE " else "bridge" ,
1064- RequiresCompatibilities = [args .launch_type ],
1063+ NetworkMode = "awsvpc" if args .launch_type == "fargate " else "bridge" ,
1064+ RequiresCompatibilities = [args .launch_type . upper () ],
10651065 TaskRoleArn = GetAtt (ecs_task_role , "Arn" ),
10661066 ExecutionRoleArn = GetAtt (ecs_task_execution_role , "Arn" ),
10671067 ContainerDefinitions = [ecs .ContainerDefinition (
10681068 Name = "imgproxy" ,
10691069 Essential = True ,
10701070 Image = Ref (docker_image ),
10711071 Cpu = Ref (container_cpu ),
1072- MemoryReservation = Ref (container_memory ) if args .launch_type == "EC2 " else NoValue ,
1072+ MemoryReservation = Ref (container_memory ) if args .launch_type == "ec2 " else NoValue ,
10731073 Environment = [
10741074 ecs .Environment (Name = "AWS_REGION" , Value = Region ),
10751075 ecs .Environment (Name = "IMGPROXY_BIND" , Value = ":8080" ),
@@ -1171,7 +1171,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
11711171 VpcId = Ref (vpc ),
11721172 Port = 80 ,
11731173 Protocol = "HTTP" ,
1174- TargetType = "ip" if args .launch_type == "FARGATE " else "instance" ,
1174+ TargetType = "ip" if args .launch_type == "fargate " else "instance" ,
11751175 TargetGroupAttributes = [loadbalancing .TargetGroupAttribute (
11761176 Key = "load_balancing.algorithm.type" ,
11771177 Value = "least_outstanding_requests" ,
@@ -1230,7 +1230,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
12301230 SecurityGroups = [Ref (ecs_host_security_group )],
12311231 Subnets = subnet_refs ,
12321232 ),
1233- ) if args .launch_type == "FARGATE " else NoValue ,
1233+ ) if args .launch_type == "fargate " else NoValue ,
12341234 LoadBalancers = [ecs .LoadBalancer (
12351235 ContainerName = "imgproxy" ,
12361236 ContainerPort = 8080 ,
@@ -1259,7 +1259,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
12591259 ScalingTargetId = Ref (autoscaling_scalable_target ),
12601260 StepScalingPolicyConfiguration = applicationautoscaling .StepScalingPolicyConfiguration (
12611261 AdjustmentType = "PercentChangeInCapacity" ,
1262- Cooldown = 120 if args .launch_type == "EC2 " else 30 ,
1262+ Cooldown = 120 if args .launch_type == "ec2 " else 30 ,
12631263 MetricAggregationType = "Average" ,
12641264 StepAdjustments = [
12651265 applicationautoscaling .StepAdjustment (
@@ -1297,7 +1297,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
12971297 ScalingTargetId = Ref (autoscaling_scalable_target ),
12981298 StepScalingPolicyConfiguration = applicationautoscaling .StepScalingPolicyConfiguration (
12991299 AdjustmentType = "PercentChangeInCapacity" ,
1300- Cooldown = 600 if args .launch_type == "EC2 " else 300 ,
1300+ Cooldown = 600 if args .launch_type == "ec2 " else 300 ,
13011301 MetricAggregationType = "Average" ,
13021302 StepAdjustments = [applicationautoscaling .StepAdjustment (
13031303 MetricIntervalUpperBound = 0 ,
@@ -1325,7 +1325,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
13251325 Value = GetAtt (ecs_service , "Name" ),
13261326 )],
13271327 Statistic = "Average" ,
1328- Period = 30 if args .launch_type == "EC2 " else 10 ,
1328+ Period = 30 if args .launch_type == "ec2 " else 10 ,
13291329 EvaluationPeriods = 2 ,
13301330 Threshold = 80 ,
13311331 ComparisonOperator = "GreaterThanThreshold" ,
@@ -1352,7 +1352,7 @@ def __init__(self, value_one: object, value_two: object) -> None:
13521352 )],
13531353 Statistic = "Average" ,
13541354 Period = 30 ,
1355- EvaluationPeriods = 20 if args .launch_type == "EC2 " else 10 ,
1355+ EvaluationPeriods = 20 if args .launch_type == "ec2 " else 10 ,
13561356 Threshold = 50 ,
13571357 ComparisonOperator = "LessThanThreshold" ,
13581358 AlarmActions = [Ref (autoscaling_scaling_in_policy )],
0 commit comments