From 4671aa098d11abe6d34846f3bf69617865c79733 Mon Sep 17 00:00:00 2001 From: Bryant Biggs Date: Thu, 26 Aug 2021 11:27:28 -0400 Subject: [PATCH 1/2] chore: update `README.md` example for making an encrypted AMI --- README.md | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index b1979469..1ae4c24f 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"] } ``` From 4875449c7063726e61b969610c0d6f96dee5b56b Mon Sep 17 00:00:00 2001 From: Anton Babenko Date: Thu, 26 Aug 2021 21:40:28 +0200 Subject: [PATCH 2/2] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1ae4c24f..9c3e8f66 100644 --- a/README.md +++ b/README.md @@ -88,7 +88,7 @@ resource "aws_ami_copy" "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" + encrypted = true tags = { Name = "ubuntu-encrypted-ami" } }