github.com/hashicorp/packer@v1.14.3/command/test-fixtures/hcl2_upgrade/without-annotations/expected.pkr.hcl (about) 1 packer { 2 required_version = ">= 1.6.0" 3 required_plugins { 4 amazon = { 5 source = "github.com/hashicorp/amazon" 6 version = "~> 1" 7 } 8 } 9 } 10 11 variable "aws_access_key" { 12 type = string 13 default = "" 14 sensitive = true 15 } 16 17 variable "aws_region" { 18 type = string 19 } 20 21 variable "aws_secondary_region" { 22 type = string 23 default = "${env("AWS_DEFAULT_REGION")}" 24 } 25 26 variable "aws_secret_key" { 27 type = string 28 default = "" 29 sensitive = true 30 } 31 32 variable "secret_account" { 33 type = string 34 default = "🤷" 35 sensitive = true 36 } 37 38 data "amazon-secretsmanager" "autogenerated_1" { 39 name = "sample/app/password" 40 } 41 42 data "amazon-secretsmanager" "autogenerated_2" { 43 key = "api_key" 44 name = "sample/app/passwords" 45 } 46 47 data "amazon-secretsmanager" "autogenerated_3" { 48 name = "some_secret" 49 } 50 51 data "amazon-secretsmanager" "autogenerated_4" { 52 key = "with_key" 53 name = "some_secret" 54 } 55 56 data "amazon-ami" "autogenerated_1" { 57 access_key = "${var.aws_access_key}" 58 filters = { 59 name = "ubuntu/images/*/ubuntu-xenial-16.04-amd64-server-*" 60 root-device-type = "ebs" 61 virtualization-type = "hvm" 62 } 63 most_recent = true 64 owners = ["099720109477"] 65 region = "${var.aws_region}" 66 secret_key = "${var.aws_secret_key}" 67 } 68 69 locals { timestamp = regex_replace(timestamp(), "[- TZ:]", "") } 70 71 local "password" { 72 sensitive = true 73 expression = "${data.amazon-secretsmanager.autogenerated_1.value}" 74 } 75 76 locals { 77 password_key = "MY_KEY_${data.amazon-secretsmanager.autogenerated_2.value}" 78 } 79 80 source "amazon-ebs" "autogenerated_1" { 81 access_key = "${var.aws_access_key}" 82 ami_description = "Ubuntu 16.04 LTS - expand root partition" 83 ami_name = "ubuntu-16-04-test-${local.timestamp}" 84 encrypt_boot = true 85 launch_block_device_mappings { 86 delete_on_termination = true 87 device_name = "/dev/sda1" 88 volume_size = 48 89 volume_type = "gp2" 90 } 91 region = "${var.aws_region}" 92 secret_key = "${var.aws_secret_key}" 93 source_ami = "${data.amazon-ami.autogenerated_1.id}" 94 spot_instance_types = ["t2.small", "t2.medium", "t2.large"] 95 spot_price = "0.0075" 96 ssh_interface = "session_manager" 97 ssh_username = "ubuntu" 98 temporary_iam_instance_profile_policy_document { 99 Statement { 100 Action = ["*"] 101 Effect = "Allow" 102 Resource = ["*"] 103 } 104 Version = "2012-10-17" 105 } 106 } 107 108 source "amazon-ebs" "named_builder" { 109 access_key = "${var.aws_access_key}" 110 ami_description = "Ubuntu 16.04 LTS - expand root partition" 111 ami_name = "ubuntu-16-04-test-${local.timestamp}" 112 encrypt_boot = true 113 launch_block_device_mappings { 114 delete_on_termination = true 115 device_name = "/dev/sda1" 116 volume_size = 48 117 volume_type = "gp2" 118 } 119 region = "${var.aws_region}" 120 secret_key = "${var.aws_secret_key}" 121 source_ami = "${data.amazon-ami.autogenerated_1.id}" 122 spot_instance_types = ["t2.small", "t2.medium", "t2.large"] 123 spot_price = "0.0075" 124 ssh_interface = "session_manager" 125 ssh_username = "ubuntu" 126 temporary_iam_instance_profile_policy_document { 127 Statement { 128 Action = ["*"] 129 Effect = "Allow" 130 Resource = ["*"] 131 } 132 Version = "2012-10-17" 133 } 134 } 135 136 build { 137 sources = ["source.amazon-ebs.autogenerated_1", "source.amazon-ebs.named_builder"] 138 139 provisioner "shell" { 140 except = ["amazon-ebs"] 141 inline = ["echo ${var.secret_account}", "echo ${build.ID}", "echo ${build.SSHPublicKey} | head -c 14", "echo ${path.root} is not ${path.cwd}", "echo ${packer.version}", "echo ${uuidv4()}"] 142 max_retries = "5" 143 } 144 145 provisioner "shell" { 146 inline = ["echo ${local.password}", "echo ${data.amazon-secretsmanager.autogenerated_1.value}", "echo ${local.password_key}", "echo ${data.amazon-secretsmanager.autogenerated_2.value}"] 147 } 148 149 provisioner "shell" { 150 inline = ["echo ${data.amazon-secretsmanager.autogenerated_3.value}", "echo ${data.amazon-secretsmanager.autogenerated_4.value}"] 151 } 152 153 154 # 1 error occurred upgrading the following block: 155 # unhandled "clean_resource_name" call: 156 # there is no way to automatically upgrade the "clean_resource_name" call. 157 # Please manually upgrade to use custom validation rules, `replace(string, substring, replacement)` or `regex_replace(string, substring, replacement)` 158 # Visit https://packer.io/docs/templates/hcl_templates/variables#custom-validation-rules , https://www.packer.io/docs/templates/hcl_templates/functions/string/replace or https://www.packer.io/docs/templates/hcl_templates/functions/string/regex_replace for more infos. 159 provisioner "shell" { 160 inline = ["echo mybuild-{{ clean_resource_name `${timestamp()}` }}"] 161 } 162 163 164 # 1 error occurred upgrading the following block: 165 # unhandled "lower" call: 166 # there is no way to automatically upgrade the "lower" call. 167 # Please manually upgrade to `lower(var.example)` 168 # Visit https://www.packer.io/docs/templates/hcl_templates/functions/string/lower for more infos. 169 provisioner "shell" { 170 inline = ["echo {{ lower `SOMETHING` }}"] 171 } 172 173 174 # 1 error occurred upgrading the following block: 175 # unhandled "upper" call: 176 # there is no way to automatically upgrade the "upper" call. 177 # Please manually upgrade to `upper(var.example)` 178 # Visit https://www.packer.io/docs/templates/hcl_templates/functions/string/upper for more infos. 179 provisioner "shell" { 180 inline = ["echo {{ upper `something` }}"] 181 } 182 183 184 # 1 error occurred upgrading the following block: 185 # unhandled "split" call: 186 # there is no way to automatically upgrade the "split" call. 187 # Please manually upgrade to `split(separator, string)` 188 # Visit https://www.packer.io/docs/templates/hcl_templates/functions/string/split for more infos. 189 provisioner "shell" { 190 inline = ["echo {{ split `some-string` `-` 0 }}"] 191 } 192 193 194 # 1 error occurred upgrading the following block: 195 # unhandled "replace_all" call: 196 # there is no way to automatically upgrade the "replace_all" call. 197 # Please manually upgrade to `replace(string, substring, replacement)` or `regex_replace(string, substring, replacement)` 198 # Visit https://www.packer.io/docs/templates/hcl_templates/functions/string/replace or https://www.packer.io/docs/templates/hcl_templates/functions/string/regex_replace for more infos. 199 provisioner "shell" { 200 inline = ["echo {{ replace_all `-` `/` `${build.name}` }}"] 201 } 202 203 204 # 1 error occurred upgrading the following block: 205 # unhandled "replace" call: 206 # there is no way to automatically upgrade the "replace" call. 207 # Please manually upgrade to `replace(string, substring, replacement)` or `regex_replace(string, substring, replacement)` 208 # Visit https://www.packer.io/docs/templates/hcl_templates/functions/string/replace or https://www.packer.io/docs/templates/hcl_templates/functions/string/regex_replace for more infos. 209 provisioner "shell" { 210 inline = ["echo {{ replace `some-string` `-` `/` 1 }}"] 211 } 212 213 provisioner "shell-local" { 214 inline = ["sleep 100000"] 215 only = ["amazon-ebs"] 216 timeout = "5s" 217 } 218 219 post-processor "amazon-import" { 220 format = "vmdk" 221 license_type = "BYOL" 222 region = "eu-west-3" 223 s3_bucket_name = "hashicorp.adrien" 224 tags = { 225 Description = "packer amazon-import ${local.timestamp}" 226 } 227 } 228 post-processors { 229 post-processor "artifice" { 230 keep_input_artifact = true 231 files = ["path/something.ova"] 232 name = "very_special_artifice_post-processor" 233 only = ["amazon-ebs"] 234 } 235 post-processor "amazon-import" { 236 except = ["amazon-ebs"] 237 license_type = "BYOL" 238 s3_bucket_name = "hashicorp.adrien" 239 tags = { 240 Description = "packer amazon-import ${local.timestamp}" 241 } 242 } 243 } 244 }