Class: AWSCDK::ECS::ManagedInstancesCapacityProviderProps

Inherits:
Jsii::Struct
  • Object
show all
Defined in:
ecs/managed_instances_capacity_provider_props.rb

Overview

The options for creating a Managed Instances Capacity Provider.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(security_groups:, subnets:, capacity_option_type: nil, capacity_provider_name: nil, ec2_instance_profile: nil, infrastructure_role: nil, instance_requirements: nil, monitoring: nil, propagate_tags: nil, task_volume_storage: nil) ⇒ ManagedInstancesCapacityProviderProps

Returns a new instance of ManagedInstancesCapacityProviderProps.

Parameters:

  • security_groups (Array<AWSCDK::EC2::ISecurityGroup>)

    The security groups to associate with the launched EC2 instances.

  • subnets (Array<AWSCDK::EC2::ISubnet>)

    The VPC subnets where EC2 instances will be launched.

  • capacity_option_type (AWSCDK::ECS::CapacityOptionType, nil) (defaults to: nil)

    Specifies the capacity option type for instances launched by this capacity provider.

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

    The name of the capacity provider.

  • ec2_instance_profile (AWSCDK::IAM::IInstanceProfile, nil) (defaults to: nil)

    The EC2 instance profile that will be attached to instances launched by this capacity provider.

  • infrastructure_role (AWSCDK::IAM::IRole, nil) (defaults to: nil)

    The IAM role that ECS uses to manage the infrastructure for the capacity provider.

  • instance_requirements (AWSCDK::EC2::InstanceRequirementsConfig, nil) (defaults to: nil)

    The instance requirements configuration for EC2 instance selection.

  • monitoring (AWSCDK::ECS::InstanceMonitoring, nil) (defaults to: nil)

    The CloudWatch monitoring configuration for the EC2 instances.

  • propagate_tags (AWSCDK::ECS::PropagateManagedInstancesTags, nil) (defaults to: nil)

    Specifies whether to propagate tags from the capacity provider to the launched instances.

  • task_volume_storage (AWSCDK::Size, nil) (defaults to: nil)

    The size of the task volume storage attached to each instance.



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'ecs/managed_instances_capacity_provider_props.rb', line 17

