Arkinu
AWS service comparison

AWS KMS vs AWS Secrets Manager: differences and when to use each

AWS KMS
AWS Secrets Manager

Often confused on the examQuestions tend to offer one as a distractor for the other: look for the phrase in the scenario that tips the balance.

Security, Identity, and Compliance

AWS KMS

Managed service for creating and controlling the keys used to encrypt and sign data. The keys are protected by hardware security modules (HSMs), never leave the service unencrypted, and access to them is controlled with key policies.

Exam phrases that point here

  • «encrypt data at rest with managed keys whose usage is audited»

    AWS KMS centralizes encryption keys, integrates with most AWS services, and every use of a key is logged in AWS CloudTrail.

    When not: If the scenario requires dedicated single-tenant HSMs under the customer's exclusive control, it points to AWS CloudHSM. And if it only asks to encrypt S3 objects with no requirements for key control or auditing, default SSE-S3 encryption may be enough.

  • «control who can use the key and rotate it automatically»

    With a customer managed key in KMS, the customer defines the key policy, can turn on automatic rotation, and can disable the key or schedule its deletion.

    When not: AWS managed keys do not allow changing their policy. And if regulations require that keys be stored and used outside AWS, the answer is an external key store or CloudHSM, not a standard KMS key.

  • «encrypt large files in the application with a managed key»

    With envelope encryption, KMS returns a data key; the application encrypts the file locally with it and stores the encrypted data key alongside the file. Only the key travels to KMS, not the data.

    When not: If the data goes to an AWS service integrated with KMS (Amazon S3, Amazon EBS, Amazon RDS), it is enough to turn on its encryption with a KMS key: the service performs envelope encryption on its own.

  • «share encrypted S3 objects with another AWS account»

    Objects encrypted with SSE-KMS need permission on the key to be read. With a customer managed key, its key policy can grant access to the other account.

    When not: Objects encrypted with the S3 AWS managed key (aws/s3) cannot be shared across accounts. If the objects use SSE-S3, KMS is not involved and access depends only on the S3 policies.

  • «audit who used the encryption key and when»

    All administrative and cryptographic calls to KMS are recorded in AWS CloudTrail.

    When not: AWS owned keys, which some services use by default, do not generate CloudTrail logs and do not support policies; if you need to audit, you need a key in the customer's account.

Study AWS KMS →

Security, Identity, and Compliance

AWS Secrets Manager

Service for storing, retrieving, and rotating secrets such as database credentials, API keys, and OAuth tokens throughout their lifecycle. It helps you avoid hardcoding credentials in code: the application requests them from the service when it needs them, and rotation can be automatic.

Exam phrases that point here

  • «automatically rotate database credentials»

    Secrets Manager rotates secrets on a schedule and updates both the secret and the password in the database, with built-in support for Amazon RDS, Amazon DocumentDB, and Amazon Redshift.

    When not: If you only need to store configuration parameters or encrypted values without rotation, AWS Systems Manager Parameter Store may be enough and is simpler.

  • «remove credentials hardcoded in the application code»

    The application requests the secret from Secrets Manager at runtime, with IAM permissions, instead of carrying the password in the code or in a file.

    When not: If what the application needs is credentials to call AWS services, the answer is an IAM role with temporary credentials, not a stored secret.

  • «securely store third-party API keys»

    In addition to database credentials, Secrets Manager stores API keys, SaaS or on-premises credentials, and SSH keys, encrypted with KMS.

    When not: If what you need to store is an encryption key used to encrypt data, the service is AWS KMS (or CloudHSM), not a secret.

  • «restrict which teams can read each secret»

    IAM policies control who reads or administers each secret; for example, developers with access only to the development secrets.

    When not: If the access control being asked for is over who uses an encryption key, it is solved with the KMS key policy.

  • «rotate credentials without affecting the application»

    Rotation tests the new credential before marking it as current, and open connections are not cut because authentication only happens when connecting.

    When not: If the application caches the password or keeps it in its configuration and does not request it again, rotation will leave it with an old credential: you have to adapt the application before turning on rotation.

Often paired with

  • Amazon RDS
  • AWS Lambda
  • AWS KMS
Study AWS Secrets Manager →