class AmazonLinuxImage
Language | Type name |
---|---|
![]() | Amazon.CDK.AWS.EC2.AmazonLinuxImage |
![]() | github.com/aws/aws-cdk-go/awscdk/v2/awsec2#AmazonLinuxImage |
![]() | software.amazon.awscdk.services.ec2.AmazonLinuxImage |
![]() | aws_cdk.aws_ec2.AmazonLinuxImage |
![]() | aws-cdk-lib » aws_ec2 » AmazonLinuxImage |
Implements
IMachine
Extends
Generic
Selects the latest version of Amazon Linux.
This Machine Image automatically updates to the latest version on every deployment. Be aware this will cause your instances to be replaced when a new version of the image becomes available. Do not store stateful information on the instance if you are using this image.
The AMI ID is selected using the values published to the SSM parameter store.
Example
declare const vpc: ec2.IVpc;
const lb = new elb.LoadBalancer(this, 'LB', {
vpc,
internetFacing: true,
});
// instance to add as the target for load balancer.
const instance = new ec2.Instance(this, 'targetInstance', {
vpc: vpc,
instanceType: ec2.InstanceType.of(ec2.InstanceClass.BURSTABLE2, ec2.InstanceSize.MICRO),
machineImage: new ec2.AmazonLinuxImage({ generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2 }),
});
lb.addTarget(new elb.InstanceTarget(instance));
Initializer
new AmazonLinuxImage(props?: AmazonLinuxImageProps)
Parameters
- props
Amazon
Linux Image Props
Properties
Name | Type | Description |
---|---|---|
parameter | string | Name of the SSM parameter we're looking up. |
parameterName
Type:
string
Name of the SSM parameter we're looking up.
Methods
Name | Description |
---|---|
get | Return the image to use in the given context. |
static ssm | Return the SSM parameter name that will contain the Amazon Linux image with the given attributes. |
getImage(scope)
public getImage(scope: Construct): MachineImageConfig
Parameters
- scope
Construct
Returns
Return the image to use in the given context.
static ssmParameterName(props?)
public static ssmParameterName(props?: AmazonLinuxImageProps): string
Parameters
- props
Amazon
Linux Image Props
Returns
string
Return the SSM parameter name that will contain the Amazon Linux image with the given attributes.