hashicorp / hashicorp/packer-plugin-amazon

Packer failing to locate AWS SSO credential on latest installs

Open
#304 2 comments 3 reactions 0 assignees View on GitHub
bug
Dominant language
Go
Stars
91
Forks
141
Avg merge
2d 18h
Merged PRs (30d)
3

Description

#### Community Note

* Please vote on this issue by adding a 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to the original issue to help the community and maintainers prioritize this request
* Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
* If you are interested in working on this issue or have submitted a pull request, please leave a comment

When filing a bug, please include the following headings if possible. Any
example text in this template can be deleted.

#### Overview of the Issue

I just rebuilt my laptop and after installing lastest AWS SSO & Packer clients I can no longer build anything with packer due to an auth error with AWS SSO I believe.
```bash
$ AWS_PROFILE=aws-sbx packer build aws-debian.pkr.hcl
Error: Datasource.Execute failed: no valid credential sources for found.

Please see
for more information about providing credentials.

Error: SSOProviderInvalidToken: the SSO session has expired or is invalid
caused by: open /home/user/.aws/sso/cache/02bd8a1275b337996f28be7975e257b499d465a3.json: no such file or directory
```
So I checked the sso/cache folder and see two files but not the one it was looking for.
```bash
$ ls ~/.aws/sso/cache/
e80b2d2608711cbb3312db7c4727a46fbad9601a.json f30fadd49f71feb67b386cf6050180ca8776c5c7.json
```

I can run Terraform and aws cli using same format and they both as expected.
```bash
AWS_PROFILE=aws-sbx terraform apply
```
```bash
AWS_PROFILE=aws-sbx aws s3 ls
````
#### Reproduction Steps

Here are the steps I take when running auth and then packer/tf tools
```bash
$ aws sso login --profile aws-sbx
(pops up browser and I auth and return to terminal)
$ packer init .
$ packer fmt . && packer validate .
$ AWS_PROFILE=aws-sbx packer build aws-debian.pkr.hcl
```

### Packer version

Packer v1.8.4
Terraform v1.3.6 on linux_amd64
aws-cli/2.9.4 Python/3.9.11 Linux/6.0.0-5-amd64 exe/x86_64.debian prompt/off

### Simplified Packer Template
```bash
packer {
required_plugins {
amazon = {
version = ">= 1.1.1"
source = "github.com/hashicorp/amazon"
}
}
}

data "amazon-parameterstore" "debian-amd64-latest" {
name = "/aws/service/debian/release/11/latest/amd64"
with_decryption = false
}

source "amazon-ebs" "debian" {
ami_name = "debian-test-ami"
encrypt_boot = true
instance_type = "t2.micro"
region = "us-west-2"
subnet_id = "subnet-XXXXXXXXXXXXX"
source_ami = data.amazon-parameterstore.debian-amd64-latest.value
ssh_username = "admin"
temporary_security_group_source_cidrs = ["X.X.X.X/24"]
}

build {
name = "base-setup-update"
sources = [
"source.amazon-ebs.debian"
]
provisioner "shell" {
inline = [
"echo Getting Updates",
"sleep 30",
"sudo apt-get update",
"sudo apt-get upgrade -y",
"sudo apt-get dist-upgrade -y",
]
}
}

```

### Operating system and Environment details

```bash
$ uname -a
Linux workstation 6.0.0-5-amd64 hashicorp/packer#1 SMP PREEMPT_DYNAMIC Debian 6.0.10-2 (2022-12-01) x86_64 GNU/Linux
```
### Log Fragments and crash.log files

Include appropriate log fragments. If the log is longer than a few dozen lines,
please include the URL to the [gist](https://gist.github.com/) of the log or
use the [Github detailed format](https://gist.github.com/ericclemmons/b146fe5da72ca1f706b2ef72a20ac39d) instead of posting it directly in the issue.

Set the env var `PACKER_LOG=1` for maximum log detail.

https://gist.github.com/lulujrush/6d053924f90a1b3621e6a92541d490d0

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.