AWS Secrets Manager
User Guide

Monitor the Use of Your AWS Secrets Manager Secrets

As a best practice, you should monitor your secrets to ensure that usage of your secrets and any changes to them are logged. This helps you to ensure that any unexpected usage or change can be investigated and unwanted changes can be rolled back. AWS Secrets Manager currently supports two AWS services that enable you to monitor your organization and the activity that happens within it.

AWS CloudTrail

AWS Secrets Manager is integrated with AWS CloudTrail, a service that captures AWS Secrets Manager API calls and delivers the log files to an Amazon S3 bucket that you specify. CloudTrail can capture all API calls generated by either the AWS Secrets Manager console or your code. Using the information collected by CloudTrail, you can determine the secret access request that was made to AWS Secrets Manager, the source IP address from which the request was made, who made the request, when it was made, and so on. AWS Secrets Manager is also integrated with the Event history feature in CloudTrail. If an API for AWS Secrets Manager is supported in Event history, you can view the most recent 90 days of events in AWS Secrets Manager in the CloudTrail console in Event history even if you have not configured any logs in CloudTrail.

To learn more about CloudTrail, including how to configure and enable it, see the AWS CloudTrail User Guide.

AWS Secrets Manager Information in CloudTrail

CloudTrail is enabled on your AWS account when you create the account. When activity occurs in AWS Secrets Manager, that activity is recorded in a CloudTrail event along with other AWS service events in Event history. You can view, search, and download the past 90 days of supported activity in your AWS account. For more information, see Viewing Events with CloudTrail Event History and Services Supported by CloudTrail Event History.

When CloudTrail logging is enabled in your AWS account, API calls made to AWS Secrets Manager actions are tracked in CloudTrail log files, where they are written with other AWS service records. CloudTrail determines when to create and write to a new file based on a time period and file size.

AWS Secrets Manager currently supports logging only the following actions as management events in CloudTrail log files. There are currently no data events.

  • CancelRotateSecret

  • CreateSecret

  • DeleteSecret

  • PutSecretValue

  • RestoreSecret

  • RotateSecret

  • TagResource

  • UntagResource

  • UpdateSecret

  • UpdateSecretVersionStage

Every log entry contains information about who generated the request. The user identity information in the log entry helps you determine the following:

  • Whether the request was made with account root or IAM user credentials

  • Whether the request was made with temporary security credentials for an IAM role or a federated user whose security credentials are validated by an external identity provider instead of directly by AWS

  • Whether the request was made by another AWS service

For more information, see the CloudTrail userIdentity Element.

You can view, search, and download the most recent 90 days of AWS Secrets Manager activity in the CloudTrail console. For more information, see Viewing Events with CloudTrail Event History. You can also create a trail and store your log files in your Amazon S3 bucket for as long as you want, and define Amazon S3 lifecycle rules to archive or delete log files automatically. By default, your log files are encrypted with Amazon S3 server-side encryption (SSE).

If you want to be notified upon log file delivery, you can configure CloudTrail to publish Amazon SNS notifications whenever new log files are delivered. For more information, see Configuring Amazon SNS Notifications for CloudTrail.

You also can aggregate AWS Secrets Manager log files from multiple AWS regions and multiple AWS accounts into a single Amazon S3 bucket.

For more information, see Receiving CloudTrail Log Files from Multiple Regions and Receiving CloudTrail Log Files from Multiple Accounts.

Understanding AWS Secrets Manager Log File Entries

CloudTrail log files can contain one or more log entries. Each entry lists multiple JSON-formatted events. A log entry represents a single request from any source and includes information about the requested action, the date and time of the action, request parameters, and so on. Log entries are not an ordered stack trace of the public API calls, so they do not appear in any specific order.

The following example shows a CloudTrail log entry for a sample CreateSecret call:

{ "eventVersion": "1.05", "userIdentity": { "type": "Root", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:root", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "myusername", "sessionContext": {"attributes": { "mfaAuthenticated": "false", "creationDate": "2018-04-03T17:43:50Z" }} }, "eventTime": "2018-04-03T17:50:55Z", "eventSource": "", "eventName": "CreateSecret", "awsRegion": "us-west-2", "requestParameters": { "name": "MyDatabaseSecret", "clientRequestToken": "EXAMPLE1-90ab-cdef-fedc-ba987EXAMPLE" }, "responseElements": null, "requestID": "EXAMPLE2-90ab-cdef-fedc-ba987EXAMPLE", "eventID": "EXAMPLE3-90ab-cdef-fedc-ba987EXAMPLE", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

The following example shows a CloudTrail log entry for a sample DeleteSecret call:

{ "eventVersion": "1.05", "userIdentity": { "type": "Root", "principalId": "123456789012", "arn": "arn:aws:iam::123456789012:root", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "myusername", "sessionContext": {"attributes": { "mfaAuthenticated": "false", "creationDate": "2018-04-03T17:43:50Z" }} }, "eventTime": "2018-04-03T17:51:02Z", "eventSource": "", "eventName": "DeleteSecret", "awsRegion": "us-west-2", "requestParameters": { "recoveryWindowInDays": 30, "secretId": "MyDatabaseSecret" }, "responseElements": { "name": "MyDatabaseSecret", "deletionDate": "May 3, 2018 5:51:02 PM", "aRN": "arn:aws:secretsmanager:us-west-2:123456789012:secret:MyDatabaseSecret-p5mycT" }, "requestID": "EXAMPLE2-90ab-cdef-fedc-ba987EXAMPLE", "eventID": "EXAMPLE3-90ab-cdef-fedc-ba987EXAMPLE", "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }

Amazon CloudWatch Events

AWS Secrets Manager can work with CloudWatch Events to trigger alerts when administrator-specified actions occur in an organization. For example, because of the sensitivity of such actions, administrators might want to be warned when a secret is deleted or when a secret is rotated. You can configure CloudWatch Events rules that look for these actions and then send the generated events to administrator defined "targets". A target could be an Amazon SNS topic that emails or text messages its subscribers. You could also create a simple AWS Lambda function that is triggered by the event, that logs the details of the action for your later review.

To learn more about CloudWatch Events, including how to configure and enable it, see the Amazon CloudWatch Events User Guide.