iac.htora.dev · security templates

Home/Refreshers/Audit logs nobody can delete: refresher

Audit logs nobody can delete

Send cloud audit logs to storage that refuses deletes for a set number of days.

Remember

  1. Something changes in the account: every API call is recorded.
  2. The cloud's audit service: CloudTrail, Activity Log, Cloud Audit Logs, or Audit.
  3. A delivery pipe: the trail, a diagnostic setting, a sink, or a connector.
  4. Locked storage: deletes refused until the retention period ends.
PlatformUsesThe part that catches people
AWSCloudTrail writing to S3 with Object Lock turned onObject Lock can only be switched on at the moment a bucket is created.
AzureActivity Log writing to a blob container with a retention policyAzure creates the container itself on first delivery, named insights-activity-logs.
Google CloudA log sink writing to a Cloud Storage bucket with a retention policyThe sink writes as its own service account, which Terraform calls its writer identity.
Oracle CloudConnector Hub copying audit events to Object Storage with a retention ruleA retention rule cannot lock straight away.

Run the quick start

Download providersterraform init
Previewterraform plan
Applyterraform apply
Print the proof commandsterraform output verify

Watch out

  • The copy is only as complete as what the cloud logs in the first place.
  • Keep the account or project containing the copy separate from the ones it watches, when you can.
Check it worked

Try to delete a stored log file. The delete should fail. The full page gives the exact commands for each platform.

Read the full pageDownload PDF

Registry 0.23.0. Built 2026-11-17.

Made by Habibullah Tora. Source on GitHub. Code under the MIT licence, writing under CC BY 4.0.