AWS Secrets Manager - Create Store and Retrieve a Secret

preview_player
Показать описание
AWS Secrets Manager helps you protect secrets needed to access your applications, services, and IT resources.
The service enables you to easily rotate, manage, and retrieve database credentials, API keys, and other secrets throughout their lifecycle.
Users and applications retrieve secrets with a call to Secrets Manager APIs, eliminating the need to hardcode sensitive information in plain text.
Secrets Manager offers secret rotation with built-in integration for Amazon RDS, Amazon Redshift, and Amazon DocumentDB. Also, the service is extensible to other types of secrets, including API keys and OAuth tokens.
In addition, Secrets Manager enables you to control access to secrets using fine-grained permissions and audit secret rotation centrally for resources in the AWS Cloud, third-party services, and on-premises.
In my this video I have explained how to use AWS Secret Manager with AWS Lambda

Prerequisite:
Extract data from an API Python , Talend

Code:

import json

# Use this code snippet in your app.
# If you need more information about configurations or implementing the sample code, visit the AWS docs:

import boto3
import base64
import requests

def get_secret():

secret_name = "***********************************************************"
region_name = "us-east-1"

# Create a Secrets Manager client
service_name='secretsmanager',
region_name=region_name
)

# In this sample we only handle the specific exceptions for the 'GetSecretValue' API.
# We rethrow the exception by default.
get_secret_value_response=""
try:
SecretId=secret_name
)
except ClientError as e:
# Secrets Manager can't decrypt the protected secret text using the provided KMS key.
# Deal with the exception here, and/or rethrow at your discretion.
raise e
# An error occurred on the server side.
# Deal with the exception here, and/or rethrow at your discretion.
raise e
# You provided an invalid value for a parameter.
# Deal with the exception here, and/or rethrow at your discretion.
raise e
# You provided a parameter value that is not valid for the current state of the resource.
# Deal with the exception here, and/or rethrow at your discretion.
raise e
# We can't find the resource that you asked for.
# Deal with the exception here, and/or rethrow at your discretion.
raise e
else:
# Decrypts secret using the associated KMS CMK.
# Depending on whether the secret is a string or binary, one of these fields will be populated.
if 'SecretString' in get_secret_value_response:
secret = get_secret_value_response['SecretString']
else:
decoded_binary_secret = base64.b64decode(get_secret_value_response['SecretBinary'])

# Your code goes here.
return get_secret_value_response

def lambda_handler(event, context):
ms=get_secret()['SecretString'];
api_key=processed['api_key']
city_name=processed['city']
temp_city=data_extracted['main']['temp']
message="The temperature of {} city : {}".format(city_name,temp_city)
print(message)

Check this playlist for more AWS Concepts & Projects in Big Data domain:
Рекомендации по теме
Комментарии
Автор

I ma glad I found you in your tube.
You are an awesome teacher. To the point and very neat. Hats Off.

anandsampathkumaran
Автор

Thank you, after searching for this on multiple sites, I finally found an easy to use guide. Will go through other videos to gain knowledge as well l.

cyberfut
Автор

Bro your knowledge and explanation is really amazing, I will pay you to learn from you. Please post more videos, please share your linkedIN if possible.

iqpvisy
Автор

how can I save a variable in secrets manager through code (not using console)?

anantdeora
Автор

Guyz I am trying to integrate the secret Manager on on premise web server…. We have jboss eap which is connecting to cloud database now I want to mask the id and password using secret manager on the on prem server… have tried multiple method online but nothing seems to work ……does anyone have document for this will by much help

ansariamin