How to find latest ubuntu ami for aws ec2

Do follow this way.

1 Answers

  • #241
    Up
    0
    Down

    Do follow this way.

    #242
    Up
    0
    Down

    Below are given the ways to find latest ec2 Ubuntu Ami using Aws-cli, Terraform and Cloudformation.

    1. To find latest Ubuntu Ami using Aws-cli ————

    echo “Finding latest Ubuntu Image”
    image_ID=$(aws ec2 describe-images \
    –owners 099720109477 \
    –filters Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-focal-* \
    –query ‘sort_by(Images,&CreationDate)[-1].ImageId’ \
    –output text)

    echo $image_ID

    2. To find latest Ubuntu Ami using Terraform ————-

    ami = data.aws_ami.ubuntu_ami.id

    ————————————————–

    data “aws_ami” “ubuntu_ami” {
    most_recent = true
    owners = [“099720109477”]

    filter {
    name = “name”
    values = [“ubuntu/images/hvm-ssd/ubuntu-*”]
    }

    3. To find latest Ubuntu Ami using Cloudformation ————-

    “Parameters”: {

    “WindowsLatestAmiId” : {
    “Type” : “AWS::SSM::Parameter::Value<AWS::EC2::Image::Id>”,
    “Default”: “/aws/service/ami-windows-latest/
    Windows_Server-2019-English-Full-Base”
    }
    }

    —————————————–

    “ImageId” : { “Ref” : “WindowsLatestAmiId” }

    • This reply was modified 3 months, 4 weeks ago by Harjap.
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.