You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Running sops inside an GitHub self-hosted action it broke with the message below:
Group 0: FAILED
arn:aws:kms:us-east-1:888888888888:alias/my-lambda: FAILED
- | Error decrypting key: AccessDeniedException: The ciphertext
| refers to a customer master key that does not exist, does
| not exist in this region, or you are not allowed to access.
| status code: 400, request id:
| 2ec5457d-3ab5-4320-a258-31f67916a847
(fake account and lambda names)
I didn't set aws-profile when encrypting the file, aws_profile is empty ("aws_profile": "").
I'm using AssumeRoleWithWebIdentity and assuming a role called github-actions-runner-base-module-lambda-role containing the permissions to decrypt the file.
Locally, I was able to assume that role and perform encrypt and decrypt, so there's no problem with the role/permission.
Inside my github actions action I setup the configuration inside "$HOME"/.aws/config setting the profile target, such as below:
After some time investigating, I have found that the issue was that sops was using AWS_WEB_IDENTITY_TOKEN instead of the profile set AWS_PROFILE=target.
To validate it I unset the AWS_WEB_IDENTITY_TOKEN_FILE env var right before executing the the sops decrypt command:
I think it could be a good idea to considering using LoadDefaultConfig() from aws go sdk instead of creating a session. That's suggested by the AWS Go SDK documentation
The session package and associated functionality are replaced with a simplified configuration system provided by the config package. The config package is a separate Go module, and can be included in your applications dependencies by with go get.
Actual Behavior
Running sops inside an GitHub self-hosted action it broke with the message below:
(fake account and lambda names)
I didn't set
aws-profile
when encrypting the file,aws_profile
is empty ("aws_profile": ""
).I'm using
AssumeRoleWithWebIdentity
and assuming a role calledgithub-actions-runner-base-module-lambda-role
containing the permissions to decrypt the file.Locally, I was able to assume that role and perform encrypt and decrypt, so there's no problem with the role/permission.
Inside my github actions action I setup the configuration inside
"$HOME"/.aws/config
setting the profiletarget
, such as below:I logged inside the github actions pod and confirmed that the configuration was set properly.
Inside my action I run an
aws
cli command before running sops decrypt using the same profile (target
) and it works smoothly:It download the file from S3 correctly.
Right after running aws cli I run sops decrypt:
And sops command fails.
Workaround
After some time investigating, I have found that the issue was that
sops
was usingAWS_WEB_IDENTITY_TOKEN
instead of the profile setAWS_PROFILE=target
.To validate it I unset the
AWS_WEB_IDENTITY_TOKEN_FILE
env var right before executing the the sops decrypt command:And it worked like a charm 😃
Possible Solution
Currently, sops load the credentials this way: https://github.com/mozilla/sops/blob/master/kms/keysource.go#L163-L219
I think it could be a good idea to considering using
LoadDefaultConfig()
from aws go sdk instead of creating a session. That's suggested by the AWS Go SDK documentationIt would be something close to this:
Sops Version
Tested with latest version (
3.7.3 (latest)
) and still facing the same issue.References
May be related to some of the opened issues below:
The text was updated successfully, but these errors were encountered: