github.com/swisspost/terratest@v0.0.0-20230214120104-7ec6de2e1ae0/examples/packer-basic-example/build.pkr.hcl (about) 1 packer { 2 required_plugins { 3 amazon = { 4 version = ">=v1.0.0" 5 source = "github.com/hashicorp/amazon" 6 } 7 oracle = { 8 version = ">=v1.0.0" 9 source = "github.com/hashicorp/oracle" 10 } 11 } 12 } 13 14 variable "ami_base_name" { 15 type = string 16 default = "" 17 } 18 19 variable "aws_region" { 20 type = string 21 default = "us-east-1" 22 } 23 24 variable "instance_type" { 25 type = string 26 default = "t2.micro" 27 } 28 29 variable "oci_availability_domain" { 30 type = string 31 default = "" 32 } 33 34 variable "oci_base_image_ocid" { 35 type = string 36 default = "" 37 } 38 39 variable "oci_compartment_ocid" { 40 type = string 41 default = "" 42 } 43 44 variable "oci_pass_phrase" { 45 type = string 46 default = "" 47 } 48 49 variable "oci_subnet_ocid" { 50 type = string 51 default = "" 52 } 53 54 data "amazon-ami" "ubuntu-xenial" { 55 filters = { 56 architecture = "x86_64" 57 "block-device-mapping.volume-type" = "gp2" 58 name = "*ubuntu-xenial-16.04-amd64-server-*" 59 root-device-type = "ebs" 60 virtualization-type = "hvm" 61 } 62 most_recent = true 63 owners = ["099720109477"] 64 region = var.aws_region 65 } 66 67 source "amazon-ebs" "ubuntu-example" { 68 ami_description = "An example of how to create a custom AMI on top of Ubuntu" 69 ami_name = "${var.ami_base_name}-terratest-packer-example" 70 encrypt_boot = false 71 instance_type = var.instance_type 72 region = var.aws_region 73 source_ami = data.amazon-ami.ubuntu-xenial.id 74 ssh_username = "ubuntu" 75 } 76 77 source "oracle-oci" "oracle-example" { 78 availability_domain = var.oci_availability_domain 79 base_image_ocid = var.oci_base_image_ocid 80 compartment_ocid = var.oci_compartment_ocid 81 image_name = "terratest-packer-example-${formatdate("YYYYMMDD-hhmm", timestamp())}" 82 pass_phrase = var.oci_pass_phrase 83 shape = "VM.Standard2.1" 84 ssh_username = "ubuntu" 85 subnet_ocid = var.oci_subnet_ocid 86 } 87 88 build { 89 sources = [ 90 "source.amazon-ebs.ubuntu-example", 91 "source.oracle-oci.oracle-example" 92 ] 93 94 provisioner "shell" { 95 inline = ["sudo DEBIAN_FRONTEND=noninteractive apt-get update", "sudo DEBIAN_FRONTEND=noninteractive apt-get upgrade -y"] 96 pause_before = "30s" 97 } 98 }