# Packer build issues on credentials, validate passes

**URL:** <https://discuss.hashicorp.com/t/packer-build-issues-on-credentials-validate-passes/24817>\
**Category:** Packer\
**Created:** [May 26, 2021, 4:24pm UTC](https://discuss.hashicorp.com/t/packer-build-issues-on-credentials-validate-passes/24817 "2021-05-26T16:24:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mduttaroy.devops](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/mduttaroy.devops/32/16112_2.png) [@mduttaroy.devops](https://discuss.hashicorp.com/u/mduttaroy.devops)\
**Post date:** [May 26, 2021, 4:24pm UTC](https://discuss.hashicorp.com/t/packer-build-issues-on-credentials-validate-passes/24817/1 "2021-05-26T16:24:48Z")

</div>

Hello Packer Community -

New to Packer and following a course in Packer. Using Packer 1.7.2 on Ubun 20.10 VM.

## Trying to deploy to AWS and I am running under an user I created in AWS which is part of group Administrator and has all privileges. I am running in a vagrant box as it allows me to keep to latest toolsets. This is shown below.

## **My packer validate passes but packer build fails:**  **Error: Datasource.Execute failed: no valid credential sources for found.**  **Please see \*\* for more information about providing credentials. Error: NoCreentialProviders: no valid providers in chain. Deprecated. For verbose messaging see aws.Config.CredentialsChainVerboseErrors \*\* on template.json.pkr.hcl line 21:** (source code shown below)

I am using AWS CLI 2 and credentials file + config file are ok.  
In fact sts get caller-identitity returns fine.

## vagrant@vbUBUNiINFRA1:~ aws.sts.get-caller-identity 3304XXXX arn:aws:iam::3304XXXX:user/mono-acc.admin XXXXXXXXXXXXX vagrant@vbUBUNiINFRA1:~ aws.version aws-cli/2.2.5 Python/3.8.8 Linux/5.8.0-53-generic exe/x86\_64.ubuntu.20 prompt/off

The file I am trying to validate is as follows:  
The ssh-username (below) is the only thing I change from the example (in book) to the default user in my credentials file based on which sts caller identity runs.

Not sure is ssh-username is the issue and what the ssh-username should be?  
I tried root as well as ubuntu for the root AWS Linux AMI  
Line 21 - where error shown occurs - is bolded-italicized

## I use the same credentials and config file to run Terraform fine. Thus I am not understanding as to why a similarly configured Packer templ will not work?

variable “aws\_profile” {  
type = string  
default = “AWS PROFILE”  
}

variable “region” {  
type = string  
default = “AWS REGION”  
}

variable “instance\_type” {  
type = string  
default = “EC2 INSTANCE TYPE”  
}

variable “source\_ami” {  
type = string  
default = “AMAZON LINUX AMI ID”  
}

data “amazon-ami” “autogenerated\_1” {  
filters = {  
name = “Amazon Linux AMI-\*”  
root-device-type = “ebs”  
virtualization-type = “hvm”  
}  
most\_recent = true  
owners = [“amazon”]  
profile = “{var.aws\_profile}" region = "{var.region}”  
}

**source “amazon-ebs” “autogenerated\_1” { \<== Line 21**  
ami\_description = “Amazon Linux Image with Jenkins Server”  
ami\_name = “jenkins-master-2.204.1”  
instance\_type = “{var.instance\_type}" profile = "{var.aws\_profile}”  
region = “{var.region}" source\_ami = "{data.amazon-ami.autogenerated\_1.id}”  
**ssh\_username = “mono-acc.admin” ← tried “root” & “ubuntu” as well**  
}

build {  
sources = [“source.amazon-ebs.autogenerated\_1”]

## provisioner “shell” { execute\_command = “sudo -E -S sh ‘{{ .Path }}’” script = “./setup.sh” } }

Thanks for your help and insight.

Mono
