-
Notifications
You must be signed in to change notification settings - Fork 3.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
amazon: Packer cannot assume role with credential_source #7142
Comments
v1.3.4 As everyone else on this thread, I too encounter this issue in a pipeline, however when I invoke Packer from my workstation the assumed role and respective target account is found. Just a regular config and credentials file, nothing out of the ordinary. |
@karl-cardenas-coding Are you also using CodeBuild? |
@SwampDragons No, I'm using Gitlab and Gitlab CI |
v 1.3.4
|
@mfunger that seems unrelated and like a configuration error. Send a email to the mailing list with some more details. |
I have just run into a very similar bug. It seems, using profiles only works if the |
@mastertinner that is something unrelated, and seems to be correct according to the documentation. If it still seems wrong after reading that please open a new issue. |
All, I'm almost positive this is an underlying problem with the AWS SDK for Go. See these issues / pull requests:
I am also using GitLab CI, and I'm almost positive because using the Packer version $ packer version
Packer v1.4.2 I have the following AWS config in my CI image: ~/.aws/config
I can grab credentials for base IAM role $ curl http://169.254.169.254/latest/meta-data/iam/security-credentials/ToolingGitLabRunner | jq
{
"AccessKeyId": "<some-key>",
"Code": "Success",
"Expiration": "<some-timestamp>",
"LastUpdated": "<some-other-timestamp>",
"SecretAccessKey": "<some-secret-access-key>",
"Token": "<some-token>",
"Type": "AWS-HMAC"
} I can list S3 buckets from the command line inside of the job pod: $ aws --profile prod s3 ls
...
2019-07-12 19:55:06 some-test-bucket-4wxow5tv
... For a job pod (say, building packer templates for the $ env | grep -i aws
AWS_PROFILE=prod
AWS_SDK_LOAD_CONFIG=1 But running the Packer build doesn't work: $ packer build aws/my-template.json
amazon-ebs output will be in this color.
Build 'amazon-ebs' errored: SharedConfigAssumeRoleError: failed to load assume role for arn:aws:iam::<prod-account-id>:role/ProdGitLabRunner, source profile has no shared credentials
==> Some builds didn't complete successfully and had errors:
--> amazon-ebs: SharedConfigAssumeRoleError: failed to load assume role for arn:aws:iam::<prod-account-id>:role/ProdGitLabRunner, source profile has no shared credentials
==> Builds finished but no artifacts were created. |
Hello, I tested today with packer 1.4.3, and it works properly now.
Then packer build command is able to assume the role named |
Great to hear! Marking this issue as closed. If anyone has further issues, reach out and we can open a new issue with new details. |
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. |
I use AWS CodeBuild to launch AMI building process with Packer, in a cross-account context.
In a central account, Codebuild project is started with a specific role, then we need to make a chained assume role (short term) and let packer manage this assume-role.
But in this way, build duration is limited to ~1 hour as short term credentials can't last more than 1 hour.
Before moving to a non-cross account architecture, we want to test every possibilities provided by Packer.
One of those is using the newly integrated feature in AWS Go SDK,
credential_source
, but it does not seems to work with Packer.We execute a shell script before running packer, to configure AWS profiles.
This is how the working assume role is done, but we can't renew credentials, and bypass 1 hour limitation, even if container credentials have been renew by CodeBuild in metadata (
~/.aws/config
and~/.aws/credentials
files are created successfully after that):Here are the packer Codebuild logs when its working :
This is the not working assume role, the
~/.aws/config
file is generated successfully:Here are the packer CodeBuild logs when its not working :
I tried to remove that line and rebuild on @rickard-von-essen advice, but I still get the same error
https://github.com/hashicorp/packer/blob/3315812c2c96df0d5bee903073b87b8798d51246/builder/amazon/common/access_config.go#L75
Packer version tested 1.3.2
CodeBuild ECS Container
aws/codebuild/eb-python-2.7-amazonlinux-64:2.1.6
The text was updated successfully, but these errors were encountered: