Thursday, October 23, 2025

AWS Secrets Manager - Multi-Region Secrets | Deep Dive & Hands-On.


A deep dive into AWS Secrets Manager Multi-Region Secrets.

Breakdown:

  •        Overview,
  •        Core Concept,
  •        Architecture,
  •        Synchronization Model,
  •        API & CLI Examples,
  •       Multi-Region Rotation Design,
  •        Use Cases,
  •        KMS Integration,
  •        CloudFormation sample (Multi-Region Setup),
  •        Limitations & Gotchas,
  •        Best Practices,
  •        Sample DR Flow.

 Overview

·       Multi-Region Secrets in AWS Secrets Manager (released in 2022) let twtech replicate secrets across AWS Regions automatically — keeping Secrets secure, consistent, and highly available for global applications.

·     NB:

  Instead of manually replicating secrets or building Lambda sync mechanisms, Secrets Manager handles this natively.

 Core Concept

A multi-Region secret has:

  • Primary secret – the authoritative version (source of truth).
  • Replica secrets – synchronized copies in other Regions.

All metadata, secret values, versions, and rotation configuration are replicated automatically by AWS Secrets Manager.

twtech creates or promotes one primary, then replicate it to one or more Regions.

 Architecture

 Primary Region

  • Secret is created normally (includes encryption with a regional KMS CMK).
  • Designated as the primary.

 Replication Process

  • twtech calls replicate-secret-to-regions (AWS CLI) or configure via console/CloudFormation.
  • Secrets Manager:
    • Creates replicas in target Regions.
    • Creates new KMS keys or uses existing ones in each Region.
    • Synchronizes secret data and metadata.
  • Replication occurs asynchronously, but typically completes in seconds.

 Replica Regions

  • Each replica:
    • Is read-only.
    • Maintains its own ARN and KMS key.
    • Can be promoted to primary if needed (disaster recovery scenario).

 Synchronization Model

Component

Behavior

Notes

Secret value

Automatically synchronized whenever primary updates

Encryption happens per-region via each region’s CMK

Metadata (tags, description)

Synchronized

Not all metadata (like replication status) is mirrored

Rotation configuration

Synchronized

Rotation runs only in primary region

Versions

Propagated

Each region maintains its version chain

Deletion

Cascade deletion or isolated deletion

Controlled via delete replication setting

 API & CLI Examples

# Create Primary Secret

aws secretsmanager create-secret --name twtechGlobalDBSecret  --secret-string '{"username":"twtechadmin","password":"twtechSuperSecret@123"}' --kms-key-id arn:aws:kms:us-east-2:accountID:key/twtechkmskey-abcd1234

# Replicate to Other Regions

aws secretsmanager replicate-secret-to-regions  --secret-id arn:aws:secretsmanager:us-east-2:accountID:secret:twtechGlobalDBSecret-abc123 --add-replica-regions Region=us-west-1,KmsKeyId=arn:aws:kms:us-west-1:accoundID:key/twtechkmskey-wxyz9876

# View Replication Status

aws secretsmanager describe-secret --secret-id twtechGlobalDBSecret

# Promote a Replica to Primary (Useful in DR/failover scenario)

aws secretsmanager promote-replica-secret-to-primary --secret-id arn:aws:secretsmanager:us-west-1:accountID:secret:twtechGlobalDBSecret-xyz456

 Multi-Region Rotation Design

  • Rotation only runs in the primary region.
  • When the secret rotates:
    • New value is written in the primary.
    • Replicas are updated automatically with the new value.
  • This avoids duplication of rotation logic across Regions.

If the primary Region is unavailable, twtech can:

  1. Promote a replica to primary.
  2. Re-enable rotation there.

 Use Cases

Use Case

Description

Global high availability apps

Multi-Region applications (e.g., Route 53 health-checked failover) can access secrets locally for lower latency.

DR/failover setups

If primary region fails, replicas provide continuity — simply promote one to primary.

Latency-sensitive services

Microservices deployed across multiple AWS regions retrieve secrets locally, reducing inter-region calls.

Compliance-driven regional data access

Secrets can be encrypted with regional KMS keys to satisfy data residency requirements.

 KMS Integration

Each Region must have a unique KMS key (customer-managed or AWS-managed).

Best practice:

  • Use customer-managed CMKs with identical key policies.
  • Enable automatic key rotation for KMS.
  • Allow cross-region and Secrets Manager service principal permissions, e.g.:

# json

{

  "Sid": "twtechAllowSecretsManagerUse",

  "Effect": "Allow",

  "Principal": { "Service": "secretsmanager.amazonaws.com" },

  "Action": [

    "kms:Encrypt",

    "kms:Decrypt",

    "kms:GenerateDataKey*"

  ],

  "Resource": "*"

}

CloudFormation Sample (Multi-Region Setup)

# yaml

Resources:

  PrimarySecret:

    Type: AWS::SecretsManager::Secret

    Properties:

      Name: twtechGlobalSecret

      Description: twtech Global database credentials

      KmsKeyId: !Ref PrimaryKMSKey

      SecretString: '{"username":"twtechadmin","password":"twtechSuperSecret@123"}'

  PrimaryKMSKey:

    Type: AWS::KMS::Key

    Properties:

      Description: twtech KMS key for primary secret

      EnableKeyRotation: true

  ReplicaSecretWest:

    Type: AWS::SecretsManager::ReplicaRegion

    Properties:

      Region: us-west-1

      KmsKeyId: arn:aws:kms:us-west-1:accountID:key/twtechkmskey-wxyz9876

NB:

CloudFormation supports replica configuration within the primary secret’s resource definition (ReplicaRegions property).

 Limitations & Gotchas

Limitation

Explanation

Write access only in primary

Replicas are read-only until promoted.

Rotation limited to primary

Automatic rotation doesn’t run in replicas.

Replication lag

Usually seconds, but asynchronous. Not for millisecond RPO.

Cross-account not supported directly

Multi-region only (not multi-account). Use Resource Policies + KMS grants for multi-account access.

Pricing

Each replica incurs the same monthly fee as a normal secret.

 Best Practices

  •   Use multi-region replication for critical global workloads.
      Combine with Route 53 failover or AWS Global Accelerator for DR.
  •   Combine with Route 53 failover or AWS Global Accelerator for DR.
  •   Always encrypt with CMKs (not AWS-managed keys) for compliance and control.
  •   Monitor replication using CloudWatch metrics: SuccessfulReplication, FailedReplication.
  •   Automate failover promotion with Lambda/Step Functions.
  •   Tag secrets with replication metadata (Environment, RegionRole, etc.).

 Sample DR Flow

  1. us-east-2 hosts primary secret.
  2. us-west-1 hosts replica.
  3. RDS & ECS apps read from local Region.
  4. If us-east-2 fails:
    • Promote us-west-1 replica to primary.
    • Restore rotation Lambda there.
    • Update DNS/Route53 to direct app traffic westward.

Project: Hands-on

How twtech uses aws Scerets manager (ASM)  to store Secrets in its environment.

Search for service: Secrets Manager


How it works: https://aws.amazon.com/secrets-manager/


Benefits and features:

Related services

How twtech stores secretes in ASM: twtechSSHSecret


Choose secret type

Configure secret

Replicate secret - optional

  • twtech Creates read-only replicas of its secret in other Regions. 

NB:

  • Replica secrets incur a charge.

Configure rotation - optional

Review




No comments:

Post a Comment

Amazon EventBridge | Overview.

Amazon EventBridge - Overview. Scope: Intro, Core Concepts, Key Benefits, Link to official documentation, Insights. Intro: Amazon EventBridg...