Class: AWSCDK::ECS::AddCapacityOptions

Inherits:
AddAutoScalingGroupCapacityOptions
  • Object
show all
Defined in:
ecs/add_capacity_options.rb

Overview

The properties for adding instance capacity to an AutoScalingGroup.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(machine_image_type: nil, spot_instance_draining: nil, topic_encryption_key: nil, allow_all_outbound: nil, associate_public_ip_address: nil, auto_scaling_group_name: nil, az_capacity_distribution_strategy: nil, block_devices: nil, capacity_rebalance: nil, cooldown: nil, default_instance_warmup: nil, deletion_protection: nil, desired_capacity: nil, group_metrics: nil, health_check: nil, health_checks: nil, ignore_unmodified_size_properties: nil, instance_lifecycle_policy: nil, instance_monitoring: nil, key_name: nil, key_pair: nil, max_capacity: nil, max_instance_lifetime: nil, min_capacity: nil, new_instances_protected_from_scale_in: nil, notifications: nil, signals: nil, spot_price: nil, ssm_session_permissions: nil, termination_policies: nil, termination_policy_custom_lambda_function_arn: nil, update_policy: nil, vpc_subnets: nil, instance_type:, machine_image: nil) ⇒ AddCapacityOptions

Returns a new instance of AddCapacityOptions.

Parameters:

  • machine_image_type (AWSCDK::ECS::MachineImageType, nil) (defaults to: nil)

    What type of machine image this is.

  • spot_instance_draining (Boolean, nil) (defaults to: nil)

    Specify whether to enable Automated Draining for Spot Instances running Amazon ECS Services.

  • topic_encryption_key (AWSCDK::KMS::IKey, nil) (defaults to: nil)

    If AddAutoScalingGroupCapacityOptions.taskDrainTime is non-zero, then the ECS cluster creates an SNS Topic to as part of a system to drain instances of tasks when the instance is being shut down. If this property is provided, then this key will be used to encrypt the contents of that SNS Topic. See SNS Data Encryption for more information.

  • allow_all_outbound (Boolean, nil) (defaults to: nil)

    Whether the instances can initiate connections to anywhere by default.

  • associate_public_ip_address (Boolean, nil) (defaults to: nil)

    Whether instances in the Auto Scaling Group should have public IP addresses associated with them.

  • auto_scaling_group_name (String, nil) (defaults to: nil)

    The name of the Auto Scaling group.

  • az_capacity_distribution_strategy (AWSCDK::Autoscaling::CapacityDistributionStrategy, nil) (defaults to: nil)

    The strategy for distributing instances across Availability Zones.

  • block_devices (Array<AWSCDK::Autoscaling::BlockDevice>, nil) (defaults to: nil)

    Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes.

  • capacity_rebalance (Boolean, nil) (defaults to: nil)

    Indicates whether Capacity Rebalancing is enabled.

  • cooldown (AWSCDK::Duration, nil) (defaults to: nil)

    Default scaling cooldown for this AutoScalingGroup.

  • default_instance_warmup (AWSCDK::Duration, nil) (defaults to: nil)

    The amount of time, in seconds, until a newly launched instance can contribute to the Amazon CloudWatch metrics.

  • deletion_protection (AWSCDK::Autoscaling::DeletionProtection, nil) (defaults to: nil)

    Deletion protection for the Auto Scaling group.

  • desired_capacity (Numeric, nil) (defaults to: nil)

    Initial amount of instances in the fleet.

  • group_metrics (Array<AWSCDK::Autoscaling::GroupMetrics>, nil) (defaults to: nil)

    Enable monitoring for group metrics, these metrics describe the group rather than any of its instances.

  • health_check (AWSCDK::Autoscaling::HealthCheck, nil) (defaults to: nil)

    Configuration for health checks.

  • health_checks (AWSCDK::Autoscaling::HealthChecks, nil) (defaults to: nil)

    Configuration for EC2 or additional health checks.

  • ignore_unmodified_size_properties (Boolean, nil) (defaults to: nil)

    If the ASG has scheduled actions, don't reset unchanged group sizes.

  • instance_lifecycle_policy (AWSCDK::Autoscaling::InstanceLifecyclePolicy, nil) (defaults to: nil)

    An instance lifecycle policy that defines how instances should be handled during lifecycle events, particularly when lifecycle hooks are abandoned or fail.

  • instance_monitoring (AWSCDK::Autoscaling::Monitoring, nil) (defaults to: nil)

    Controls whether instances in this group are launched with detailed or basic monitoring.

  • key_name (String, nil) (defaults to: nil)

    Name of SSH keypair to grant access to instances.

  • key_pair (AWSCDK::EC2::IKeyPair, nil) (defaults to: nil)

    The SSH keypair to grant access to the instance.

  • max_capacity (Numeric, nil) (defaults to: nil)

    Maximum number of instances in the fleet.

  • max_instance_lifetime (AWSCDK::Duration, nil) (defaults to: nil)

    The maximum amount of time that an instance can be in service.

  • min_capacity (Numeric, nil) (defaults to: nil)

    Minimum number of instances in the fleet.

  • new_instances_protected_from_scale_in (Boolean, nil) (defaults to: nil)

    Whether newly-launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in.

  • notifications (Array<AWSCDK::Autoscaling::NotificationConfiguration>, nil) (defaults to: nil)

    Configure autoscaling group to send notifications about fleet changes to an SNS topic(s).

  • signals (AWSCDK::Autoscaling::Signals, nil) (defaults to: nil)

    Configure waiting for signals during deployment.

  • spot_price (String, nil) (defaults to: nil)

    The maximum hourly price (in USD) to be paid for any Spot Instance launched to fulfill the request.

  • ssm_session_permissions (Boolean, nil) (defaults to: nil)

    Add SSM session permissions to the instance role.

  • termination_policies (Array<AWSCDK::Autoscaling::TerminationPolicy>, nil) (defaults to: nil)

    A policy or a list of policies that are used to select the instances to terminate.

  • termination_policy_custom_lambda_function_arn (String, nil) (defaults to: nil)

    A lambda function Arn that can be used as a custom termination policy to select the instances to terminate.

  • update_policy (AWSCDK::Autoscaling::UpdatePolicy, nil) (defaults to: nil)

    What to do when an AutoScalingGroup's instance configuration is changed.

  • vpc_subnets (AWSCDK::EC2::SubnetSelection, nil) (defaults to: nil)

    Where to place instances within the VPC.

  • instance_type (AWSCDK::EC2::InstanceType)

    The EC2 instance type to use when launching instances into the AutoScalingGroup.

  • machine_image (AWSCDK::EC2::IMachineImage, nil) (defaults to: nil)

    The ECS-optimized AMI variant to use.



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
# File 'ecs/add_capacity_options.rb', line 43

