All guides

CloudTrail, Azure Activity Log and Cloud Audit Logs: turn them on first

AWS, Azure and Google Cloud each record control plane activity by default, and each keeps it for a set period. Set up export to a separate account, subscription or project before you build anything else.

Lines of code on a screen, coloured by syntax

What each cloud keeps by default

  • AWS. CloudTrail event history is a record of the past 90 days of management events in a Region. It does not record data events.
  • Azure. Azure retains Activity Log events, which record control plane operations, for 90 days. Microsoft Entra audit and sign-in logs are a separate source. Microsoft Entra ID keeps them for seven days with the Free license and 30 days with P1 or P2.
  • Google Cloud. Admin Activity and System Event audit logs are always written. They go to the _Required bucket, which keeps them for 400 days. Policy Denied logs are generated by default. Data Access logs are disabled by default, except for BigQuery. The _Default bucket, where these two types go, keeps logs for 30 days by default.

AWS CloudTrail

CloudTrail's event types include management events and data events. Management events are control plane operations, such as the IAM AttachRolePolicy and EC2 CreateSubnet calls. Data events are operations performed on or in a resource, such as GetObject on an S3 object or a Lambda function invocation. Trails log management events by default. Data events are not logged until you add each resource type, and additional charges apply.

For an ongoing record of events, you must create a trail. In AWS Organizations, the management account or a delegated administrator account can create an organization trail. It delivers the events of the management account and all member accounts to the same S3 bucket. Users in member accounts can see the trail but cannot delete it, turn logging on or off, or change which events are logged.

Shell

aws cloudtrail create-trail \
  --name org-trail \
  --s3-bucket-name my-org-cloudtrail-logs \
  --is-multi-region-trail \
  --is-organization-trail \
  --enable-log-file-validation

aws cloudtrail start-logging --name org-trail

Choose your own trail and bucket names. The three flags matter because of the defaults of create-trail: the trail covers only the current Region, it belongs only to the current account, and log file validation is off. After create-trail completes, run start-logging to start logging for the trail.

With log file validation, CloudTrail creates a hash for every log file. Every hour it delivers a signed digest file that references the log files of the last hour. aws cloudtrail validate-logs uses the digest files to detect modification or deletion of log files.

Azure Activity Log and Entra logs

The Activity Log records management operations on Azure resources. Data plane operations are captured in resource logs, which are not collected by default and need a diagnostic setting. A request rejected by Azure Resource Manager at authentication or authorization leaves no entry in the Activity Log.

For longer retention, create a diagnostic setting. It can send Activity Log entries to a Log Analytics workspace, a storage account or an event hub. This command creates one for a subscription:

Shell

az monitor diagnostic-settings subscription create \
  --name activity-to-workspace \
  --location <location> \
  --workspace <log-analytics-workspace-id> \
  --logs "[{category:Administrative,enabled:true},{category:Security,enabled:true}]"

Microsoft's example also includes the categories Policy, ServiceHealth, Alert, Recommendation, Autoscale and ResourceHealth.

Microsoft Entra ID logs all sign-ins into a tenant in its sign-in logs. Its audit logs capture changes to applications, groups, users and licenses. These logs have their own diagnostic settings in the Microsoft Entra admin center. Configuring them takes at least the Security Administrator role.

Google Cloud Audit Logs

Cloud Audit Logs has four types:

  • Admin Activity is written by calls that modify the configuration or metadata of resources. You cannot disable it.
  • System Event is written by Google Cloud systems that modify the configuration of resources. You cannot disable it.
  • Data Access is written by calls that read configuration or metadata, and by calls that create, modify or read user-provided data. It is disabled by default, except for BigQuery, because it can generate large volumes of data.
  • Policy Denied is written when a service denies access because of a security policy violation.

For a project's _Default bucket, you can configure retention between 1 day and 3,650 days.

An aggregated sink combines the log entries of an organization or a folder and routes them to a central destination. This command follows Google's form for an organization-level sink that routes to a log bucket:

Shell

gcloud logging sinks create my-sink \
  logging.googleapis.com/projects/<project-id>/locations/<location>/buckets/<bucket-name> \
  --include-children \
  --organization=<organization-id> \
  --log-filter='logName:"cloudaudit.googleapis.com"'

The filter is the query that Google gives for displaying all audit logs. Then grant the sink's writer identity the Logs Bucket Writer role (roles/logging.bucketWriter) on the destination.

A separate account for the logs

  1. AWS. Follow the CloudTrail security best practices: create a separate AWS account as a log archive account, create a dedicated S3 bucket for the trail's log files, and restrict access to that account to trusted administrative users. AWS also recommends MFA delete on the bucket.
  2. Azure. The destination of a diagnostic setting does not have to be in the same subscription as the source, if the user who configures it has Azure RBAC access to both. Send the Activity Log of each subscription and the Entra logs to one workspace.
  3. Google Cloud. Route the aggregated sink to a log bucket in the project you choose for central logging, and set the retention of that bucket.

Then test it: make a change in a workload account and find the event in the central store.

Sources

Want a second pair of eyes on yours? We do this work for a living.

Book a call

More guides