AWS AMI Build Fails With Permission denied


I am very new to puppet/packer and CI/CD.

My packerfile.json looks like:

    "variables": {
    "aws_access_key": "",
    "aws_secret_key": "",
    "build_number": "",
    "version": ""
    "builders": [{
    "type": "amazon-ebs",
    "access_key": "{{user `aws_access_key`}}",
    "secret_key": "{{user `aws_secret_key`}}",
    "region": "eu-west-1",
    "source_ami_filter": {
    "filters": {
        "virtualization-type": "hvm",
        "name": "centos-base *",
        "root-device-type": "ebs"
    "owners": ["MY_AWS_ACCOUNT"],
    "most_recent": true
    "instance_type": "t2.small",
    "ssh_username": "centos",
    "ami_users" : [ "MY_AWS_ACCOUNT" ],
    "vpc_id": "MY_VPC",
    "subnet_id" : "MY_SUBNET",
    "ami_name": "AMI_NAME {{user `build_number`}}"
"provisioners": [
    "type": "file",
    "source": "service_files/",
    "destination": "/tmp/"
    "type": "puppet-masterless",
    "manifest_file": "base.pp",
    "module_paths": "./modules",
    "puppet_bin_dir": "/opt/puppetlabs/bin",
    "facter": {
        "build": "{{user `version`}}-{{user `build_number`}}.el7.centos"

And I even emptied my base.pp to look like:
Yumrepo <| |> -> Package <| |> -> Service <| |>

But my packer build (packer build -var 'build_number=X' -var 'version=X' packerfile.jso) still fails with the error:

    centos-base: No packages marked for update
==> centos-base: Uploading service_files/ => /tmp/
==> centos-base: Provisioning with Puppet...
    centos-base: Creating Puppet staging directory...
    centos-base: Creating directory: /tmp/packer-puppet-masterless
    centos-base: Uploading local modules from: ./modules
    centos-base: Creating directory: /tmp/packer-puppet-masterless/module-0
==> centos-base: Terminating the source AWS instance...
==> centos-base: Cleaning up any extra volumes...
==> centos-base: Destroying volume (vol-096kusdg434y789)...
==> centos-base: Deleting temporary security group...
==> centos-base: Deleting temporary keypair...
Build 'centos-base' errored: Error uploading modules: scp: /tmp/packer-puppet-masterless/module-0/codedeploy/.git/objects/pack/pack-77c4bbc91249292fb09b77b7e8eb9746b9ca8503.idx: Permission denied

==> Some builds didn't complete successfully and had errors:
--> centos-base: Error uploading modules: scp: /tmp/packer-puppet-masterless/module-0/codedeploy/.git/objects/pack/pack-77c4bbc91249292fb09b77b7e8eb9746b9ca8503.idx: Permission denied

==> Builds finished but no artifacts were created.

I have tried different versions of packer, different versions of puppet, and with librarian-puppet install each time to ensure all modules required get installed but the error is still happening.

Any ideas?

Thank you.

Could you check access to your source files?
In addition packer supports the -debug flag which helps to diag build environment.