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 } } data "aws_ami" "server_ami" { most_recent = true # Get the most recent version of the AMI owners = ["099720109477"] # This ID represents Canonical, the company behind Ubuntu # Filter to find Ubuntu 22.04 LTS (Jammy Jellyfish) AMIs filter { name = "name" 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"] } }