aws-cdk-lib.aws_ec2.AmazonLinuxImage
get
static ssm
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
const sg = ec2.SecurityGroup.fromSecurityGroupId(this, 'FsxSecurityGroup', '{SECURITY-GROUP-ID}');
const fs = fsx.LustreFileSystem.fromLustreFileSystemAttributes(this, 'FsxLustreFileSystem', {
dnsName: '{FILE-SYSTEM-DNS-NAME}',
fileSystemId: '{FILE-SYSTEM-ID}',
securityGroup: sg,
});
const vpc = ec2.Vpc.fromVpcAttributes(this, 'Vpc', {
availabilityZones: ['us-west-2a', 'us-west-2b'],
publicSubnetIds: ['{US-WEST-2A-SUBNET-ID}', '{US-WEST-2B-SUBNET-ID}'],
vpcId: '{VPC-ID}',
});
const inst = new ec2.Instance(this, 'inst', {
instanceType: ec2.InstanceType.of(ec2.InstanceClass.T2, ec2.InstanceSize.LARGE),
machineImage: new ec2.AmazonLinuxImage({
generation: ec2.AmazonLinuxGeneration.AMAZON_LINUX_2,
}),
vpc,
vpcSubnets: {
subnetType: ec2.SubnetType.PUBLIC,
},
});
fs.connections.allowDefaultPortFrom(inst);
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. |
Image(scope)
getpublic getImage(scope: Construct): MachineImageConfig
Parameters
- scope
Construct
Returns
Return the image to use in the given context.
ParameterName(props?)
static ssmpublic 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.