Packer build stuck with amazon-ebs: After this operation, 239 MB of additional disk space will be used

I am new to packer… Here, the packer template json file that i have been using… somehow my packer build get stuck with amazon-ebs: After this operation, 239 MB of additional disk space will be used…
this is happening all the time… if just run update & docker install i didn’ see this issue…
Can you please someone give me an advise?

“variables”: {
“aws_access_key”: “”,
“aws_secret_key”: “”,
“ami_name”: “”,
“ssh_username”: “”,
“vpc_id”: “”,
“subnet_id”: “”
“builders”: [
“type”: “amazon-ebs”,
“access_key”: “{{user aws_access_key}}”,
“secret_key”: “{{user aws_secret_key}}”,
“region”: “us-west-2”,
“source_ami_filter”: {
“filters”: {
“virtualization-type”: “hvm”,
“name”: “ubuntu/images/hvm-ssd/ubuntu-bionic-18.04-amd64-server-*”,
“root-device-type”: “ebs”
“owners”: [“099720109477”],
“most_recent”: true
“instance_type”: “t2.micro”,
“ssh_username”: “{{user ssh_username}}”,
“ssh_timeout”: “20m”,
“ami_name”: “{{user ami_name}}”,
“ssh_pty”: “true”,
“vpc_id”: “{{user vpc_id}}”,
“subnet_id”: “{{user subnet_id}}”,

  "tags": {
    "Name": "App Name",
    "BuiltBy": "Packer"

“description”: “AWS image”,
“provisioners”: [
“type”: “shell”,
“inline”: [
“sudo apt update -y”,
“sudo apt install -y git”,
“sudo apt install -y”,
“sudo apt install python-pip”,
“pip install awscli”

At sudo apt install python-pip there is missing a -y for assume yes. Maybe that’s the case.

For the pip command you could use yes | pip install awscli. If that’s the problem.

Hi there. I notice you are missing backticks in your variable calls. They should read

 “access_key”: “{{user `aws_access_key`}}”,
 “secret_key”: “{{user `aws_secret_key`}}”


oh…my script has backticks… somehow those are not copied… when i pasted

Thanks again… Nvm… This is resolved… somehow i had to use sleep 10 before i do apt update… I was able to install appropriate packages…

Here, if you don’t mind i am asking another question. I am just wondering how to do aws configure through packer so that i can run appropriate commands like aws s3 cp etc.

currently i am getting amazon-ebs: fatal error: Unable to locate credentials.

This is what i have been doing… Any advise would be really helpful… thanks


    "variables": {

        "aws_access_key": "",

        "aws_secret_key": "",

        "ami_name": "",

        "ssh_username": "",

        "vpc_id": "",

        "subnet_id": ""


    "builders": [


            "type": "amazon-ebs",

            "access_key": "{{user `aws_access_key`}}",

            "secret_key": "{{user `aws_secret_key`}}",

Hi there - the clue is in the error message. “Unable to locate credentials”

The user variables you are providing are blank i.e. “”. You either need to provide them in the variables stanza or else use an external file to provide them. In my case I am running Packer through Gitlab so I am able to use environment variables set by Gitlab to populate these on the fly.

Can I suggest you do some research into how to use an external file to provide variable data.

Ian Carson