Skip to content
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

KMSMasterKeyProvider - requested master keys are generated before setting default region. #83

Closed
dtmistry opened this issue Sep 14, 2018 · 2 comments
Assignees
Labels

Comments

@dtmistry
Copy link

When using KMSMasterKeyProvider, can a CMK key alias be used as the key_id instead of the arn?

The KMS API GenerateDataKey operation accepts alias as the key_id. But it looks like the sdk expects the key_id to be an arn. If the key_id is not an arn, the init fails with the below error -

The below fails with an exception -

kwargs = dict(
    key_ids=["alias/cmk-alias"],
    region_names=["us-east-1"],
    botocore_session=existing_session
)
aws_encryption_sdk.KMSMasterKeyProvider(**kwargs)      
UnknownRegionError: No default region found and no region determinable from key id: alias/cmk-alias

/usr/local/lib/python2.7/site-packages/aws_encryption_sdk/key_providers/kms.py:50:UnknownRegionError
@mattsb42-aws mattsb42-aws self-assigned this Sep 14, 2018
@mattsb42-aws
Copy link
Member

Thanks for reporting this!

It looks like this is caused by us finding the default region after generating the pre-defined master keys rather than before.

We'll get a fix out for this shortly, but in the meantime you can work around this by not pre-populating the key IDs.

kwargs = dict(
    region_names=["us-east-1"],
    botocore_session=existing_session
)
key_provider = aws_encryption_sdk.KMSMasterKeyProvider(**kwargs)
key_provider.add_master_key("alias/cmk-alias")

@mattsb42-aws mattsb42-aws changed the title KMSMasterKeyProvider - alias as key_id KMSMasterKeyProvider - requested master keys are generated before setting default region. Sep 14, 2018
@mattsb42-aws
Copy link
Member

This fix is now available in v1.3.7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants