Packer: Packer hangs when no credentials are provided, or when environment credentials are incomplete.

Created on 24 Oct 2018  ·  4Comments  ·  Source: hashicorp/packer

The error occurs during region validation. We never return from

https://github.com/hashicorp/packer/blob/master/builder/amazon/common/access_config.go#L86

I can reproduce by picking any basic packer template which doesn't have a region set in it, and unsetting my AWS_ACCESS_KEY_ID from my environment.

I can't seem to reproduce the conditions that cause this outside of Packer.

package main

import (
    "fmt"

    "github.com/aws/aws-sdk-go/aws"
    "github.com/aws/aws-sdk-go/aws/session"
)

func main() {
    config := aws.NewConfig().WithCredentialsChainVerboseErrors(true)
    fmt.Printf("config is %#v\n\n", config)

    opts := session.Options{
        SharedConfigState: session.SharedConfigEnable,
        Config:            *config,
    }

    sess, err := session.NewSessionWithOptions(opts)
    if err != nil {
        fmt.Println(err)
    }

    cp, err := sess.Config.Credentials.Get()

    fmt.Println("I successfully reach this line.")
    fmt.Printf("cp is %#v", cp)
}

works fine...

bug buildeamazon

Most helpful comment

Yeay congrats finding this bug!
I was going made using the packer docker image to validate my templates.
I couldn't find out why nothing happened at all.
Nothing on cli output, even logs gave me no information.

For people using the hashicorp/packer docker image and AWS provider, you should use it with: docker run -i --rm -v $(pwd):/templates -v $HOME/.aws:/root/.aws -w /templates hashicorp/packer:light validate /templates/aws_ami_custom.json

All 4 comments

I have a fix in #6931 ! Yay ! 🙂

Yeay congrats finding this bug!
I was going made using the packer docker image to validate my templates.
I couldn't find out why nothing happened at all.
Nothing on cli output, even logs gave me no information.

For people using the hashicorp/packer docker image and AWS provider, you should use it with: docker run -i --rm -v $(pwd):/templates -v $HOME/.aws:/root/.aws -w /templates hashicorp/packer:light validate /templates/aws_ami_custom.json

I just made a pr to aws for this https://github.com/aws/aws-sdk-go/pull/2298

This should totally fix this issue.

I'm going to lock this issue because it has been closed for _30 days_ ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tleyden picture tleyden  ·  3Comments

s4mur4i picture s4mur4i  ·  3Comments

frezbo picture frezbo  ·  3Comments

mwhooker picture mwhooker  ·  3Comments

sourav82 picture sourav82  ·  3Comments