Secrets Manager, Parameter Store and AWS AppConfig for Developers: Secrets, Configuration and Feature Flags

AWS Developer Associate 45 min min read Updated: Nov 17, 2026 Intermediate
Secrets Manager, Parameter Store and AWS AppConfig for Developers: Secrets, Configuration and Feature Flags
Intermediate Topic 2 of 3

Never Hard-Code Secrets

Secrets in Git or images get leaked. Passwords, API keys and tokens must not live in source code, container images, AMIs or plain environment variables checked into Git. Fetch them at runtime from a secure service using an IAM role.
ServiceBest forKey features
AWS Secrets ManagerDatabase passwords, API keys, OAuth tokens that need rotationAutomatic rotation (Lambda), versioning, cross-Region replication, KMS encryption, resource policies, native RDS/Aurora/Redshift/DocumentDB rotation. Costs per secret per month + API calls
SSM Parameter StoreConfiguration values and simple secretsFree standard tier (up to 10,000 params, 4 KB each). Advanced tier (up to 8 KB, policies like expiration, more parameters, charges). String, StringList, **SecureString** (KMS). Hierarchies /app/prod/db/host. No built-in rotation
AWS AppConfigFeature flags and runtime configuration deployed safelyValidators, gradual rollout, automatic rollback on CloudWatch alarm, caching agent/extension, works with Lambda, containers, EC2

Secrets Manager

python import boto3, json sm = boto3.client("secretsmanager") sm.create_secret(Name="shop/db", SecretString=json.dumps({"username": "app", "password": "S3cret!x", "host": "db.example.internal"})) val = sm.get_secret_value(SecretId="shop/db") # returns the AWSCURRENT version creds = json.loads(val["SecretString"]) print(val["VersionId"], val["VersionStages"]) # ['AWSCURRENT']
ConceptMeaning
Version stagesAWSCURRENT (in use), AWSPREVIOUS (last one), AWSPENDING (during rotation)
RotationA rotation Lambda has four steps: createSecret, setSecret (change it in the database), testSecret, finishSecret (move AWSCURRENT). AWS supplies ready templates for RDS. Set a schedule (for example every 30 days)
ReplicationCopy a secret to other Regions for DR
Access controlIAM policy (secretsmanager:GetSecretValue), resource policy for cross-account, and kms:Decrypt if you use a customer managed key
  • Cache the secret in your function or app for a few minutes (or use the AWS Parameters and Secrets Lambda Extension) to reduce API calls, cost and latency
  • After rotation, clients with cached old passwords fail. Handle AccessDenied/authentication errors by refreshing the secret and retrying, or use the alternating-users rotation strategy
  • In ECS, inject secrets with the secrets field of the task definition
  • RDS can manage the master password in Secrets Manager for you (--manage-master-user-password)

Parameter Store

