Encrypt and Decrypt AWS Lambda Function Environment Variables using AWS KMS

Pubblicato il: 06 ottobre 2021
sul canale di: Knowledge Amplifier
6,189
67

Secrets are meant to be... well, secret.
We can not to expose important secure keys (like database passwords) to the outside world.
As such, hardcoding passwords inside of your source code is a terrible idea.
Luckily, with AWS Lambda we can avoid that - we're going to learn how we can use environment variables in order to pass in a password to a lambda function without potentially exposing it to the world.
Moreover using KMS , we can encrypt the environment variables & make the system more secured.

In this video , I have explained the basic concept of KMS , and how to use this to encrypt and decrypt secured credentials.


Prerequisite:
Extract data from an API Python , Talend
   • Extract data from an API Python , Talend  


Base Code:

import boto3
import requests
import json

def lambda_handler(event, context):
city_name=
api_key=
url="http://api.openweathermap.org/data/2...."+city_name+"&appid="+api_key+"&units=metric"
print("URL for API: ",url)
result=requests.get(url)
data_extracted=result.json()
temp_city=data_extracted['main']['temp']
message="The temperature of {} city : ".format(city_name)
print(message,temp_city)

Check this playlist for more AWS Projects in Big Data domain:
   • Demystifying Data Engineering with Cloud C...  


In questa pagina del sito puoi guardare il video online Encrypt and Decrypt AWS Lambda Function Environment Variables using AWS KMS della durata di ore minuti seconda in buona qualità , che l'utente ha caricato Knowledge Amplifier 06 ottobre 2021, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 6,189 volte e gli è piaciuto 67 spettatori. Buona visione!