def initialize(machine_image_type: nil, spot_instance_draining: nil, topic_encryption_key: nil, allow_all_outbound: nil, associate_public_ip_address: nil, auto_scaling_group_name: nil, az_capacity_distribution_strategy: nil, block_devices: nil, capacity_rebalance: nil, cooldown: nil, default_instance_warmup: nil, deletion_protection: nil, desired_capacity: nil, group_metrics: nil, health_check: nil, health_checks: nil, ignore_unmodified_size_properties: nil, instance_lifecycle_policy: nil, instance_monitoring: nil, key_name: nil, key_pair: nil, max_capacity: nil, max_instance_lifetime: nil, min_capacity: nil, new_instances_protected_from_scale_in: nil, notifications: nil, signals: nil, spot_price: nil, ssm_session_permissions: nil, termination_policies: nil, termination_policy_custom_lambda_function_arn: nil, update_policy: nil, vpc_subnets: nil, instance_type:, machine_image: nil)
  @machine_image_type = machine_image_type
  Jsii::Type.check_type(@machine_image_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLk1hY2hpbmVJbWFnZVR5cGUifQ==")), "machineImageType") unless @machine_image_type.nil?
  @spot_instance_draining = spot_instance_draining
  Jsii::Type.check_type(@spot_instance_draining, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "spotInstanceDraining") unless @spot_instance_draining.nil?
  @topic_encryption_key = topic_encryption_key
  Jsii::Type.check_type(@topic_encryption_key, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3Nfa21zLklLZXkifQ==")), "topicEncryptionKey") unless @topic_encryption_key.nil?
  @allow_all_outbound = allow_all_outbound
  Jsii::Type.check_type(@allow_all_outbound, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "allowAllOutbound") unless @allow_all_outbound.nil?
  @associate_public_ip_address = associate_public_ip_address
  Jsii::Type.check_type(@associate_public_ip_address, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "associatePublicIpAddress") unless @associate_public_ip_address.nil?
  @auto_scaling_group_name = auto_scaling_group_name
  Jsii::Type.check_type(@auto_scaling_group_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "autoScalingGroupName") unless @auto_scaling_group_name.nil?
  @az_capacity_distribution_strategy = az_capacity_distribution_strategy
  Jsii::Type.check_type(@az_capacity_distribution_strategy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuQ2FwYWNpdHlEaXN0cmlidXRpb25TdHJhdGVneSJ9")), "azCapacityDistributionStrategy") unless @az_capacity_distribution_strategy.nil?
  @block_devices = block_devices.is_a?(Array) ? block_devices.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::Autoscaling::BlockDevice.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : block_devices
  Jsii::Type.check_type(@block_devices, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5CbG9ja0RldmljZSJ9LCJraW5kIjoiYXJyYXkifX0=")), "blockDevices") unless @block_devices.nil?
  @capacity_rebalance = capacity_rebalance
  Jsii::Type.check_type(@capacity_rebalance, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "capacityRebalance") unless @capacity_rebalance.nil?
  @cooldown = cooldown
  Jsii::Type.check_type(@cooldown, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "cooldown") unless @cooldown.nil?
  @default_instance_warmup = default_instance_warmup
  Jsii::Type.check_type(@default_instance_warmup, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "defaultInstanceWarmup") unless @default_instance_warmup.nil?
  @deletion_protection = deletion_protection
  Jsii::Type.check_type(@deletion_protection, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuRGVsZXRpb25Qcm90ZWN0aW9uIn0=")), "deletionProtection") unless @deletion_protection.nil?
  @desired_capacity = desired_capacity
  Jsii::Type.check_type(@desired_capacity, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "desiredCapacity") unless @desired_capacity.nil?
  @group_metrics = group_metrics
  Jsii::Type.check_type(@group_metrics, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5Hcm91cE1ldHJpY3MifSwia2luZCI6ImFycmF5In19")), "groupMetrics") unless @group_metrics.nil?
  @health_check = health_check
  Jsii::Type.check_type(@health_check, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuSGVhbHRoQ2hlY2sifQ==")), "healthCheck") unless @health_check.nil?
  @health_checks = health_checks
  Jsii::Type.check_type(@health_checks, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuSGVhbHRoQ2hlY2tzIn0=")), "healthChecks") unless @health_checks.nil?
  @ignore_unmodified_size_properties = ignore_unmodified_size_properties
  Jsii::Type.check_type(@ignore_unmodified_size_properties, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "ignoreUnmodifiedSizeProperties") unless @ignore_unmodified_size_properties.nil?
  @instance_lifecycle_policy = instance_lifecycle_policy.is_a?(Hash) ? ::AWSCDK::Autoscaling::InstanceLifecyclePolicy.new(**instance_lifecycle_policy.transform_keys(&:to_sym)) : instance_lifecycle_policy
  Jsii::Type.check_type(@instance_lifecycle_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuSW5zdGFuY2VMaWZlY3ljbGVQb2xpY3kifQ==")), "instanceLifecyclePolicy") unless @instance_lifecycle_policy.nil?
  @instance_monitoring = instance_monitoring
  Jsii::Type.check_type(@instance_monitoring, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuTW9uaXRvcmluZyJ9")), "instanceMonitoring") unless @instance_monitoring.nil?
  @key_name = key_name
  Jsii::Type.check_type(@key_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "keyName") unless @key_name.nil?
  @key_pair = key_pair
  Jsii::Type.check_type(@key_pair, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklLZXlQYWlyIn0=")), "keyPair") unless @key_pair.nil?
  @max_capacity = max_capacity
  Jsii::Type.check_type(@max_capacity, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "maxCapacity") unless @max_capacity.nil?
  @max_instance_lifetime = max_instance_lifetime
  Jsii::Type.check_type(@max_instance_lifetime, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5EdXJhdGlvbiJ9")), "maxInstanceLifetime") unless @max_instance_lifetime.nil?
  @min_capacity = min_capacity
  Jsii::Type.check_type(@min_capacity, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJudW1iZXIifQ==")), "minCapacity") unless @min_capacity.nil?
  @new_instances_protected_from_scale_in = new_instances_protected_from_scale_in
  Jsii::Type.check_type(@new_instances_protected_from_scale_in, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "newInstancesProtectedFromScaleIn") unless @new_instances_protected_from_scale_in.nil?
  @notifications = notifications.is_a?(Array) ? notifications.map { |jsii_v0| jsii_v0.is_a?(Hash) ? ::AWSCDK::Autoscaling::NotificationConfiguration.new(**jsii_v0.transform_keys(&:to_sym)) : jsii_v0 } : notifications
  Jsii::Type.check_type(@notifications, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5Ob3RpZmljYXRpb25Db25maWd1cmF0aW9uIn0sImtpbmQiOiJhcnJheSJ9fQ==")), "notifications") unless @notifications.nil?
  @signals = signals
  Jsii::Type.check_type(@signals, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuU2lnbmFscyJ9")), "signals") unless @signals.nil?
  @spot_price = spot_price
  Jsii::Type.check_type(@spot_price, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "spotPrice") unless @spot_price.nil?
  @ssm_session_permissions = ssm_session_permissions
  Jsii::Type.check_type(@ssm_session_permissions, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJib29sZWFuIn0=")), "ssmSessionPermissions") unless @ssm_session_permissions.nil?
  @termination_policies = termination_policies
  Jsii::Type.check_type(@termination_policies, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19hdXRvc2NhbGluZy5UZXJtaW5hdGlvblBvbGljeSJ9LCJraW5kIjoiYXJyYXkifX0=")), "terminationPolicies") unless @termination_policies.nil?
  @termination_policy_custom_lambda_function_arn = termination_policy_custom_lambda_function_arn
  Jsii::Type.check_type(@termination_policy_custom_lambda_function_arn, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "terminationPolicyCustomLambdaFunctionArn") unless @termination_policy_custom_lambda_function_arn.nil?
  @update_policy = update_policy
  Jsii::Type.check_type(@update_policy, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfYXV0b3NjYWxpbmcuVXBkYXRlUG9saWN5In0=")), "updatePolicy") unless @update_policy.nil?
  @vpc_subnets = vpc_subnets.is_a?(Hash) ? ::AWSCDK::EC2::SubnetSelection.new(**vpc_subnets.transform_keys(&:to_sym)) : vpc_subnets
  Jsii::Type.check_type(@vpc_subnets, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLlN1Ym5ldFNlbGVjdGlvbiJ9")), "vpcSubnets") unless @vpc_subnets.nil?
  @instance_type = instance_type
  Jsii::Type.check_type(@instance_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluc3RhbmNlVHlwZSJ9")), "instanceType")
  @machine_image = machine_image
  Jsii::Type.check_type(@machine_image, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLklNYWNoaW5lSW1hZ2UifQ==")), "machineImage") unless @machine_image.nil?
end

Instance Attribute Details

#allow_all_outboundBoolean? (readonly)

Note:

Default: true

Whether the instances can initiate connections to anywhere by default.

Returns:

  • (Boolean, nil)


145
146
147
# File 'ecs/add_capacity_options.rb', line 145

def allow_all_outbound
  @allow_all_outbound
end

#associate_public_ip_addressBoolean? (readonly)

Note:

Default: - Use subnet setting.

Whether instances in the Auto Scaling Group should have public IP addresses associated with them.

launch_template and mixed_instances_policy must not be specified when this property is specified

Returns:

  • (Boolean, nil)


152
153
154
# File 'ecs/add_capacity_options.rb', line 152

def associate_public_ip_address
  @associate_public_ip_address
end

#auto_scaling_group_nameString? (readonly)

Note:

Default: - Auto generated by CloudFormation

The name of the Auto Scaling group.

This name must be unique per Region per account.

Returns:

  • (String, nil)


159
160
161
# File 'ecs/add_capacity_options.rb', line 159

def auto_scaling_group_name
  @auto_scaling_group_name
end

#az_capacity_distribution_strategyAWSCDK::Autoscaling::CapacityDistributionStrategy? (readonly)

Note:

Default: None

The strategy for distributing instances across Availability Zones.



164
165
166
# File 'ecs/add_capacity_options.rb', line 164

def az_capacity_distribution_strategy
  @az_capacity_distribution_strategy
end

#block_devicesArray<AWSCDK::Autoscaling::BlockDevice>? (readonly)

Note:

Default: - Uses the block device mapping of the AMI

Specifies how block devices are exposed to the instance. You can specify virtual devices and EBS volumes.

Each instance that is launched has an associated root device volume, either an Amazon EBS volume or an instance store volume. You can use block device mappings to specify additional EBS volumes or instance store volumes to attach to an instance when it is launched.

launch_template and mixed_instances_policy must not be specified when this property is specified



177
178
179
# File 'ecs/add_capacity_options.rb', line 177

def block_devices
  @block_devices
end

#capacity_rebalanceBoolean? (readonly)

Note:

Default: false

Indicates whether Capacity Rebalancing is enabled.

When you turn on Capacity Rebalancing, Amazon EC2 Auto Scaling attempts to launch a Spot Instance whenever Amazon EC2 notifies that a Spot Instance is at an elevated risk of interruption. After launching a new instance, it then terminates an old instance.



187
188
189
# File 'ecs/add_capacity_options.rb', line 187

def capacity_rebalance
  @capacity_rebalance
end

#cooldownAWSCDK::Duration? (readonly)

Note:

Default: Duration.minutes(5)

Default scaling cooldown for this AutoScalingGroup.

Returns:



192
193
194
# File 'ecs/add_capacity_options.rb', line 192

def cooldown
  @cooldown
end

#default_instance_warmupAWSCDK::Duration? (readonly)

Note:

Default: None

The amount of time, in seconds, until a newly launched instance can contribute to the Amazon CloudWatch metrics.

This delay lets an instance finish initializing before Amazon EC2 Auto Scaling aggregates instance metrics, resulting in more reliable usage data. Set this value equal to the amount of time that it takes for resource consumption to become stable after an instance reaches the InService state.

To optimize the performance of scaling policies that scale continuously, such as target tracking and step scaling policies, we strongly recommend that you enable the default instance warmup, even if its value is set to 0 seconds

Default instance warmup will not be added if no value is specified



207
208
209
# File 'ecs/add_capacity_options.rb', line 207

def default_instance_warmup
  @default_instance_warmup
end

#deletion_protectionAWSCDK::Autoscaling::DeletionProtection? (readonly)

Note:

Default: DeletionProtection.NONE

Deletion protection for the Auto Scaling group.



213
214
215
# File 'ecs/add_capacity_options.rb', line 213

def deletion_protection
  @deletion_protection
end

#desired_capacityNumeric? (readonly)

Note:

Default: minCapacity, and leave unchanged during deployment

Initial amount of instances in the fleet.

If this is set to a number, every deployment will reset the amount of instances to this number. It is recommended to leave this value blank.



222
223
224
# File 'ecs/add_capacity_options.rb', line 222

def desired_capacity
  @desired_capacity
end

#group_metricsArray<AWSCDK::Autoscaling::GroupMetrics>? (readonly)

Note:

Default: - no group metrics will be reported

Enable monitoring for group metrics, these metrics describe the group rather than any of its instances.

To report all group metrics use GroupMetrics.all() Group metrics are reported in a granularity of 1 minute at no additional charge.

Returns:



230
231
232
# File 'ecs/add_capacity_options.rb', line 230

def group_metrics
  @group_metrics
end

#health_checkAWSCDK::Autoscaling::HealthCheck? (readonly)

Deprecated.

Use healthChecks instead

Note:

Default: - HealthCheck.ec2 with no grace period

Configuration for health checks.



236
237
238
# File 'ecs/add_capacity_options.rb', line 236

def health_check
  @health_check
end

#health_checksAWSCDK::Autoscaling::HealthChecks? (readonly)

Note:

Default: - EC2 type with no grace period

Configuration for EC2 or additional health checks.

Even when using HealthChecks.withAdditionalChecks(), the EC2 type is implicitly included.



244
245
246
# File 'ecs/add_capacity_options.rb', line 244

def health_checks
  @health_checks
end

#ignore_unmodified_size_propertiesBoolean? (readonly)

Note:

Default: true

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.

Returns:

  • (Boolean, nil)


255
256
257
# File 'ecs/add_capacity_options.rb', line 255

def ignore_unmodified_size_properties
  @ignore_unmodified_size_properties
end

#instance_lifecycle_policyAWSCDK::Autoscaling::InstanceLifecyclePolicy? (readonly)

Note:

Default: None

An instance lifecycle policy that defines how instances should be handled during lifecycle events, particularly when lifecycle hooks are abandoned or fail.



261
262
263
# File 'ecs/add_capacity_options.rb', line 261

def instance_lifecycle_policy
  @instance_lifecycle_policy
end

#instance_monitoringAWSCDK::Autoscaling::Monitoring? (readonly)

Note:

Default: - Monitoring.DETAILED

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.

launch_template and mixed_instances_policy must not be specified when this property is specified



272
273
274
# File 'ecs/add_capacity_options.rb', line 272

def instance_monitoring
  @instance_monitoring
end

#instance_typeAWSCDK::EC2::InstanceType (readonly)

The EC2 instance type to use when launching instances into the AutoScalingGroup.



419
420
421
# File 'ecs/add_capacity_options.rb', line 419

def instance_type
  @instance_type
end

#key_nameString? (readonly)

Note:

Default: - No SSH access will be possible.

Name of SSH keypair to grant access to instances.

launch_template and mixed_instances_policy must not be specified when this property is specified

You can either specify key_pair or key_name, not both.

Returns:

  • (String, nil)


282
283
284
# File 'ecs/add_capacity_options.rb', line 282

def key_name
  @key_name
end

#key_pairAWSCDK::EC2::IKeyPair? (readonly)

Note:

Default: - No SSH access will be possible.

The SSH keypair to grant access to the instance.

Feature flag AUTOSCALING_GENERATE_LAUNCH_TEMPLATE must be enabled to use this property.

launch_template and mixed_instances_policy must not be specified when this property is specified.

You can either specify key_pair or key_name, not both.

Returns:



293
294
295
# File 'ecs/add_capacity_options.rb', line 293

def key_pair
  @key_pair
end

#machine_imageAWSCDK::EC2::IMachineImage? (readonly)

Note:

Default: - Automatically updated, ECS-optimized Amazon Linux 2

The ECS-optimized AMI variant to use.

The default is to use an ECS-optimized AMI of Amazon Linux 2 which is automatically updated to the latest version on every deployment. This will replace the instances in the AutoScalingGroup. Make sure you have not disabled task draining, to avoid downtime when the AMI updates.

To use an image that does not update on every deployment, pass:

machine_image = AWSCDK::ECS::ECSOptimizedImage.amazon_linux2(AWSCDK::ECS::AmiHardwareType::STANDARD, {
    cached_in_context: true,
})

For more information, see Amazon ECS-optimized AMIs.

You must define either machine_image or machine_image_type, not both.

Returns:



442
443
444
# File 'ecs/add_capacity_options.rb', line 442

def machine_image
  @machine_image
end

#machine_image_typeAWSCDK::ECS::MachineImageType? (readonly)

Note:

Default: - Automatically determined from machineImage, if available, otherwise MachineImageType.AMAZON_LINUX_2.

What type of machine image this is.

Depending on the setting, different UserData will automatically be added to the AutoScalingGroup to configure it properly for use with ECS.

If you create an AutoScalingGroup yourself and are adding it via add_auto_scaling_group(), you must specify this value. If you are adding an auto_scaling_group via add_capacity, this value will be determined from the machine_image you pass.



128
129
130
# File 'ecs/add_capacity_options.rb', line 128

def machine_image_type
  @machine_image_type
end

#max_capacityNumeric? (readonly)

Note:

Default: desiredCapacity

Maximum number of instances in the fleet.

Returns:

  • (Numeric, nil)


298
299
300
# File 'ecs/add_capacity_options.rb', line 298

def max_capacity
  @max_capacity
end

#max_instance_lifetimeAWSCDK::Duration? (readonly)

Note:

Default: none

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 86,400 seconds (one day). To clear a previously set value, leave this property undefined.



311
312
313
# File 'ecs/add_capacity_options.rb', line 311

def max_instance_lifetime
  @max_instance_lifetime
end

#min_capacityNumeric? (readonly)

Note:

Default: 1

Minimum number of instances in the fleet.

Returns:

  • (Numeric, nil)


316
317
318
# File 'ecs/add_capacity_options.rb', line 316

def min_capacity
  @min_capacity
end

#new_instances_protected_from_scale_inBoolean? (readonly)

Note:

Default: false

Whether newly-launched instances are protected from termination by Amazon EC2 Auto Scaling when scaling in.

By default, Auto Scaling can terminate an instance at any time after launch when scaling in an Auto Scaling Group, subject to the group's termination policy. However, you may wish to protect newly-launched instances from being scaled in if they are going to run critical applications that should not be prematurely terminated.

This flag must be enabled if the Auto Scaling Group will be associated with an ECS Capacity Provider with managed termination protection.

Returns:

  • (Boolean, nil)


330
331
332
# File 'ecs/add_capacity_options.rb', line 330

def new_instances_protected_from_scale_in
  @new_instances_protected_from_scale_in
end

#notificationsArray<AWSCDK::Autoscaling::NotificationConfiguration>? (readonly)

Note:

Default: - No fleet change notifications will be sent.

Configure autoscaling group to send notifications about fleet changes to an SNS topic(s).



336
337
338
# File 'ecs/add_capacity_options.rb', line 336

def notifications
  @notifications
end

#signalsAWSCDK::Autoscaling::Signals? (readonly)

Note:

Default: - Do not wait for signals

Configure waiting for signals during deployment.

Use this to pause the CloudFormation deployment to wait for the instances in the AutoScalingGroup to report successful startup during creation and updates. The UserData script needs to invoke cfn-signal with a success or failure code after it is done setting up the instance.

Without waiting for signals, the CloudFormation deployment will proceed as soon as the AutoScalingGroup has been created or updated but before the instances in the group have been started.

For example, to have instances wait for an Elastic Load Balancing health check before they signal success, add a health-check verification by using the cfn-init helper script. For an example, see the verify_instance_health command in the Auto Scaling rolling updates sample template:

https://github.com/awslabs/aws-cloudformation-templates/blob/master/aws/services/AutoScaling/AutoScalingRollingUpdates.yaml



357
358
359
# File 'ecs/add_capacity_options.rb', line 357

def signals
  @signals
end

#spot_instance_drainingBoolean? (readonly)

Note:

Default: false

Specify whether to enable Automated Draining for Spot Instances running Amazon ECS Services.

For more information, see Using Spot Instances.

Returns:

  • (Boolean, nil)


135
136
137
# File 'ecs/add_capacity_options.rb', line 135

def spot_instance_draining
  @spot_instance_draining
end

#spot_priceString? (readonly)

Note:

Default: none

The maximum hourly price (in USD) to be paid for any Spot Instance launched to fulfill the request.

Spot Instances are launched when the price you specify exceeds the current Spot market price.

launch_template and mixed_instances_policy must not be specified when this property is specified

Returns:

  • (String, nil)


367
368
369
# File 'ecs/add_capacity_options.rb', line 367

def spot_price
  @spot_price
end

#ssm_session_permissionsBoolean? (readonly)

Note:

Default: false

Add SSM session permissions to the instance role.

Setting this to true adds the necessary permissions to connect to the instance using SSM Session Manager. You can do this from the AWS Console.

NOTE: Setting this flag to true may not be enough by itself. You must also use an AMI that comes with the SSM Agent, or install the SSM Agent yourself. See Working with SSM Agent in the SSM Developer Guide.

Returns:

  • (Boolean, nil)


382
383
384
# File 'ecs/add_capacity_options.rb', line 382

def ssm_session_permissions
  @ssm_session_permissions
end

#termination_policiesArray<AWSCDK::Autoscaling::TerminationPolicy>? (readonly)

Note:

Default: - TerminationPolicy.DEFAULT

A policy or a list of policies that are used to select the instances to terminate.

The policies are executed in the order that you list them.



390
391
392
# File 'ecs/add_capacity_options.rb', line 390

def termination_policies
  @termination_policies
end

#termination_policy_custom_lambda_function_arnString? (readonly)

Note:

Default: - No lambda function Arn will be supplied

A lambda function Arn that can be used as a custom termination policy to select the instances to terminate.

This property must be specified if the TerminationPolicy.CUSTOM_LAMBDA_FUNCTION is used.



399
400
401
# File 'ecs/add_capacity_options.rb', line 399

def termination_policy_custom_lambda_function_arn
  @termination_policy_custom_lambda_function_arn
end

#topic_encryption_keyAWSCDK::KMS::IKey? (readonly)

Note:

Default: The SNS Topic will not be encrypted.

If AddAutoScalingGroupCapacityOptions.taskDrainTime is non-zero, then the ECS cluster creates an SNS Topic to as part of a system to drain instances of tasks when the instance is being shut down. If this property is provided, then this key will be used to encrypt the contents of that SNS Topic. See SNS Data Encryption for more information.

Returns:



140
141
142
# File 'ecs/add_capacity_options.rb', line 140

def topic_encryption_key
  @topic_encryption_key
end

#update_policyAWSCDK::Autoscaling::UpdatePolicy? (readonly)

Note:

Default: - UpdatePolicy.rollingUpdate() if using init, UpdatePolicy.none() otherwise

What to do when an AutoScalingGroup's instance configuration is changed.

This is applied when any of the settings on the ASG are changed that affect how the instances should be created (VPC, instance type, startup scripts, etc.). It indicates how the existing instances should be replaced with new instances matching the new config. By default, nothing is done and only new instances are launched with the new config.



410
411
412
# File 'ecs/add_capacity_options.rb', line 410

def update_policy
  @update_policy
end

#vpc_subnetsAWSCDK::EC2::SubnetSelection? (readonly)

Note:

Default: - All Private subnets.

Where to place instances within the VPC.



415
416
417
# File 'ecs/add_capacity_options.rb', line 415

def vpc_subnets
  @vpc_subnets
end

Class Method Details

.jsii_propertiesObject



444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
# File 'ecs/add_capacity_options.rb', line 444

def self.jsii_properties
  {
    :machine_image_type => "machineImageType",
    :spot_instance_draining => "spotInstanceDraining",
    :topic_encryption_key => "topicEncryptionKey",
    :allow_all_outbound => "allowAllOutbound",
    :associate_public_ip_address => "associatePublicIpAddress",
    :auto_scaling_group_name => "autoScalingGroupName",
    :az_capacity_distribution_strategy => "azCapacityDistributionStrategy",
    :block_devices => "blockDevices",
    :capacity_rebalance => "capacityRebalance",
    :cooldown => "cooldown",
    :default_instance_warmup => "defaultInstanceWarmup",
    :deletion_protection => "deletionProtection",
    :desired_capacity => "desiredCapacity",
    :group_metrics => "groupMetrics",
    :health_check => "healthCheck",
    :health_checks => "healthChecks",
    :ignore_unmodified_size_properties => "ignoreUnmodifiedSizeProperties",
    :instance_lifecycle_policy => "instanceLifecyclePolicy",
    :instance_monitoring => "instanceMonitoring",
    :key_name => "keyName",
    :key_pair => "keyPair",
    :max_capacity => "maxCapacity",
    :max_instance_lifetime => "maxInstanceLifetime",
    :min_capacity => "minCapacity",
    :new_instances_protected_from_scale_in => "newInstancesProtectedFromScaleIn",
    :notifications => "notifications",
    :signals => "signals",
    :spot_price => "spotPrice",
    :ssm_session_permissions => "ssmSessionPermissions",
    :termination_policies => "terminationPolicies",
    :termination_policy_custom_lambda_function_arn => "terminationPolicyCustomLambdaFunctionArn",
    :update_policy => "updatePolicy",
    :vpc_subnets => "vpcSubnets",
    :instance_type => "instanceType",
    :machine_image => "machineImage",
  }
end

Instance Method Details

#to_jsiiObject



484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
# File 'ecs/add_capacity_options.rb', line 484

def to_jsii
  result = {}
  result.merge!(super)
  result.merge!({
    "machineImageType" => @machine_image_type,
    "spotInstanceDraining" => @spot_instance_draining,
    "topicEncryptionKey" => @topic_encryption_key,
    "allowAllOutbound" => @allow_all_outbound,
    "associatePublicIpAddress" => @associate_public_ip_address,
    "autoScalingGroupName" => @auto_scaling_group_name,
    "azCapacityDistributionStrategy" => @az_capacity_distribution_strategy,
    "blockDevices" => @block_devices,
    "capacityRebalance" => @capacity_rebalance,
    "cooldown" => @cooldown,
    "defaultInstanceWarmup" => @default_instance_warmup,
    "deletionProtection" => @deletion_protection,
    "desiredCapacity" => @desired_capacity,
    "groupMetrics" => @group_metrics,
    "healthCheck" => @health_check,
    "healthChecks" => @health_checks,
    "ignoreUnmodifiedSizeProperties" => @ignore_unmodified_size_properties,
    "instanceLifecyclePolicy" => @instance_lifecycle_policy,
    "instanceMonitoring" => @instance_monitoring,
    "keyName" => @key_name,
    "keyPair" => @key_pair,
    "maxCapacity" => @max_capacity,
    "maxInstanceLifetime" => @max_instance_lifetime,
    "minCapacity" => @min_capacity,
    "newInstancesProtectedFromScaleIn" => @new_instances_protected_from_scale_in,
    "notifications" => @notifications,
    "signals" => @signals,
    "spotPrice" => @spot_price,
    "ssmSessionPermissions" => @ssm_session_permissions,
    "terminationPolicies" => @termination_policies,
    "terminationPolicyCustomLambdaFunctionArn" => @termination_policy_custom_lambda_function_arn,
    "updatePolicy" => @update_policy,
    "vpcSubnets" => @vpc_subnets,
    "instanceType" => @instance_type,
    "machineImage" => @machine_image,
  })
  result.compact
end