How to use AWS KMS in AWS Lambda

I just started working with AWS services, especially with AWS Lambda. Is there any way to use AWS KMS service from Lambda code (Java). I would like to use KMS to decrypt a secret secret (read from a property). My lambda code is in java. Thanks in advance.

+4
source share
2 answers

Yes, it should work fine.

I recently ported the Node.js RESTful API to Lambda and did not need to change the KMS code.

You just need to make sure that the role your Lambda function has has access rights to the key that you configure with AWS for use with encrypted / decrypted calls.

+3

Python:

with open('encrypted_pem.txt', 'r') as encrypted_pem:
    pem_file = encrypted_pem.read()

kms = boto3.client('kms', region_name=REGION)
return kms.decrypt(CiphertextBlob=b64decode(pem_file))['Plaintext']

- AWS Labs.

README , PEM, , AWS KMS CLI.

+3

Source: https://habr.com/ru/post/1607735/


All Articles