Encrypt and Decrypt AWS Lambda Function Environment Variables using AWS KMS

Publié le: 06 octobre 2021
sur la chaîne: 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...  


Sur cette page du site, vous pouvez voir la vidéo en ligne Encrypt and Decrypt AWS Lambda Function Environment Variables using AWS KMS durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Knowledge Amplifier 06 octobre 2021, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 6,189 fois et il a aimé 67 téléspectateurs. Bon visionnage!