AWS Secrets Manager, AWS Systems Manager Parameter Store, and environment variables can all deliver a string to an application. That superficial similarity causes many poor design decisions. They solve different parts of the configuration lifecycle, and the right choice depends on what the value represents, who may retrieve it, how it changes, and what must happen when it is compromised.
The short version is straightforward: use temporary AWS credentials from roles wherever possible; use Secrets Manager for credentials and tokens that need a managed secret lifecycle; use Parameter Store for centrally managed configuration and selected encrypted values; and use environment variables for non-secret, deployment-coupled settings. The important work is making those boundaries explicit.
Classify the value before choosing the service
Start by placing each value in one of four classes:
- Identity that AWS can provide dynamically. An application calling AWS APIs usually should use an IAM role and temporary credentials, not a stored access key.
- A secret. Database credentials, third-party API tokens, OAuth client secrets, signing material, and similar values can grant authority if disclosed.
- Sensitive configuration. A license key, internal identifier, private endpoint, or other value may require restricted access even if it has no automatic rotation mechanism.
- Ordinary configuration. A feature flag name, log level, table name, region, timeout, or public endpoint usually is not a secret, although changing it can still affect availability.
Do not decide based only on whether a value is encrypted at rest. Encryption protects stored bytes. Secret management also requires authorization, auditing, rotation, version handling, safe retrieval, incident response, and a plan for consumers to adopt a replacement.
Comparison at a glance
| Decision factor | Secrets Manager | Parameter Store | Environment variables |
|---|---|---|---|
| Best fit | Credentials, keys, and tokens with a managed lifecycle | Central configuration and selected encrypted values | Small, non-secret settings tied to a deployment |
| Rotation | Built-in lifecycle support, including managed or Lambda-based rotation for supported patterns | No equivalent automatic credential rotation workflow | Requires a configuration update and usually a new deployment or version |
| Encryption | Encrypted with AWS KMS | SecureString values use AWS KMS |
Lambda encrypts environment variables at rest with AWS KMS |
| Runtime access | API call authorized by IAM and, where applicable, KMS and resource policy | API call authorized by IAM and KMS for decryption | Available to the process from its deployed configuration |
| Change independence | Can change independently of application code | Can change independently of application code | Commonly coupled to deployment configuration |
| Pricing model | Charged by stored secret and API usage | Standard parameters have no additional Parameter Store charge; advanced parameters and higher throughput can add charges | No separate store charge, but deployment and operational costs still exist |
This is a decision aid, not a substitute for reviewing current quotas, regional availability, and pricing. Application Config, deployment services, and third-party secret platforms may also be appropriate, but they are outside this three-way comparison.
When Secrets Manager is the right default
Secrets Manager is purpose-built for values that grant access. It stores versions, uses staging labels such as the current and pending versions, integrates with IAM and AWS KMS, records API activity through AWS logging services, and supports rotation workflows.
Use it when one or more of these conditions apply:
- the value is a database password, API credential, token, or other authentication material;
- automatic or scheduled rotation is required;
- the secret contains several related fields, such as a username, password, host, port, and database name;
- consumers need controlled access across accounts or Regions;
- secret-specific audit and lifecycle controls justify the additional cost; or
- an incident response plan must replace a value without rebuilding application code.
Rotation is not magic. For many secret types, Secrets Manager calls a Lambda function through four stages: create a pending secret, apply it to the target, test it, and mark it current. The rotation function is a privileged component with access to both the stored value and the target service. Give it only the permissions and network path it needs, verify that the pending and current values refer to the same intended resource, and make each step safe to retry.
Consumers must also be rotation-aware. A long-lived process that reads a secret only at startup can continue using an old credential after rotation. Define a cache lifetime, refresh on authentication failure, and prevent a burst of simultaneous retrieval calls. AWS provides extension and library patterns for caching secrets in Lambda; whichever mechanism you choose, measure its behavior during rotation and service errors.
Where Parameter Store fits
Parameter Store is a hierarchical configuration store within AWS Systems Manager. It supports String, StringList, and SecureString values. That makes it a strong fit for centrally managed application settings such as:
/example/prod/payments/timeout-seconds;/example/prod/payments/api-base-url;/example/prod/payments/log-level; and- selected sensitive values that do not need a Secrets Manager rotation workflow.
The path hierarchy is useful for organization and authorization, but it needs careful policy review. AWS warns that a principal allowed to call GetParametersByPath on a parent path can recursively retrieve descendants even if one descendant has an explicit IAM denial in a different policy arrangement. Test the effective access paths; do not assume that a neat naming tree automatically creates isolation.
Use SecureString when the value needs additional KMS-backed protection. Only the parameter value is encrypted; the name, description, and other metadata are not. Do not put customer information, credentials, or sensitive context in parameter names or tags. For fine-grained decryption control, a customer-managed KMS key can be more appropriate than the default AWS managed key, but it introduces key-policy and lifecycle responsibilities.
Parameter tiers affect limits and cost. AWS documents a standard tier for most smaller, lower-scale configuration and an advanced tier for larger values, greater counts, cross-account sharing, or parameter policies. Do not let automatic tier selection create a surprise: capture the intended tier in infrastructure code and monitor API volume for workloads that fetch on every request.
Environment variables are configuration delivery, not a secret lifecycle
Environment variables are simple and valuable. In Lambda they are version-specific configuration, easy for the function to read, and encrypted at rest with an AWS KMS key. AWS currently limits the combined size of Lambda environment variables to 4 KB.
Those properties do not make environment variables equivalent to a secret manager. A value is copied into the function configuration, available to the process, visible to principals with relevant configuration access, and commonly propagated through deployment templates, CI settings, or diagnostic tooling. Replacing it requires updating configuration and publishing or deploying the intended version. That is acceptable for a table name or feature mode. It is a fragile lifecycle for a database password.
A sound Lambda split often looks like this:
- environment variable:
APP_ENV=prod; - environment variable:
ORDERS_TABLE=orders-prod; - environment variable:
PAYMENTS_SECRET_ID=/example/prod/payments/provider; - runtime retrieval: the secret value from Secrets Manager under the function’s execution role.
The identifier is configuration; the credential remains in the secret store. The example intentionally contains no real account number, ARN, key, endpoint, or credential.
IAM and KMS answer different questions
Successful encryption does not guarantee correct authorization. Retrieval commonly involves at least two decisions:
- May this principal retrieve this secret or parameter through the service API?
- May this principal use the relevant KMS key to decrypt it?
Scope both decisions to the application, environment, and values required. Avoid wildcard read access across every production secret. Separate deployment permissions, which may create or update values, from runtime permissions, which should usually retrieve only named values. A function that reads one payment provider token should not be able to list or update every secret in the account.
Cross-account designs add resource policies, key policies, role trust, and network considerations. Document the whole path and test both expected access and expected denial. A policy review that confirms only the happy path can miss an alternate API, parent path, old role, or broad KMS permission.
Retrieval design affects reliability
Moving a credential out of an environment variable does not finish the design. The application now depends on a remote control-plane call. Decide:
- whether retrieval happens at initialization, per request, or through a local cache;
- how long a cached value remains valid;
- how the process adopts a new version during rotation;
- what happens when the service or KMS call is throttled or unavailable;
- whether a stale value is safer than failing closed for this specific operation; and
- which metrics and logs reveal retrieval failures without revealing the value.
For many Lambda workloads, retrieve once per execution environment and cache for a bounded period. This avoids an API call on every invocation while allowing eventual refresh. Do not write the retrieved value to logs, exception messages, traces, metrics, or responses. Log the secret identifier only if the identifier itself is not sensitive, plus a stable failure category and request correlation ID.
CI/CD and local development need separate identities
A production secret should not pass through a developer laptop simply because the application uses it. Give each environment distinct values and permissions. A developer should normally receive a local or sandbox credential with limited scope, not permission to retrieve production secrets.
In delivery pipelines:
- store a reference to the secret rather than the secret in the repository;
- use the CI platform’s identity federation or short-lived role credentials instead of a long-lived AWS access key;
- prevent secret values from appearing in command output, test reports, build artifacts, caches, or infrastructure plan files;
- limit the deployment role’s ability to read a value when it only needs to attach the secret identifier to a workload; and
- scan commits and artifacts, but treat scanning as a detection layer rather than permission to commit secrets temporarily.
A local .env file can be convenient for non-production development, but exclude it from version control, populate it with sandbox-only values, and document how a developer revokes them. An example file should contain placeholders such as PAYMENTS_TOKEN=replace-with-sandbox-token, never a usable credential.
Common mistakes
- Storing long-lived AWS access keys. Prefer an IAM role and temporary credentials for AWS workloads.
- Calling every configuration value a secret. This raises cost and operational friction without improving protection. Classify first.
- Using Parameter Store
Stringfor a credential. If Parameter Store is selected for sensitive data, useSecureStringand review KMS access. - Assuming encrypted environment variables are invisible. Principals and processes with the right access can still retrieve plaintext. Encryption at rest is one layer.
- Rotating the stored value but not the target. A database password changes only when both the secret store and database converge on the new credential.
- Retrieving on every request. This can add latency, cost, and a new throttling failure mode. Cache deliberately.
- Logging a response object during debugging. SDK responses can contain the secret value. Log outcome metadata, not payloads.
- Reusing one secret across development and production. Environment isolation should include identities and values, not only names.
A practical decision sequence
- Can an IAM role remove the stored credential? If yes, do that first.
- Does the value grant access? If yes, start with Secrets Manager.
- Does it require automated rotation, secret versions, or secret-specific cross-account controls? Stay with Secrets Manager.
- Is it centrally managed configuration or a short encrypted value without a rotation workflow? Evaluate Parameter Store and the correct tier.
- Is it small, non-secret, and naturally tied to the deployed version? An environment variable is likely sufficient.
- How will the consumer retrieve, cache, refresh, fail, and report? Complete that design before deployment.
This decision belongs within a broader Cloud Security and Governance model, including account boundaries, key ownership, audit retention, and incident response. Application teams planning the runtime integration can connect it to Cloud Strategy and Architecture, while ongoing access reviews and rotation monitoring fit within Managed Cloud Operations.
The best secret is one the application does not need to store. For every remaining value, choose the mechanism that supports its complete lifecycle—not merely the one that makes the string easiest to load. To review an AWS configuration and secret-management design, contact Bluegrass Cloud.
Sources
- AWS Secrets Manager: What is AWS Secrets Manager?
- AWS Secrets Manager: Lambda rotation functions
- AWS Systems Manager: Parameter Store reference
- AWS Lambda: Working with environment variables
- AWS Lambda: Securing environment variables
- AWS Prescriptive Guidance: Use ephemeral secrets or a secrets-management service
- AWS Secrets Manager pricing
- AWS Systems Manager pricing
