Skip to content

Rotating secrets credential of a different account

0

I have two AWS account A and B. In the account A there's an RDS database that use PostgreSQL. In the account B there are some credentials stored in Secret Manager. I would like to have a rotation function in account B that rotate the credentials stored in account B, and connecting to the database change the DB credential that are in an RDS of the account A.

Is this possible? I found this application in the serverless repo and it seems it could be used, but the last two parameters are related with subnets and security groups. Enter image description here

How should I handle this in cross account rotation? PS: Have in mind that the VPC that contains the database (account A) and the VPC that contains the rotation function (account B) are peered.

1 Answer
0

Yes. You could set up something like this:

  1. Create a role in Account A with permissions to update the secrets in Account A
  2. create a role in account B for a lambda function to use. This role should have access to read the secret in account B, the basic lambda IAM requirements and assume-role to the role in account A
  3. update the trust policy on the role created in step 1 so it allows the role in step 2 to assume the role
  4. in account B, set up an EventBridge rule which triggers when the secret is rotated (start here)
  5. set up a target for this eventbridge rule to trigger a lambda function in Account B using the role created in step 2.
  6. the code in this lambda function should read the secrets from Account B (local account) and then assume the role in account A using STS AssumeRole. With this assumed role, you can call the Update Secret API and maintain the same values in account A as B is using

for the AssumeRole setup, this article may help

AWS

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.