@@ -64,38 +64,44 @@ This module does not support encrypted AMI's out of the box however it is easy e
6464This example creates an encrypted image from the latest ubuntu 16.04 base image.
6565
6666``` hcl
67- resource "aws_ami_copy" "ubuntu-xenial-encrypted-ami" {
68- name = "ubuntu-xenial-encrypted-ami"
69- description = "An encrypted root ami based off ${data.aws_ami.ubuntu-xenial.id}"
70- source_ami_id = "${data.aws_ami.ubuntu-xenial.id}"
71- source_ami_region = "eu-west-2"
72- encrypted = "true"
73-
74- tags {
75- Name = "ubuntu-xenial-encrypted-ami"
76- }
67+ provider "aws" {
68+ region = "us-west-2"
7769}
7870
79- data "aws_ami" "encrypted-ami " {
71+ data "aws_ami" "ubuntu " {
8072 most_recent = true
73+ owners = ["679593333241"]
8174
8275 filter {
8376 name = "name"
84- values = ["ubuntu-xenial-encrypted "]
77+ values = ["ubuntu-minimal/images/hvm-ssd/ubuntu-focal-20.04-* "]
8578 }
8679
87- owners = ["self"]
80+ filter {
81+ name = "virtualization-type"
82+ values = ["hvm"]
83+ }
8884}
8985
90- data "aws_ami" "ubuntu-xenial" {
86+ resource "aws_ami_copy" "ubuntu_encrypted_ami" {
87+ name = "ubuntu-encrypted-ami"
88+ description = "An encrypted root ami based off ${data.aws_ami.ubuntu.id}"
89+ source_ami_id = data.aws_ami.ubuntu.id
90+ source_ami_region = "eu-west-2"
91+ encrypted = true
92+
93+ tags = { Name = "ubuntu-encrypted-ami" }
94+ }
95+
96+ data "aws_ami" "encrypted-ami" {
9197 most_recent = true
9298
9399 filter {
94100 name = "name"
95- values = ["ubuntu/images/hvm-ssd/ubuntu-xenial-16.04-amd64-server-*" ]
101+ values = [aws_ami_copy.ubuntu_encrypted_ami.id ]
96102 }
97103
98- owners = ["099720109477 "]
104+ owners = ["self "]
99105}
100106```
101107
0 commit comments