Forum Replies Created

Viewing 2 posts - 16 through 17 (of 17 total)
  • in reply to: How to find latest Windows ami for Aws ec2 #273
    Up
    1
    Down

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

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

    echo “Finding latest Windows Image”

    image_ID=$(aws ec2 describe-images \
    –owners 801119661308 \
    –filters Name=name,Values=Windows_Server-2019-English-Full-Base-* \
    –query ‘sort_by(Images,&CreationDate)[-1].ImageId’ \
    –output text)

    echo $image_ID
    ———————————-
    –image-id $image_ID \

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

    ami = data.aws_ami.windows_ami.id

    —————————————

    data “aws_ami” “windows_ami” {
    most_recent = true
    owners = [“801119661308”]

    filter {
    name = “name”
    values = [“Windows_Server-2019-English-Full-Base-*”]
    }
    filter {
    name = “virtualization-type”
    values = [“hvm”]
    }

    3. To find latest Windows 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” }

    in reply to: How to find latest ubuntu ami for aws ec2 #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 2 years, 1 month ago by Harjap.
Viewing 2 posts - 16 through 17 (of 17 total)