Skip to content

Instantly share code, notes, and snippets.

@arianvp
Created November 6, 2024 13:21
Show Gist options
  • Save arianvp/14dd40742c24894bb312ac3f5b90b433 to your computer and use it in GitHub Desktop.
Save arianvp/14dd40742c24894bb312ac3f5b90b433 to your computer and use it in GitHub Desktop.
resource "aws_s3_bucket_item" "this" {
bucket = "images"
key = var.image_name
source = var.image_path
}
resource "aws_ebs_snapshort_import" "this" {
disk_container {
type = "VHD"
user_bucket = aws_s3_bucket_item.this.bucket
s3_key = aws_s3_bucket_item.this.key
}
}
resource "aws_ami" "this" {
name = var.image_name
virtualization_type = "hvm"
root_device_name = "/dev/xvda"
imds_support = "v2.0"
architecture = "x86_64"
ebs_block_device {
device_name = "/dev/xvda"
snapshot_id = aws_ebs_snapshort_import.this.snapshot_id
}
}
resource "aws_instance" "this" {
ami = aws_ami.this.id
instance_type = "t4g.small"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment