Passing exported variables from gitlab to packer template

Hello and hopefully someone can help with my issue :slight_smile:
i’m using gitlab ci pipeline for packer (custom gitlab-ci.yml) which is integrated with Hashicorp vault to get required AWS credentials and assume the IAM role (with required permissions).
these creds are exported correctly, and when (before executing packer build command) command aws sts get-caller-identity is executed, it shows correct IAM role used in this step.
but when packer build command is ran with .pkr.hcl template file, it seems that these AWS credentials are not passed, and packer build fails with error:

Build ‘amazon-ebs.test-ami’ errored after 63 milliseconds 442 microseconds: error validating regions: UnauthorizedOperation: You are not authorized to perform this operation.

I’m not sure how to pass these exported variables so that packer build executes necessary steps with this assumed IAM role.
I hope i explained my problem without much confusion :slight_smile:

I would be very grateful if someone could advise where could be the issue?
Thank you in advance for your help!

Hi, I have similar problem. Did you make it work? How CICD variables can be exported to my “variables.pkr.hcl” file?