SkillSprout
Chapter 6 · Lesson 4
Advanced
7 min read

Secrets Manager, KMS, IAM at Scale and Service Catalog

Overview

Automation must be safe. This lesson covers how to keep secrets out of code (Secrets Manager, Parameter Store), how to control encryption keys (KMS), how to grant least privilege at scale (permission boundaries, ABAC, Identity Center, Access Analyzer) and how to let teams self-serve approved infrastructure (Service Catalog).

Consider a bank vault. Secrets Manager is the safe deposit system that changes the combinations regularly; KMS is the master key facility that never lets the keys leave the building; IAM is the access policy for who may enter which room; Service Catalog is the menu of pre-approved rooms staff can order without building their own.

DOP-C02 scenarios blend these: a pipeline needs database credentials that rotate, encrypted artifacts shared across accounts, developers who can create roles but only within boundaries, and standardised product launches with guardrails.

Key Concepts

  • Secrets Manager stores secrets with automatic rotation (Lambda; managed rotation for RDS/Aurora/Redshift/DocumentDB), versioning stages (AWSCURRENT, AWSPENDING), KMS encryption and resource policies; replicate to other Regions.
  • Parameter Store SecureString is cheaper but has no built-in rotation; use Secrets Manager for credentials needing rotation.
  • KMS keys: AWS managed, customer managed (CMK), AWS owned; key policy is the primary access control and must allow the account for IAM policies to work.
  • Envelope encryption: KMS encrypts a data key (GenerateDataKey) and your service encrypts data locally; direct Encrypt is limited to 4 KB.
  • Grants give temporary delegated access to a key; multi-Region keys share key material across Regions for DR and global apps; automatic rotation yearly (configurable from 90 days to 7 years).
  • Cross-account key use needs both the key policy and an IAM policy in the caller account; the AWS managed keys cannot be shared.
  • Permission boundaries cap what a role can be granted, enabling delegated IAM administration; ABAC uses tags (aws:PrincipalTag / aws:ResourceTag) to scale permissions.
  • Service Catalog portfolios and products (CloudFormation or Terraform) with launch constraints, template constraints and TagOptions let users launch approved resources without broad IAM rights.

Detailed Notes

Secrets Manager vs Parameter Store

FeatureSecrets ManagerParameter Store
Automatic rotationYes (Lambda / managed)No
Cross-Region replicationYesNo
Max size64 KB4 KB standard, 8 KB advanced
CostPer secret + API callsFree standard tier
Resource policyYesAdvanced parameters via RAM sharing
Typical useDB credentials, API keysConfig, flags, non-rotating secrets

Retrieval in a template (never store secrets in plain text):

yaml
MasterUserPassword: '{{resolve:secretsmanager:prod/orders/db:SecretString:password}}'
bash
aws secretsmanager rotate-secret --secret-id prod/orders/db \
  --rotation-lambda-arn $ROTATION_FN --rotation-rules AutomaticallyAfterDays=30
aws secretsmanager replicate-secret-to-regions --secret-id prod/orders/db \
  --add-replica-regions Region=us-west-2

Rotation steps: createSecret, setSecret, testSecret, finishSecret. Alternating users rotation keeps one credential valid during rotation, avoiding downtime for apps that cache credentials. Applications should fetch secrets at runtime and cache them with a TTL (SDK caching client).

KMS key policy

json
{
  "Version": "2012-10-17",
  "Statement": [
    { "Sid": "EnableIAMPolicies", "Effect": "Allow",
      "Principal": { "AWS": "arn:aws:iam::111122223333:root" }, "Action": "kms:*", "Resource": "*" },
    { "Sid": "AllowPipelineAccount", "Effect": "Allow",
      "Principal": { "AWS": "arn:aws:iam::999988887777:role/prod-deploy-role" },
      "Action": ["kms:Decrypt", "kms:DescribeKey", "kms:GenerateDataKey*"], "Resource": "*" }
  ]
}

Without the first statement, IAM policies cannot grant access and the key may become unmanageable. For cross-account use, the other account must also allow the actions in an IAM policy.

Key types and features

TypeControlRotationCost
AWS ownedNone, shared across accountsAWSFree
AWS managed (aws/s3)Policy is read-onlyYearly automaticFree key, pay for use
Customer managedFull policy controlOptional automatic / manualMonthly + use
External key store / imported materialOwn key materialManualHigher

Multi-Region keys have the same key ID and material in several Regions (primary and replicas), enabling encrypt in one Region and decrypt in another, useful for global tables, Aurora Global and cross-Region copies. Use encryption context conditions and CloudTrail for auditing, and key deletion requires a 7-30 day waiting period.

IAM at scale

