Logging AWS OpsWorks for Chef Automate API Calls with AWS CloudTrail
Important
AWS OpsWorks for Chef Automate reached end of life on May 5, 2024 and has been disabled for both new and existing customers. We recommend that existing customers migrate to Chef SaaS or an alternative solution. If you have questions,
you can reach out to the AWS Support Team on AWS re:Post
AWS OpsWorks for Chef Automate is integrated with AWS CloudTrail, a service that provides a record of actions taken by an IAM identity, or an AWS service in AWS OpsWorks for Chef Automate. CloudTrail captures all API calls for AWS OpsWorks for Chef Automate as events, including calls from the AWS OpsWorks for Chef Automate console and from code calls to the AWS OpsWorks for Chef Automate APIs. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for AWS OpsWorks for Chef Automate. If you don't configure a trail, you can still view the most recent events in the CloudTrail console in Event history. Using the information collected by CloudTrail, you can determine the request that was made to AWS OpsWorks for Chef Automate, the IP address from which the request was made, who made the request, when it was made, and additional details.
To learn more about CloudTrail, see the AWS CloudTrail User Guide.
AWS OpsWorks for Chef Automate Information in CloudTrail
CloudTrail is enabled on your AWS account when you create the account. When activity occurs in AWS OpsWorks for Chef Automate, that activity is recorded in a CloudTrail event along with other AWS service events in Event history. You can view, search, and download recent events in your AWS account. For more information, see Viewing Events with CloudTrail Event History.
For an ongoing record of events in your AWS account, including events for AWS OpsWorks for Chef Automate, create a trail. A trail enables CloudTrail to deliver log files to an Amazon S3 bucket. By default, when you create a trail in the console, the trail applies to all regions. The trail logs events from all regions in the AWS partition and delivers the log files to the Amazon S3 bucket that you specify. Additionally, you can configure other AWS services to further analyze and act upon the event data collected in CloudTrail logs. For more information, see:
All AWS OpsWorks for Chef Automate actions are logged by CloudTrail and are documented in the AWS OpsWorks for Chef Automate API Reference. For example, calls to the CreateServer, CreateBackup, and DescribeServers actions generate entries in the CloudTrail log files.
Every event or log entry contains information about who generated the request. The identity information helps you determine the following:
-
Whether the request was made with root or IAM user credentials.
-
Whether the request was made with temporary security credentials for a role or federated user.
-
Whether the request was made by another AWS service.
For more information, see the CloudTrail userIdentity Element.
Understanding AWS OpsWorks for Chef Automate Log File Entries
A trail is a configuration that enables delivery of events as log files to an Amazon S3 bucket that you specify. CloudTrail log files contain one or more log entries. An event 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. CloudTrail log files 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 the AWS OpsWorks for Chef Automate CreateServer
action.
{"eventVersion":"1.05", "userIdentity":{ "type":"AssumedRole", "principalId":"
ID number
:OpsWorksCMUser", "arn":"arn:aws:sts::831000000000:assumed-role/Admin/OpsWorksCMUser", "accountId":"831000000000","accessKeyId":"ID number
", "sessionContext":{ "attributes":{ "mfaAuthenticated":"false", "creationDate":"2017-01-05T22:03:47Z" }, "sessionIssuer":{ "type":"Role", "principalId":"ID number
", "arn":"arn:aws:iam::831000000000:role/Admin", "accountId":"831000000000", "userName":"Admin" } } }, "eventTime":"2017-01-05T22:18:23Z", "eventSource":"opsworks-cm.amazonaws.com", "eventName":"CreateServer", "awsRegion":"us-west-2", "sourceIPAddress":"101.25.190.51", "userAgent":"console.amazonaws.com", "requestParameters":{ "serverName":"OpsChef-test-server", "engineModel":"Single", "engine":"Chef", "instanceProfileArn":"arn:aws:iam::831000000000:instance-profile/aws-opsworks-cm-ec2-role", "backupRetentionCount":3,"serviceRoleArn":"arn:aws:iam::831000000000:role/service-role/aws-opsworks-cm-service-role", "engineVersion":"12", "preferredMaintenanceWindow":"Fri:21:00", "instanceType":"t2.medium", "subnetIds":["subnet-1e111f11"], "preferredBackupWindow":"Wed:08:00" }, "responseElements":{ "server":{ "endpoint":"OpsChef-test-server-thohsgreckcnwgz3.us-west-2.opsworks-cm.io", "createdAt":"Jan 5, 2017 10:18:22 PM", "serviceRoleArn":"arn:aws:iam::831000000000:role/service-role/aws-opsworks-cm-service-role", "preferredBackupWindow":"Wed:08:00", "status":"CREATING", "subnetIds":["subnet-1e111f11"], "engine":"Chef", "instanceType":"t2.medium", "serverName":"OpsChef-test-server", "serverArn":"arn:aws:opsworks-cm:us-west-2:831000000000:server/OpsChef-test-server/8epp7f6z-e91f-4z10-89z5-8c6219cdb09f", "engineModel":"Single", "backupRetentionCount":3, "engineAttributes":[ {"name":"CHEF_STARTER_KIT","value":"*** Redacted ***"}, {"name":"CHEF_PIVOTAL_KEY","value":"*** Redacted ***"}, {"name":"CHEF_DELIVERY_ADMIN_PASSWORD","value":"*** Redacted ***"}], "engineVersion":"12.11.1", "instanceProfileArn":"arn:aws:iam::831000000000:instance-profile/aws-opsworks-cm-ec2-role", "preferredMaintenanceWindow":"Fri:21:00" } }, "requestID":"de7f64f9-d394-12ug-8081-7bb0386fbcb6", "eventID":"8r7b18df-6c90-47be-87cf-e8346428cfc3", "eventType":"AwsApiCall", "recipientAccountId":"831000000000" }