Getting this Packer Errors when assigning variable values in source block

I have written below packer configuration file to create custom Image on OCI but I am getting error while assigning values using variables.

source “oracle-oci” “example” {
availability_domain = var.availability_domain
base_image_ocid = var.base_image_ocid
compartment_ocid = var.compartment_ocid
image_name = var.image_name
shape = var.shape
ssh_username = var.sshusername
subnet_ocid = var.subnet_ocid
fingerprint = var.fingerprint
region = var.region
}

build {
sources = [“source.oracle-oci.example”]

provisioner “shell” {
inline = [“echo Configuration is going to Start”,
“sudo yum install bind-utils”
]
}
}

Delcared variables in the file variables.pkr.hcl as given below

variable “user_ocid”{
type = string
}

variable “tenancy_ocid”{
type = string
}

variable “fingerprint”{
type = string
}

variable “ssh_key_file”{
type = string
}

variable “availability_domain”{
type = string
}

variable “region”{
type = string
}

variable “base_image_ocid”{
type = string
}

variable “compartment_ocid”{
type = string
}

variable “image_name”{
type = string
}

variable “compute_shape”{
type = string
}

variable “ssh_username”{
type = string
}

variable “type” {
type = string
}

variable “subnet_ocid”{
type = string
}

and assigned values to these declared variables in variables.auto.pkrvars.hcl

user_ocid = “ocid1.user.oc1…aaaaaaaahgdvdcubdpkspue5yeqqh7jyjzcuxafgmtgnwbtphbta6xngx2lq”
tenancy_ocid = “ocid1.tenancy.oc1…aaaaaaaafma2ir7od5xml2zavd5pajbhxjvg52inpmfssx7mefpbjsdfvilq”
fingerprint = “f3:32::81:06”
ssh_key_file = “./ssh-key-2021-03-04.key”
availability_domain = “fGpl:US-ASHBURN-AD-1”
region = “us-ashburn-1”
base_image_ocid = “ocid1.image.oc1.iad.ascphledptjobv2pgprzvsvdttho3a”
compartment_ocid = “ocid1.compartment.oc1…aaaaaaaavi56cmc642qvqfs45lkga”
image_name = “OCI_Packer_Image”
compute_shape = “VM.Standard2.1”
ssh_username = “opc”
type = “oracle-oci”
subnet_ocid = “ocid1.subnet.oc1.iad.aaaaaaawsc6zvaswtwq4dsmilsx67d6q”

when I run packer validate or packer build I am getting the below error for every attribute value is set in source block with variable value.

PS C:\Users\Anandkumar\OneDrive - Personal\Hashicorp Examples\Packer> packer validate .\build.pkr.hcl
Error: Unsupported attribute

on .\build.pkr.hcl line 10:
(source code not available)

This object does not have an attribute named “fingerprint”.

Error: Unsupported attribute

on .\build.pkr.hcl line 8:
(source code not available)

This object does not have an attribute named “subnet_ocid”.

Error: Unsupported attribute

on .\build.pkr.hcl line 5:
(source code not available)

This object does not have an attribute named “image_name”.

Error: Unsupported attribute

on .\build.pkr.hcl line 7:
(source code not available)

This object does not have an attribute named “ssh_username”.

Error: Unsupported attribute

on .\build.pkr.hcl line 4:
(source code not available)

This object does not have an attribute named “compartment_ocid”.

Error: Unsupported attribute

on .\build.pkr.hcl line 6:
(source code not available)

This object does not have an attribute named “shape”.
Error: Unsupported attribute

on .\build.pkr.hcl line 11:
(source code not available)

This object does not have an attribute named “region”.

Error: Unsupported attribute

on .\build.pkr.hcl line 2:
(source code not available)

This object does not have an attribute named “availability_domain”.

Error: Unsupported attribute

on .\build.pkr.hcl line 3:
(source code not available)

This object does not have an attribute named “base_image_ocid”.

PS C:\Users\Anandkumar\OneDrive - Personal\Hashicorp Examples\Packer>

Did you ever get this resolved? I am expericing the same issue.

Environment:
Packer 1.7.5
Ubuntu 20.04

config.pkr.hcl:

packer {
    required_version = ">=1.7.5"

    required_plugins {
        vsphere = {
          version = ">= 0.0.1"
          source = "github.com/hashicorp/vsphere"
        }
    }
}

Hi thanks for reaching out. it looks like you are defining the variables and values in separate HCL files, but executing Packer against a single file namely build.pkr.hcl. So Packer does not know about the other files.

Have you tried running packer on the directory of files packer validate . ?

By default when you execute Packer against a single hcl file no other file except the one being passed in will get evaluated. Since you have variables in a separate file, and a separate file for the values you must run Packer against the directory so that all files get evaluated at runtime.

@nywilken
Thanks. Pure newbie mistake.