python ssm = boto3.client("ssm") ssm.put_parameter(Name="/shop/prod/db/host", Value="db.example.internal", Type="String", Overwrite=True) ssm.put_parameter(Name="/shop/prod/api/key", Value="abc123", Type="SecureString", KeyId="alias/shop-app", Overwrite=True) one = ssm.get_parameter(Name="/shop/prod/api/key", WithDecryption=True)["Parameter"]["Value"] # Get everything under a path (paginate if many) r = ssm.get_parameters_by_path(Path="/shop/prod/", Recursive=True, WithDecryption=True) config = {p["Name"].split("/")[-1]: p["Value"] for p in r["Parameters"]}
  • Use a hierarchy /app/env/component/name and give roles access to a path in IAM: arn:aws:ssm:*:*:parameter/shop/prod/*
  • SecureString uses KMS. The caller needs ssm:GetParameter and kms:Decrypt
  • Parameters keep version history and can be referenced from CloudFormation and Lambda environment variables ({{resolve:ssm:/shop/prod/db/host}}) and public AWS parameters such as the latest AMI id
  • Standard throughput is limited (default about 40 requests per second for GetParameter; higher throughput can be enabled). Cache values

Secrets Manager vs Parameter Store

Secrets ManagerParameter Store
Primary useSecrets that rotateConfiguration and simple secrets
Automatic rotationYesNo (you build it)
CostPer secret per monthFree standard tier
Max size64 KB4 KB (8 KB advanced)
Cross-account sharingResource policy supportedAdvanced parameters can be shared via RAM
Cross-Region replicationBuilt inManual
EncryptionAlways KMSOptional (SecureString)
Exam rule of thumb: 'Rotate database credentials automatically' → Secrets Manager. 'Cheapest way to store configuration or a secret' → Parameter Store. 'Roll out a feature or setting gradually with rollback' → AppConfig.

AWS AppConfig

AppConfig (part of Systems Manager) lets you change application behavior without deploying code. It validates configuration, rolls it out gradually, watches CloudWatch alarms, and rolls back automatically if they fire.

ConceptMeaning
Application, environment, configuration profileWhat app, where it runs (dev, prod), and where the data is (hosted store, S3, Parameter Store, Secrets Manager)
Feature flags profileBoolean and attribute flags, targeting rules and variants
ValidatorsJSON Schema or a Lambda check before deployment
Deployment strategyExample: AppConfig.Linear50PercentEvery30Seconds, canary, all at once, or custom (duration, growth, bake time during which alarms are watched)
MonitorsCloudWatch alarms that trigger rollback
python # Lambda: read configuration through the AppConfig Lambda extension (local HTTP cache, port 2772) import json, urllib.request def get_flags(): url = "http://localhost:2772/applications/shop/environments/prod/configurations/flags" with urllib.request.urlopen(url) as r: return json.loads(r.read()) def handler(event, context): flags = get_flags() if flags.get("new-checkout", {}).get("enabled"): return {"path": "new"} return {"path": "old"}
  • The extension or agent caches configuration and polls for updates, so you do not call the AppConfig API on each request
  • Use for feature flags, A/B limits, throttling values, allow lists and kill switches
  • Compare: changing a Lambda environment variable requires a new deployment. AppConfig changes at runtime with safety checks

IAM Example for a Lambda Role

json { "Version": "2012-10-17", "Statement": [ {"Effect": "Allow", "Action": "secretsmanager:GetSecretValue", "Resource": "arn:aws:secretsmanager:ap-south-1:111111111111:secret:shop/db-*"}, {"Effect": "Allow", "Action": ["ssm:GetParameter", "ssm:GetParametersByPath"], "Resource": "arn:aws:ssm:ap-south-1:111111111111:parameter/shop/prod/*"}, {"Effect": "Allow", "Action": "kms:Decrypt", "Resource": "arn:aws:kms:ap-south-1:111111111111:key/abcd-1234"}, {"Effect": "Allow", "Action": ["appconfig:GetLatestConfiguration", "appconfig:StartConfigurationSession"], "Resource": "*"} ] }

Secret ARNs end with a random suffix, so use shop/db-* in policies.

Practice Tasks

  1. Store a database secret and read it from Lambda with caching
  2. Enable rotation for an RDS secret and watch the version stages change
  3. Create a Parameter Store hierarchy and load all parameters by path
  4. Create an AppConfig feature flag and roll it out linearly with an alarm monitor
  5. Remove kms:Decrypt from the role and note the error you get

Conclusion

Never hard-code secrets. Use Secrets Manager for rotating credentials, Parameter Store for configuration and cheap secrets, and AppConfig for feature flags and safe runtime configuration rollouts. Grant least-privilege access with IAM (plus KMS decrypt), cache values, and handle rotation gracefully.

Quick Summary: no hard-coded secrets; service comparison; Secrets Manager; Parameter Store; compare table; AppConfig; IAM example.

Get Newsletter

Subscibe to our newsletter and we will notify you about the newest updates on Edugators