TechniquePurpose
Permission boundaryLets developers create roles but never exceed the boundary
ABAC with tagsOne policy: allow when aws:PrincipalTag/project equals aws:ResourceTag/project
IAM Identity CenterCentral SSO with permission sets across accounts, short-lived credentials
Access AnalyzerExternal access findings, unused access findings, policy generation from CloudTrail, policy validation in pipelines
Roles for workloadsInstance profiles, task roles, IRSA / EKS Pod Identity, Lambda roles; no long-lived keys
Session policies and aws:SourceIp/VpcEndpoint conditionsNarrow runtime access
json
{
  "Effect": "Allow",
  "Action": ["ec2:StartInstances", "ec2:StopInstances"],
  "Resource": "*",
  "Condition": { "StringEquals": { "ec2:ResourceTag/team": "${aws:PrincipalTag/team}" } }
}

For CI/CD, use OIDC federation (GitHub Actions to an IAM role) rather than stored keys.

Service Catalog

ElementDescription
PortfolioCollection of products shared with accounts/OUs and granted to IAM principals
ProductCloudFormation/Terraform template with versions
Launch constraintThe role Service Catalog assumes to provision, so users need no direct permissions
Template constraintRestrict parameter values (instance types)
TagOptions / tag updateEnforce tags on launched resources
Provisioned productThe running instance of a product; supports updates and drift

Share portfolios via Organizations and import them into member accounts. This is the pattern for the "developers can launch only approved databases" requirement. Control Tower Account Factory is itself a Service Catalog product.

Putting it together

A pipeline deployment role assumes a boundary-limited role, reads credentials from Secrets Manager (rotating), writes artifacts encrypted with a shared CMK, and provisions environments through Service Catalog products whose launch roles hold the real permissions.

Real World Example

Scenario: a team needs rotating database credentials and cross-account deploys. The RDS master secret uses managed rotation every 30 days, replicated to the DR Region. Applications read the secret through the SDK with a short cache.

The pipeline artifact bucket uses a customer managed KMS key whose policy trusts the production deploy role. Developers receive a permission boundary so they can create service roles without escalating privileges, and request new databases via a Service Catalog product restricted to approved instance classes and tags.

Architecture Diagram

Secrets, keys and least-privilege access
Architecture
AWS Cloud
Workload roleboundary + ABAC
Secrets Manager30-day rotation
Customer managed keykey policy
RDSrotated credentials
Service Catalogapproved products

Workloads fetch rotating secrets; KMS protects data; IAM boundaries limit privilege.

  1. 1A workload role (limited by boundary and tags) requests a secret at runtime.
  2. 2Secrets Manager decrypts the value with the customer managed KMS key.
  3. 3A rotation Lambda periodically changes the database credential and updates the secret.
  4. 4Cross-account roles use the key through key and IAM policies.
  5. 5Teams provision approved infrastructure via Service Catalog launch roles.

Best Practices

  • ✓Fetch secrets at runtime with caching; never bake them into images, templates or code.
  • ✓Enable rotation and replicate critical secrets to DR Regions.
  • ✓Use customer managed keys where cross-account sharing, audit or custom rotation is needed.
  • ✓Apply permission boundaries and ABAC for scalable least privilege; validate policies with Access Analyzer.
  • ✓Offer Service Catalog products with launch constraints instead of broad IAM rights.

Common Interview Questions

Exam Tips

DOP-C02 focus

  • "Automatic rotation of database credentials" = Secrets Manager; Parameter Store lacks rotation.
  • Cross-account KMS = key policy + IAM policy, with a customer managed key.
  • "Delegate IAM administration without privilege escalation" = permission boundary.
  • "Self-service with guardrails" = Service Catalog (launch constraints, TagOptions).

Chapter quiz

Security and Compliance Automation · 10 questions

  1. 1.A security team wants any S3 bucket created without default encryption in any member account to be fixed automatically within minutes, and the compliance status visible centrally. Which approach is best?

  2. 2.An organisation wants to prevent anyone, including account administrators, from disabling CloudTrail or leaving approved Regions. Which control meets the requirement?

  3. 3.GuardDuty reports a finding that an EC2 instance is communicating with a known command-and-control address. The company wants to isolate the instance automatically while keeping evidence. What is the best pipeline?

  4. 4.A team needs database credentials that rotate every 30 days with no application downtime and with auditable access. Which service is most appropriate?

  5. 5.Product teams must launch approved, pre-configured infrastructure on their own but must not have permission to create the underlying resources directly. Which solution enables self-service with guardrails?

  6. 6.A company wants to guarantee that nobody in member accounts, including account root users, can disable CloudTrail or leave the organisation. Which action should be taken?

  7. 7.A Config rule detects S3 buckets without default encryption in 120 accounts. The company wants violations fixed automatically within minutes and results aggregated centrally. What is the BEST approach?

  8. 8.Security wants GuardDuty enabled for all existing and future accounts in all Regions, managed from a dedicated security account rather than the management account. What should they do?

  9. 9.A pipeline in account A encrypts artifacts with a customer managed KMS key. A deployment role in account B gets AccessDenied on kms:Decrypt even though its IAM policy allows the action. What is missing?

  10. 10.Developers should be able to launch RDS databases only with approved engine versions and instance classes, without having permissions to create RDS resources directly. Which solution fits BEST?

0 of 10 answered

Finished this lesson?

0 of 44 lessons done · 0% of the course