diff --git a/README.md b/README.md index b1979469..9c3e8f66 100644 --- a/README.md +++ b/README.md @@ -64,38 +64,44 @@ This module does not support encrypted AMI's out of the box however it is easy e This example creates an encrypted image from the latest ubuntu 16.04 base image. ```hcl -resource "aws_ami_copy" "ubuntu-xenial-encrypted-ami" { - name = "ubuntu-xenial-encrypted-ami" - description = "An encrypted root ami based off ${data.aws_ami.ubuntu-xenial.id}" - source_ami_id = "${data.aws_ami.ubuntu-xenial.id}" - source_ami_region = "eu-west-2" - encrypted = "true" - - tags { - Name = "ubuntu-xenial-encrypted-ami" - } +provider "aws" { + region = "us-west-2" } -data "aws_ami" "encrypted-ami" { +data "aws_ami" "ubuntu" { most_recent = true + owners = ["679593333241"] filter { name = "name" - values = ["ubuntu-xenial-encrypted"] + values = ["ubuntu-minimal/images/hvm-ssd/ubuntu-focal-20.04-*"] } - owners = ["self"] + filter { + name = "virtualization-type" + values = ["hvm"] + } } -data "aws_ami" "ubuntu-xenial" { +resource "aws_ami_copy" "ubuntu_encrypted_ami" { + name = "ubuntu-encrypted-ami" + description = "An encrypted root ami based off ${data.aws_ami.ubuntu.id}" + source_ami_id = data.aws_ami.ubuntu.id + source_ami_region = "eu-west-2" + encrypted = true + + tags = { Name = "ubuntu-encrypted-ami" } +} + +data "aws_ami" "encrypted-ami" { most_recent = true filter { name = "name" - values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*"] + values = [aws_ami_copy.ubuntu_encrypted_ami.id] } - owners = ["099720109477"] + owners = ["self"] } ```