class EcsOptimizedImage
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.ECS.EcsOptimizedImage |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsecs#EcsOptimizedImage |
![]() | software.amazon.awscdk.services.ecs.EcsOptimizedImage |
![]() | aws_cdk.aws_ecs.EcsOptimizedImage |
![]() | aws-cdk-lib » aws_ecs » EcsOptimizedImage |
Implements
IMachine
Construct a Linux or Windows machine image from the latest ECS Optimized AMI published in SSM.
Example
declare const vpc: ec2.Vpc;
const cluster = new ecs.Cluster(this, 'Cluster', {
vpc,
});
// Either add default capacity
cluster.addCapacity('DefaultAutoScalingGroupCapacity', {
instanceType: new ec2.InstanceType("t2.xlarge"),
desiredCapacity: 3,
});
// Or add customized capacity. Be sure to start the Amazon ECS-optimized AMI.
const autoScalingGroup = new autoscaling.AutoScalingGroup(this, 'ASG', {
vpc,
instanceType: new ec2.InstanceType('t2.xlarge'),
machineImage: ecs.EcsOptimizedImage.amazonLinux(),
// Or use Amazon ECS-Optimized Amazon Linux 2 AMI
// machineImage: EcsOptimizedImage.amazonLinux2(),
desiredCapacity: 3,
// ... other options here ...
});
const capacityProvider = new ecs.AsgCapacityProvider(this, 'AsgCapacityProvider', {
autoScalingGroup,
});
cluster.addAsgCapacityProvider(capacityProvider);
Methods
Name | Description |
---|---|
get | Return the correct image. |
static amazon | Construct an Amazon Linux AMI image from the latest ECS Optimized AMI published in SSM. |
static amazon | Construct an Amazon Linux 2 image from the latest ECS Optimized AMI published in SSM. |
static amazon | Construct an Amazon Linux 2023 image from the latest ECS Optimized AMI published in SSM. |
static windows(windowsVersion, options?) | Construct a Windows image from the latest ECS Optimized AMI published in SSM. |
getImage(scope)
public getImage(scope: Construct): MachineImageConfig
Parameters
- scope
Construct
Returns
Return the correct image.
static amazonLinux(options?)
public static amazonLinux(options?: EcsOptimizedImageOptions): EcsOptimizedImage
Parameters
- options
Ecs
Optimized Image Options
Returns
Construct an Amazon Linux AMI image from the latest ECS Optimized AMI published in SSM.
static amazonLinux2(hardwareType?, options?)
public static amazonLinux2(hardwareType?: AmiHardwareType, options?: EcsOptimizedImageOptions): EcsOptimizedImage
Parameters
- hardwareType
Ami
— ECS-optimized AMI variant to use.Hardware Type - options
Ecs
Optimized Image Options
Returns
Construct an Amazon Linux 2 image from the latest ECS Optimized AMI published in SSM.
static amazonLinux2023(hardwareType?, options?)
public static amazonLinux2023(hardwareType?: AmiHardwareType, options?: EcsOptimizedImageOptions): EcsOptimizedImage
Parameters
- hardwareType
Ami
— ECS-optimized AMI variant to use.Hardware Type - options
Ecs
Optimized Image Options
Returns
Construct an Amazon Linux 2023 image from the latest ECS Optimized AMI published in SSM.
static windows(windowsVersion, options?)
public static windows(windowsVersion: WindowsOptimizedVersion, options?: EcsOptimizedImageOptions): EcsOptimizedImage
Parameters
- windowsVersion
Windows
— Windows Version to use.Optimized Version - options
Ecs
Optimized Image Options
Returns
Construct a Windows image from the latest ECS Optimized AMI published in SSM.