Security and secrets: KMS, Secrets Manager and threat detection
Encrypt with KMS, keep secrets in Secrets Manager or Parameter Store, and let GuardDuty and Security Hub watch your account.
By the end of this lesson you'll be able to
0 of 5 completeKMS protects keys, not your design
KMS is a key-management service. It does not decide who should read a database password or whether an application should have access to production. IAM policies and KMS key policies decide that.
Most AWS encryption uses envelope encryption. A service generates a data key, encrypts the data with the plaintext data key, then asks KMS to encrypt the data key with a KMS key. The plaintext data key is discarded after use. KMS protects the small key operation; the service protects the data.
AWS-managed keys are created and operated by AWS for a service, such as the key behind SSM SecureString. A customer-managed key gives you more control over policy, rotation, aliases and deletion, but also gives you more responsibility and can add cost. This lesson uses no customer-managed key.
$ aws kms describe-key \ --key-id alias/aws/ssm \ --query 'KeyMetadata.{KeyManager:KeyManager,KeyState:KeyState}'
aws kms describe-key \awsthe AWS command line
The real practice run returned KeyManager AWS and KeyState Enabled. That confirms the SSM parameter uses an AWS-managed key, not a customer-created key.
Secrets have a lifecycle
Secrets Manager is for credentials and other values that need a secret lifecycle. It stores versions, controls access with IAM, records API use in CloudTrail and can support rotation. The application should retrieve a secret at runtime using its role, not bake the value into an image or repository.
$ aws secretsmanager create-secret \ --name academy-security-demo \ --secret-string '{"username":"demo-app","token":"lesson-only"}' $ aws secretsmanager get-secret-value \ --secret-id academy-security-demo \ --query SecretString \ --output text $ aws secretsmanager delete-secret \ --secret-id academy-security-demo \ --force-delete-without-recovery
aws secretsmanager create-secret \awsthe AWS command line
Force deletion is appropriate only for disposable practice data. Production deletion normally uses a recovery window so an accidental delete can be reversed. Secret names and values are different: a name can appear in configuration, while the value must stay out of logs and shell history.
Parameters are configuration
SSM Parameter Store is a convenient hierarchy for configuration. String is readable configuration. StringList is a comma-separated list. SecureString encrypts the value and requires permission to decrypt it.
$ aws ssm put-parameter \ --name /academy/security-demo/app-name \ --type String \ --value academy-demo $ aws ssm put-parameter \ --name /academy/security-demo/api-token \ --type SecureString \ --key-id alias/aws/ssm \ --value lesson-only-token $ aws ssm get-parameters \ --names /academy/security-demo/app-name /academy/security-demo/api-token \ --with-decryption \ --query 'Parameters[].{Name:Name,Type:Type,Value:Value}'
aws ssm put-parameter \awsthe AWS command line
Use a path that reflects ownership and environment, then grant access to only that path. SecureString encrypts at rest; it does not make a value safe to print in a CI log. Delete a practice parameter when the exercise ends.
Detection is not prevention
GuardDuty analyses supported AWS account and workload signals for suspicious activity. Security Hub collects security findings and standards in one place. Neither is a replacement for least privilege, patching, backups or an incident response process.
I did not enable GuardDuty or Security Hub in this lesson. Enabling account-wide detection services was outside the approved resource list. In a real account, check the region, delegated administration and cost before enabling them, then route findings to the people who can act.
Edge controls have different jobs
AWS WAF filters HTTP requests at supported application edges. It can match rules for IPs, headers, paths or known attack patterns. AWS Shield helps protect against distributed denial-of-service attacks. WAF is an application-layer filter; Shield is a DDoS protection service. Neither is a secret store or a substitute for secure application code.
Secret storage is a lifecycle, not a string
Secrets Manager is for credentials that need versions, retrieval auditing and optional rotation. Parameter Store
is a hierarchical configuration store: use String for ordinary settings and SecureString when the value needs
encryption at rest. KMS AWS-managed aliases such as aws/secretsmanager and aws/ssm avoid creating a customer
key for a short exercise; customer-managed keys are for ownership and key-policy control that you are prepared to
operate.
$ aws secretsmanager get-secret-value --secret-id "$SECRET" --query SecretString --output text $ aws ssm get-parameters --names "$PLAIN" "$SECURE" --with-decryption \ --query 'Parameters[].{Name:Name,Type:Type,Value:Value}' --output table $ aws kms list-aliases --query 'Aliases[?starts_with(AliasName, `alias/aws/`)].AliasName' --output text
aws secretsmanager get-secret-value --secret-id "$SECRET" --query SecretString --output textawsthe AWS command line--querypick fields from the JSON response--outputoutput format
The first command reads one version; the second deliberately uses --with-decryption for the SecureString; the
third confirms that the exercise uses AWS-managed aliases. Delete the secret with
--force-delete-without-recovery, delete both parameters, and verify each identifier is gone.
Store and remove a practice secret
Create one Secrets Manager secret, one String parameter and one SecureString parameter protected by the AWS-managed SSM key. Retrieve each value, inspect the key manager, force-delete the secret without recovery, delete both parameters and verify that the values cannot be retrieved.
Secret and parameter values from real reads, KeyManager AWS, then ResourceNotFound or ParameterNotFound after cleanupReveal one safe solution
$ REGION=ap-south-1 $ PROFILE=anythinkx $ SECRET=academy-security-demo $ PLAIN=/academy/security-demo/app-name $ SECURE=/academy/security-demo/api-token $ aws secretsmanager create-secret --profile $PROFILE --region $REGION --name $SECRET --secret-string '{"username":"demo-app","token":"lesson-only"}' $ aws ssm put-parameter --profile $PROFILE --region $REGION --name $PLAIN --type String --value academy-demo $ aws ssm put-parameter --profile $PROFILE --region $REGION --name $SECURE --type SecureString --key-id alias/aws/ssm --value lesson-only-token $ aws secretsmanager get-secret-value --profile $PROFILE --region $REGION --secret-id $SECRET --query SecretString --output text $ aws ssm get-parameters --profile $PROFILE --region $REGION --names $PLAIN $SECURE --with-decryption --query 'Parameters[].{Name:Name,Type:Type,Value:Value}' $ aws kms describe-key --profile $PROFILE --region $REGION --key-id alias/aws/ssm --query 'KeyMetadata.{KeyManager:KeyManager,KeyState:KeyState}' $ aws secretsmanager delete-secret --profile $PROFILE --region $REGION --secret-id $SECRET --force-delete-without-recovery $ aws ssm delete-parameters --profile $PROFILE --region $REGION --names $PLAIN $SECURE $ aws secretsmanager get-secret-value --profile $PROFILE --region $REGION --secret-id $SECRET --query SecretString --output text $ aws ssm get-parameter --profile $PROFILE --region $REGION --name $SECURE --with-decryption --query Parameter.Value --output text
aws secretsmanager create-secret --profile $PROFILE --region $REGION --name $SECRET --secret-string '{"username":"demo-app","token":"lesson-only"}'awsthe AWS command line--regionwhich Region
aws secretsmanager get-secret-value --profile $PROFILE --region $REGION --secret-id $SECRET --query SecretString --output text--querypick fields from the JSON response--outputoutput format
The last two reads should fail after cleanup. The failures are the proof: a secret or parameter that can still be read is not deleted. Never use force deletion for a credential that another workload may still need.
Try it yourself
0 of 6 steps doneRun each task in your own account or terminal, then tick it off.
Quick check
Why should an application not put a database password in its source repository?
Official reading for this lesson
Or get every quiz answer right and it completes itself.