toowoxx / terraform-provider-packer

Terraform Provider for HashiCorp Packer
Mozilla Public License 2.0
32 stars 7 forks source link

How to pass non string variable to packer from this provider #10

Closed kholisrag closed 2 years ago

kholisrag commented 2 years ago

We have :

lets say we have noamd-clients-ami.pkr.hcl, that contains

...
variable "ami_regions" {
  type        = list(string)
  description = "A list of regions to copy the AMI to"
  default     = ["us-east-1", "eu-central-1", "ap-southeast-1"]
}

variable "ami_tags" {
  type = map(string)
  description = "Tags pass to Packer Builded's AMI"
}
...
...

source "amazon-ebs" "nomad_ami" {
  ...
  tags = var.ami_tags
}

then we have main.tf that contains :

resource "packer_image" "nomad_ami" {
  ...
  variables = {
    ...
    ami_regions      = var.ami_regions
    ami_tags           = local.tags
    ...
  }

  triggers = {
    packer_version          = data.packer_version.version.version
    files_hash              = data.packer_files.nomad_ami.files_hash
    ...
  }
}

question :

  1. did the current provider support non string hcl type in the variables ?
  2. can we have packer build logs when running with this provider ?
simaotwx commented 2 years ago

Duplicate of #7 Complex input types are not supported right now. Please use jsonencode and jsondecode as a workaround.

simaotwx commented 3 weeks ago

Implemented in 0.16.0