cloudtools / stacker

An AWS CloudFormation Stack orchestrator/manager.
http://stacker.readthedocs.io/en/stable/
BSD 2-Clause "Simplified" License
711 stars 167 forks source link

KMS lookups give values $VAL wrapped as "b'$VAL'" when using python 3 #755

Closed hauntingEcho closed 3 years ago

hauntingEcho commented 4 years ago

While attempting to encrypt a password 'hello!' per the directions here:

  1. the command given for encryption fails entirely
  2. after getting encryption working, Stacker populated incorrect values

using the suggested encryption command aws kms encrypt --key-id alias/DbConnectionKey --plaintext 'hello!' --output text --query CiphertextBlob results in:

Invalid base64: "hello!"

From there, I attempted to use aws kms encrypt --key-id alias/DbConnectionKey --plaintext fileb://<(echo -n 'hello!') --output text --query CiphertextBlob and used the result to create a secret via Stacker. In this secret, I see:

image

Does this need a different configuration than the one from the docs, or is there another way I should be doing this? I'm currently using Stacker 1.7.0 on python 3.5.3. I've also tried dropping the '!' off the end and received the same behavior with just "hello".

hauntingEcho commented 4 years ago

after uninstalling via pip3 and reinstalling via pip2, the issue only affects Python 3. For what it's worth, aws --version gives me aws-cli/2.0.0 Python/3.7.3 Linux/4.4.0-17763-Microsoft botocore/2.0.0dev4

hauntingEcho commented 3 years ago

This has been resolved with 1.7.1

baryal1299 commented 3 years ago

This has been resolved with 1.7.1

Still seeing the same issue, is this fixed for python 3?

$ aws --version aws-cli/1.16.199 Python/3.6.7 Darwin/18.7.0 botocore/1.15.39 $ stacker --version stacker 1.7.1

I went ahead and opened a pull request: https://github.com/cloudtools/stacker/pull/762

hauntingEcho commented 3 years ago

you're right, I hadn't cleaned out my python2 installation and am seeing this issue again

bmcoelho commented 3 years ago

Hi guys,

Any chance to fix this in the next release? All the secrets are now showing as b'secret'

Thanks

hauntingEcho commented 3 years ago

It looks like this should be fixed by your PR #765 , pending release ( #766 )

phobologic commented 3 years ago

I'll go ahead and get a dot release out by this weekend.

phobologic commented 3 years ago

https://github.com/cloudtools/stacker/releases/tag/1.7.2 - released, sorry for the delay!