def initialize(security_groups:, subnets:, capacity_option_type: nil, capacity_provider_name: nil, ec2_instance_profile: nil, infrastructure_role: nil, instance_requirements: nil, monitoring: nil, propagate_tags: nil, task_volume_storage: nil)
  @security_groups = security_groups
  Jsii::Type.check_type(@security_groups, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lYzIuSVNlY3VyaXR5R3JvdXAifSwia2luZCI6ImFycmF5In19")), "securityGroups")
  @subnets = subnets
  Jsii::Type.check_type(@subnets, JSON.parse(Base64.strict_decode64("eyJjb2xsZWN0aW9uIjp7ImVsZW1lbnR0eXBlIjp7ImZxbiI6ImF3cy1jZGstbGliLmF3c19lYzIuSVN1Ym5ldCJ9LCJraW5kIjoiYXJyYXkifX0=")), "subnets")
  @capacity_option_type = capacity_option_type
  Jsii::Type.check_type(@capacity_option_type, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkNhcGFjaXR5T3B0aW9uVHlwZSJ9")), "capacityOptionType") unless @capacity_option_type.nil?
  @capacity_provider_name = capacity_provider_name
  Jsii::Type.check_type(@capacity_provider_name, JSON.parse(Base64.strict_decode64("eyJwcmltaXRpdmUiOiJzdHJpbmcifQ==")), "capacityProviderName") unless @capacity_provider_name.nil?
  @ec2_instance_profile = ec2_instance_profile
  Jsii::Type.check_type(@ec2_instance_profile, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklJbnN0YW5jZVByb2ZpbGUifQ==")), "ec2InstanceProfile") unless @ec2_instance_profile.nil?
  @infrastructure_role = infrastructure_role
  Jsii::Type.check_type(@infrastructure_role, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfaWFtLklSb2xlIn0=")), "infrastructureRole") unless @infrastructure_role.nil?
  @instance_requirements = instance_requirements.is_a?(Hash) ? ::AWSCDK::EC2::InstanceRequirementsConfig.new(**instance_requirements.transform_keys(&:to_sym)) : instance_requirements
  Jsii::Type.check_type(@instance_requirements, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWMyLkluc3RhbmNlUmVxdWlyZW1lbnRzQ29uZmlnIn0=")), "instanceRequirements") unless @instance_requirements.nil?
  @monitoring = monitoring
  Jsii::Type.check_type(@monitoring, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLkluc3RhbmNlTW9uaXRvcmluZyJ9")), "monitoring") unless @monitoring.nil?
  @propagate_tags = propagate_tags
  Jsii::Type.check_type(@propagate_tags, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5hd3NfZWNzLlByb3BhZ2F0ZU1hbmFnZWRJbnN0YW5jZXNUYWdzIn0=")), "propagateTags") unless @propagate_tags.nil?
  @task_volume_storage = task_volume_storage
  Jsii::Type.check_type(@task_volume_storage, JSON.parse(Base64.strict_decode64("eyJmcW4iOiJhd3MtY2RrLWxpYi5TaXplIn0=")), "taskVolumeStorage") unless @task_volume_storage.nil?
end

Instance Attribute Details

#capacity_option_typeAWSCDK::ECS::CapacityOptionType? (readonly)

Note:

Default: - ON_DEMAND

Specifies the capacity option type for instances launched by this capacity provider.

This determines whether instances are launched as On-Demand or Spot instances.



59
60
61
# File 'ecs/managed_instances_capacity_provider_props.rb', line 59

def capacity_option_type
  @capacity_option_type
end

#capacity_provider_nameString? (readonly)

Note:

Default: CloudFormation-generated name

The name of the capacity provider.

If a name is specified, it cannot start with aws, ecs, or fargate. If no name is specified, a default name in the CFNStackName-CFNResourceName-RandomString format is used. If the stack name starts with aws, ecs, or fargate, a unique resource name is generated that starts with cp-.

Returns:

  • (String, nil)


69
70
71
# File 'ecs/managed_instances_capacity_provider_props.rb', line 69

def capacity_provider_name
  @capacity_provider_name
end

#ec2_instance_profileAWSCDK::IAM::IInstanceProfile? (readonly)

Note:

Default: - A new instance profile prefixed with 'ecsInstanceRole' will be created

The EC2 instance profile that will be attached to instances launched by this capacity provider.

This instance profile must contain the necessary IAM permissions for ECS container instances to register with the cluster and run tasks. At minimum, it should include permissions for ECS agent communication, ECR image pulling, and CloudWatch logging.

If you are using Amazon ECS Managed Instances with the AWS-managed Infrastructure policy (AmazonECSInfrastructureRolePolicyForManagedInstances), the instance profile must be prefixed with ecs_instance_role for the built in PassRole policy to apply.

If you are using a custom policy for the Infrastructure role, the instance profile can have an alternative name.



84
85
86
# File 'ecs/managed_instances_capacity_provider_props.rb', line 84

def ec2_instance_profile
  @ec2_instance_profile
end

#infrastructure_roleAWSCDK::IAM::IRole? (readonly)

Note:

Default: - A new role will be created with the AmazonECSInfrastructureRolePolicyForManagedInstances managed policy

The IAM role that ECS uses to manage the infrastructure for the capacity provider.

This role is used by ECS to perform actions such as launching and terminating instances, managing Auto Scaling Groups, and other infrastructure operations required for the managed instances capacity provider.

Returns:



93
94
95
# File 'ecs/managed_instances_capacity_provider_props.rb', line 93

def infrastructure_role
  @infrastructure_role
end

#instance_requirementsAWSCDK::EC2::InstanceRequirementsConfig? (readonly)

Note:

Default: - no specific instance requirements, ECS will choose appropriate instances

The instance requirements configuration for EC2 instance selection.

This allows you to specify detailed requirements for instance selection including vCPU count ranges, memory ranges, CPU manufacturers (Intel, AMD, AWS Graviton), instance generations, network performance requirements, and many other criteria. ECS will automatically select appropriate instance types that meet these requirements.



103
104
105
# File 'ecs/managed_instances_capacity_provider_props.rb', line 103

def instance_requirements
  @instance_requirements
end

#monitoringAWSCDK::ECS::InstanceMonitoring? (readonly)

Note:

Default: - no enhanced monitoring (basic monitoring only)

The CloudWatch monitoring configuration for the EC2 instances.

Determines the granularity of CloudWatch metrics collection for the instances. Detailed monitoring incurs additional costs but provides better observability.



111
112
113
# File 'ecs/managed_instances_capacity_provider_props.rb', line 111

def monitoring
  @monitoring
end

#propagate_tagsAWSCDK::ECS::PropagateManagedInstancesTags? (readonly)

Note:

Default: PropagateManagedInstancesTags.NONE - no tag propagation

Specifies whether to propagate tags from the capacity provider to the launched instances.

When set to CAPACITY_PROVIDER, tags applied to the capacity provider resource will be automatically applied to all EC2 instances launched by this capacity provider.



119
120
121
# File 'ecs/managed_instances_capacity_provider_props.rb', line 119

def propagate_tags
  @propagate_tags
end

#security_groupsArray<AWSCDK::EC2::ISecurityGroup> (readonly)

The security groups to associate with the launched EC2 instances.

These security groups control the network traffic allowed to and from the instances.

Returns:



45
46
47
# File 'ecs/managed_instances_capacity_provider_props.rb', line 45

def security_groups
  @security_groups
end

#subnetsArray<AWSCDK::EC2::ISubnet> (readonly)

The VPC subnets where EC2 instances will be launched.

This array must be non-empty and should contain subnets from the VPC where you want the managed instances to be deployed.

Returns:



52
53
54
# File 'ecs/managed_instances_capacity_provider_props.rb', line 52

def subnets
  @subnets
end

#task_volume_storageAWSCDK::Size? (readonly)

Note:

Default: Size.gibibytes(80)

The size of the task volume storage attached to each instance.

This storage is used for container images, container logs, and temporary files. Larger storage may be needed for workloads with large container images or applications that generate significant temporary data.

Returns:



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

def task_volume_storage
  @task_volume_storage
end

Class Method Details

.jsii_propertiesObject



130
131
132
133
134
135
136
137
138
139
140
141
142
143
# File 'ecs/managed_instances_capacity_provider_props.rb', line 130

def self.jsii_properties
  {
    :security_groups => "securityGroups",
    :subnets => "subnets",
    :capacity_option_type => "capacityOptionType",
    :capacity_provider_name => "capacityProviderName",
    :ec2_instance_profile => "ec2InstanceProfile",
    :infrastructure_role => "infrastructureRole",
    :instance_requirements => "instanceRequirements",
    :monitoring => "monitoring",
    :propagate_tags => "propagateTags",
    :task_volume_storage => "taskVolumeStorage",
  }
end

Instance Method Details

#to_jsiiObject



145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'ecs/managed_instances_capacity_provider_props.rb', line 145

def to_jsii
  result = {}
  result.merge!({
    "securityGroups" => @security_groups,
    "subnets" => @subnets,
    "capacityOptionType" => @capacity_option_type,
    "capacityProviderName" => @capacity_provider_name,
    "ec2InstanceProfile" => @ec2_instance_profile,
    "infrastructureRole" => @infrastructure_role,
    "instanceRequirements" => @instance_requirements,
    "monitoring" => @monitoring,
    "propagateTags" => @propagate_tags,
    "taskVolumeStorage" => @task_volume_storage,
  })
  result.compact
end