Baba
Baba

Reputation: 2209

How to move secrets from Amazon DynamoDB to AWS Secrets Manager

I am new to AWS and I have some secrets(ClientID and ClientSecrets) stored in dynamodb which I need to move to AWS secrets manager. What is the best way to do this? Automation is a preferred way.

Upvotes: -2

Views: 328

Answers (1)

smac2020
smac2020

Reputation: 10704

You can write custom logic using the AWS SDK. You need to create 2 Service clients in the supported SDK you want to use. For example, you can implement this in Python, .NET, Java, and so on.

  1. DynamoDB Service Client.
  2. Secrets Manager Service Client.

Now query the secrets you want to retrieve from DynamoDB by invoking the DynamoDB Service Client's query(). As you are using Python, you can use: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/dynamodb.html.

Once you get your result set, use the data to create secrets by invoking the Secrets Manager Service Client's createSecret(). You can use: https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/secretsmanager.html

To automate this, wrap this logic in an AWS Lambda function and then schedule it using a cron expression or Amazon EventBridge. For details, see:

Schedule AWS Lambda functions using EventBridge

Upvotes: 1

Related Questions