Certopolis

AWS Certified Solutions Architect – Professional

Secrets Manager multi-Region and cross-account access: SAP-C03

The Secrets Manager User Guide says a secret can be replicated to other Regions, and rotation on the primary propagates each new value to every replica. Reading a secret from another account needs a resource policy on the secret, an identity policy on the caller, and a KMS key that you create, because aws/secretsmanager cannot be used across accounts.

Replicating a secret to other Regions

Secrets Manager replicates the encrypted secret data and metadata, such as tags and resource policies, to the Regions you choose. The replica's ARN is the same as the primary's except for the Region. Each replica can be encrypted with a KMS key in its own Region. The target Region must be enabled first.

Rotation is configured on the primary only. Secrets Manager rotates the secret in the primary Region and the new value propagates to all replicas, so you do not manage rotation on each replica. A replica cannot be updated independently of its primary, except for its encryption key.

An application can read a secret from another Region without replication by calling the Secrets Manager endpoint in the Region where the secret is stored. AWS points to replication for Regional access, low latency and resilience, with applications reading the replica in their own Region.

Promoting a replica makes it a standalone secret. Changes to the primary no longer reach it. AWS gives two reasons to promote: disaster recovery when the primary becomes unavailable, and turning on rotation for that copy. StopReplicationToReplica is called in the replica's Region, and applications must then be updated to use the standalone secret.

Reading a secret from another account

Cross-account access must be allowed in two policies. A resource policy on the secret allows the role in the other account. An identity policy on that role allows secretsmanager:GetSecretValue on the secret and kms:Decrypt on the key. This differs from access within one account.

The key is the third part. The AWS managed key aws/secretsmanager cannot be used for cross-account access. The secret must be encrypted with a KMS key that you create, and that key's policy must allow the other account's role. Reading needs kms:Decrypt. A principal that also writes the secret value needs kms:GenerateDataKey.

AWS warns against granting secretsmanager:PutResourcePolicy in a resource policy, because it lets a principal, even one in another account, rewrite the policy. The BlockPublicPolicy parameter and IAM Access Analyzer help check what a resource policy allows.

Rotation types and RDS-managed master passwords

Secrets Manager has three forms of rotation. Managed rotation is configured and run by the service that owns the secret and uses no Lambda function. Managed external secrets rotation covers secrets held by Secrets Manager partners and also uses no Lambda function. Every other secret rotates through a Lambda function that updates both the secret and the database or service.

Amazon RDS can own the master user password. Setting ManageMasterUserPassword to true when creating or modifying a DB instance makes RDS generate the password, store it in Secrets Manager and rotate it every seven days by default. The rotation schedule can be changed.

The secret can use the default key or a customer managed key, but the key cannot be changed once RDS manages the credentials. Deleting the DB instance deletes the secret. The integration is not supported with RDS Custom or Blue/Green Deployments, and for most engines a read replica cannot be created from a source that manages its credentials this way.

Where the exam catches people

  • Believing each replica secret needs its own rotation schedule: rotation runs on the primary and the new value propagates to every replica.
  • Believing a replica can be edited or rotated separately while it is still a replica: only its encryption key can change. It must be promoted to a standalone secret first.
  • Believing an identity policy with kms:Decrypt is enough to read another account's secret: the secret needs a resource policy and a KMS key you create, because aws/secretsmanager cannot be used across accounts.
  • Believing every rotation needs a Lambda function: managed rotation and managed external secrets rotation use none.
  • Believing the KMS key of an RDS-managed master user secret can be swapped later: it cannot be changed once RDS manages the credentials.

Written from these sources

Try 3 questions on this

Pick an answer to see why each option is right or wrong.

  1. A company runs a payments application in us-east-1 on an Amazon Aurora global database, with a warm standby of the application in us-west-2. The application reads its database credentials from an AWS Secrets Manager secret in us-east-1 that rotates every 30 days. During a disaster recovery test that simulated the loss of us-east-1, the standby could not start because it could not reach the secret. The standby must read the credentials from its own Region and must always have the password that is current after each rotation. Which solution will meet these requirements with the LEAST operational overhead?

    Right. In the game that’s Renown for your Operational Excellence and Automation building.

    Not that one: B is right. In the game your Operational Excellence and Automation building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The standby reads it from the Secrets Manager endpoint in its own Region, which keeps working when us-east-1 is lost, and nothing has to be built or run to keep the copy in step.

    Written from docs.aws.amazon.com/secretsmanager/latest/userguide/replicate-secrets.html

  2. A company's shared-services account holds an AWS Secrets Manager secret encrypted with the AWS managed key aws/secretsmanager. An application in a separate workload account runs under an IAM role whose identity policy allows secretsmanager:GetSecretValue on the secret's ARN and kms:Decrypt on every KMS key in the shared-services account. Every GetSecretValue call from the application fails with an access denied error. The secret must stay in the shared-services account. Which combination of steps should a solutions architect take to resolve this issue? (Select TWO.)

    Right. In the game that’s Renown for your Operational Excellence and Automation building.

    Not that one: B,D is right. In the game your Operational Excellence and Automation building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The AWS managed key aws/secretsmanager cannot serve another account, so the secret must be re-encrypted with a customer managed key whose key policy allows that role to decrypt. Either change alone still ends in access denied.

    Written from docs.aws.amazon.com/secretsmanager/latest/userguide/auth-and-access_examples_cross.html

  3. A company is replacing the AWS CloudFormation templates that create Amazon RDS for MySQL DB instances for 20 product teams. Today a database administrator sets each master password by hand after creation and records it in a spreadsheet. The new design must meet the following requirements: • No person, template, or pipeline handles the master password at any time. • The password is rotated at least every 7 days. • Applications read the current password from AWS Secrets Manager. Which solution will meet these requirements with the LEAST operational overhead?

    Right. In the game that’s Renown for your Operational Excellence and Automation building.

    Not that one: D is right. In the game your Operational Excellence and Automation building would lose a little Renown, and this question would come back later.

    Show the full explanation and doc quotes

    The template never contains or passes a password, and applications read the secret whose ARN the instance's MasterUserSecret attribute exposes. No secret resource, rotation function or attachment has to be defined or maintained, which makes this the lowest-overhead design that meets every requirement.

    Written from docs.aws.amazon.com/AmazonRDS/latest/UserGuide/rds-secrets-manager.html

Ask for something