Try encrypting KMS key without encryption context first #154
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
When the API key is encrypted using the AWS console, the function name is added as an encryption context. When the API key is encrypted using the AWS CLI, no encryption context is added. We need to try decrypting the API key both with and without the encryption context, because decrypting using the incorrect encryption context will cause decryption to fail.
Previously, we tried decrypting WITH the encryption context first, then fell back to encrypting WITHOUT the encryption context. This PR reverses the order and tries decrypting WITHOUT the encryption context first, falling back to encrypting WITH the encryption context.
Motivation
We want to encourage customers to encrypt their keys using the AWS CLI, without the encryption context. That way, a single encrypted key can be re-used for multiple functions. This is necessary in order to use our deployment tools (e.g. Serverless Framework plugin).
Testing Guidelines
We have unit test coverage of this functionality.
Types of Changes
Check all that apply