Skip to content

Instantly share code, notes, and snippets.

@ryan-lane
Last active August 1, 2016 03:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryan-lane/f612529c451c0d4d68ea9ee221ff1df6 to your computer and use it in GitHub Desktop.
Save ryan-lane/f612529c451c0d4d68ea9ee221ff1df6 to your computer and use it in GitHub Desktop.
Token and username generation for KMS authentication
import kmsauth
generator = kmsauth.KMSTokenGenerator(
# KMS key to use for authentication to the lambda
'alias/awseipext-production-iad',
# Encryption context to use
{
# We're authenticating to this service
'to':'awseipext-production-iad',
# It's from this IAM role
'from':'myrole-production-iad',
# This token is for a service
'user_type': 'service',
# This is an association action
'action': 'associate',
'resource': '52.0.0.1',
},
# Find the KMS key in this region
'us-east-1'
)
username = generator.get_username()
token = generator.get_token()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment