2025-01-12 12:05:58 +01:00
|
|
|
data "cloudinit_config" "config" {
|
|
|
|
gzip = true # Compress the cloud-init data to save space
|
|
|
|
base64_encode = true # Encode the data in base64 for proper transmission to EC2
|
|
|
|
|
|
|
|
part {
|
|
|
|
content_type = "text/cloud-config" # Specify that this is a cloud-config file
|
|
|
|
content = file("${path.module}/cloudinit.yml") # Read the content of the cloudinit.yml file
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-09-17 20:56:50 +02:00
|
|
|
data "aws_ami" "server_ami" {
|
2025-01-12 12:05:58 +01:00
|
|
|
most_recent = true # Get the most recent version of the AMI
|
|
|
|
owners = ["099720109477"] # This ID represents Canonical, the company behind Ubuntu
|
2024-09-17 20:56:50 +02:00
|
|
|
|
2025-01-12 12:05:58 +01:00
|
|
|
# Filter to find Ubuntu 22.04 LTS (Jammy Jellyfish) AMIs
|
2024-09-17 20:56:50 +02:00
|
|
|
filter {
|
|
|
|
name = "name"
|
2025-01-12 12:05:58 +01:00
|
|
|
values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Ensure we're getting a hardware virtual machine (HVM) AMI
|
|
|
|
filter {
|
|
|
|
name = "virtualization-type"
|
|
|
|
values = ["hvm"]
|
|
|
|
}
|
|
|
|
|
|
|
|
# Specify that we want an x86_64 architecture (suitable for t2.micro instances)
|
|
|
|
filter {
|
|
|
|
name = "architecture"
|
|
|
|
values = ["x86_64"]
|
2024-09-17 20:56:50 +02:00
|
|
|
}
|
|
|
|
}
|