Skip to main content
In this lesson we cover secrets management on AWS with focus on what matters for the AWS Certified DevOps Engineer – Professional exam and real-world CI/CD patterns. At a high level, secrets management aims to avoid hardcoding sensitive data (passwords, API keys, credentials) in code, configuration, or container images. AWS offers two primary managed options:
  • AWS Secrets Manager
  • AWS Systems Manager Parameter Store (SSM Parameter Store)
Which one to choose depends on access patterns, rotation needs, integration complexity, and cost. Rotation requirements are often the decisive factor.
A presentation slide titled "Rotating Secrets in AWS Secrets Manager" that compares two options: "Managed Rotation" and "Rotation by Lambda Function." Each option is shown with an icon and brief bullet points describing AWS-managed rotation versus using an AWS Lambda function to handle secret rotation.

Key differences and considerations

Below is a concise comparison of the most important differences to help you decide which service fits your use case. Important: exam questions usually test capability differences (e.g., “automatic rotation required → Secrets Manager”), not the exact dollar amounts for pricing. For documentation, see:

Rotation specifics

  • Secrets Manager: enable rotation and provide a rotation Lambda (AWS provides templates). Rotation executes rotate → test → finish steps automatically.
  • Parameter Store: no built-in rotation. Typical pattern: use a Lambda that updates the external credential (for example, a database password) and then updates the SSM parameter (SecureString) with the new value.
A slide titled "Rotating Secrets in AWS Secrets Manager" showing icons for AWS Secrets Manager, AWS Lambda, and AWS KMS connected by bidirectional arrows. It illustrates the interaction between those services during secret rotation.

CI/CD integration patterns

CI/CD pipelines should inject secrets at build, deployment, or runtime instead of embedding them in source or image artifacts. Common integration patterns:
  • Provide pipeline steps with an execution role that has permission to read only the required secret/parameter.
  • Use Secrets Manager when rotation is needed — it integrates smoothly with pipeline builds and deployment steps.
  • Use Parameter Store for non-rotating configuration values or when you need to store many small parameters at lower cost.
Example CLI commands for retrieving secrets/parameters in a build or job step:
  • AWS Secrets Manager:
  • SSM Parameter Store (SecureString):
Minimal IAM policy allowing a CodeBuild role to retrieve one secret (example):
Always apply least privilege — grant the pipeline role only the secrets it needs.
A comparison table titled "Parameter Store vs Secrets Manager" showing features and differences between AWS Secrets Manager and Parameter Store. It lists items like automatic rotation (Secrets Manager: yes; Parameter Store: no/manual), cost, max secret size, CloudTrail audit, KMS encryption, fine‑grained access, and best‑use cases.

Security and auditing

  • Encryption: both services integrate with AWS KMS. Choose customer-managed CMKs for tighter control over key policies and key rotation.
  • Access control: use IAM policies and roles. Follow least-privilege principles for CI/CD, Lambda, ECS tasks, and EC2 instances that require secrets.
  • Auditing: enable CloudTrail and monitor access to secrets and parameters. Secrets Manager includes rotation/audit-related metadata that helps with tracing rotation events.
  • Monitoring and alerting: include secret access events in your anomaly detection and alerting rules to detect unusual access patterns.
A diagram titled "Security and Access Control" showing IAM providing permissions and a role to AWS CodeBuild, which sends requests to and receives secrets from AWS Secrets Manager.

Practical guidance and best practices

  • Never hard-code secrets in source code, container images, or static configuration files.
  • Use IAM roles with least privilege for services that access secrets (for example, grant CodeBuild permission only to the specific secret or parameter it needs).
  • Prefer Secrets Manager if you require automatic rotation or rich rotation workflows; use its managed, Lambda-based rotation when supported.
  • Use Parameter Store for non-rotating configuration values, feature flags, or when you need many small parameters at lower cost.
  • Encrypt sensitive values with KMS. Prefer customer-managed CMKs when you require custom key policies or key lifecycle control.
  • Regularly audit and monitor secret usage with CloudTrail and integrate these logs into your SIEM or alerting workflows.
  • Inject secrets at runtime (environment variables or secret mounts) for Lambda, ECS, EKS, or EC2 instead of baking them into images or artifacts.
A slide titled "Secrets Management – Best Practices" showing five tips for handling secrets. The tips: never hardcode secrets, use IAM roles with least privilege, enable automatic rotation, regularly audit secret access logs, and use environment variables securely in Lambda/ECS/EC2.
AWS exam scenarios typically test which service is appropriate for a situation (for example, “automatic rotation required” → choose Secrets Manager). Focus on differences in capabilities, limits, and integration patterns rather than memorizing exact prices.

A few exam-oriented tips

  • If the scenario requires managed, built-in rotation → Secrets Manager.
  • If the scenario involves many small configuration values, feature flags, or budget constraints where rotation isn’t required → Parameter Store.
  • Remember that both services use KMS and CloudTrail; the deciding factors are rotation, size, and cost/throughput needs.
  • For pipeline questions, expect the recommended pattern to be injecting secrets at runtime with a role scoped to the necessary resource.

Summary

  • Use AWS Secrets Manager for credentials that require automatic managed rotation and richer secret workflows.
  • Use Systems Manager Parameter Store for general configuration and non-rotating secure values when cost and simplicity are primary concerns.
  • Both services integrate with KMS, IAM, and CloudTrail for encryption, access control, and auditing.
  • In CI/CD, inject secrets securely at build/deploy/runtime using least-privilege IAM roles to avoid credential leakage.
This article includes a demo of an integrated pipeline that shows secrets being injected securely and how rotation is handled in practice. Further reading and references:

Watch Video