Last active
February 28, 2024 10:35
-
-
Save Cyclenerd/fc5c51b25539a735cfb6707948255992 to your computer and use it in GitHub Desktop.
Amazon Machine Images (AMI) Snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
provider "aws" { | |
region = "eu-central-1" | |
default_tags { | |
tags = { | |
terraform = "true" | |
} | |
} | |
} | |
# https://registry.terraform.io/providers/-/aws/latest/docs/data-sources/ami | |
data "aws_ami" "image" { | |
most_recent = true | |
filter { | |
name = "name" | |
values = ["ubuntu-minimal/images/hvm-ssd/ubuntu-jammy-22.04-*"] | |
} | |
filter { | |
name = "architecture" | |
values = ["x86_64"] | |
} | |
owners = ["099720109477"] # Canonical | |
} | |
output "image" { | |
description = "AMI ID" | |
value = data.aws_ami.image.id | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy an AMI (you can copy an AMI from one Region to another) | |
# https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/CopyingAMIs.html#ami-copy-steps | |
# https://docs.aws.amazon.com/cli/latest/reference/ec2/copy-image.html | |
aws ec2 copy-image \ | |
--source-image-id "ami-03b52b3400f6c6a77" \ | |
--source-region "us-east-1" \ | |
--name "freebsd_13.3_x86_64-nils" \ | |
--region "eu-central-1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment