Logging App Runner API calls with AWS CloudTrail - AWS App Runner

Logging App Runner API calls with AWS CloudTrail

App Runner is integrated with AWS CloudTrail, a service that provides a record of actions taken by a user, role, or an AWS service in App Runner. CloudTrail captures all API calls for App Runner as events. The calls captured include calls from the App Runner console and code calls to the App Runner API operations. If you create a trail, you can enable continuous delivery of CloudTrail events to an Amazon S3 bucket, including events for App Runner. 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 App Runner, the IP address from where 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.

App Runner information in CloudTrail

CloudTrail is enabled on your AWS account when you create the account. When activity occurs in App Runner, 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 App Runner, 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 AWS 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 the following:

All App Runner actions are logged by CloudTrail and are documented in the AWS App Runner API Reference. For example, calls to the CreateService, DeleteConnection, and StartDeployment 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 App Runner 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, and request parameters. CloudTrail log files aren't an ordered stack trace of the public API calls, so they don't appear in any specific order.

The following example shows a CloudTrail log entry that demonstrates the CreateService action.


For security reasons, some property values are redacted in the logs and replaced with the text HIDDEN_DUE_TO_SECURITY_REASONS. This prevents unintended exposure of secret information. However, you can still see that these properties were passed in the request or returned in the response.

{ "eventVersion": "1.08", "userIdentity": { "type": "IAMUser", "principalId": "AIDACKCEVSQ6C2EXAMPLE", "arn": "arn:aws:iam::123456789012:user/aws-user", "accountId": "123456789012", "accessKeyId": "AKIAIOSFODNN7EXAMPLE", "userName": "aws-user" }, "eventTime": "2020-10-02T23:25:33Z", "eventSource": "apprunner.amazonaws.com", "eventName": "CreateService", "awsRegion": "us-east-2", "sourceIPAddress": "", "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.75 Safari/537.36", "requestParameters": { "serviceName": "python-test", "sourceConfiguration": { "codeRepository": { "repositoryUrl": "https://github.com/github-user/python-hello", "sourceCodeVersion": { "type": "BRANCH", "value": "main" }, "codeConfiguration": { "configurationSource": "API", "codeConfigurationValues": { "runtime": "python3", "buildCommand": "HIDDEN_DUE_TO_SECURITY_REASONS", "startCommand": "HIDDEN_DUE_TO_SECURITY_REASONS", "port": "8080", "runtimeEnvironmentVariables": "HIDDEN_DUE_TO_SECURITY_REASONS" } } }, "autoDeploymentsEnabled": true, "authenticationConfiguration": { "connectionArn": "arn:aws:apprunner:us-east-2:123456789012:connection/your-connection/e7656250f67242d7819feade6800f59e" } }, "healthCheckConfiguration": { "protocol": "HTTP" }, "instanceConfiguration": { "cpu": "256", "memory": "1024" } }, "responseElements": { "service": { "serviceName": "python-test", "serviceId": "dfa2b7cc7bcb4b6fa6c1f0f4efff988a", "serviceArn": "arn:aws:apprunner:us-east-2:123456789012:service/python-test/dfa2b7cc7bcb4b6fa6c1f0f4efff988a", "serviceUrl": "generated domain", "createdAt": "2020-10-02T23:25:32.650Z", "updatedAt": "2020-10-02T23:25:32.650Z", "status": "OPERATION_IN_PROGRESS", "sourceConfiguration": { "codeRepository": { "repositoryUrl": "https://github.com/github-user/python-hello", "sourceCodeVersion": { "type": "Branch", "value": "main" }, "sourceDirectory": "/", "codeConfiguration": { "codeConfigurationValues": { "configurationSource": "API", "runtime": "python3", "buildCommand": "HIDDEN_DUE_TO_SECURITY_REASONS", "startCommand": "HIDDEN_DUE_TO_SECURITY_REASONS", "port": "8080", "runtimeEnvironmentVariables": "HIDDEN_DUE_TO_SECURITY_REASONS" } } }, "autoDeploymentsEnabled": true, "authenticationConfiguration": { "connectionArn": "arn:aws:apprunner:us-east-2:123456789012:connection/your-connection/e7656250f67242d7819feade6800f59e" } }, "healthCheckConfiguration": { "protocol": "HTTP", "path": "/", "interval": 5, "timeout": 2, "healthyThreshold": 3, "unhealthyThreshold": 5 }, "instanceConfiguration": { "cpu": "256", "memory": "1024" }, "autoScalingConfigurationSummary": { "autoScalingConfigurationArn": "arn:aws:apprunner:us-east-2:123456789012:autoscalingconfiguration/DefaultConfiguration/1/00000000000000000000000000000001", "autoScalingConfigurationName": "DefaultConfiguration", "autoScalingConfigurationRevision": 1 } } }, "requestID": "1a60af60-ecf5-4280-aa8f-64538319ba0a", "eventID": "e1a3f623-4d24-4390-a70b-bf08a0e24669", "readOnly": false, "eventType": "AwsApiCall", "recipientAccountId": "123456789012" }