Home/Templates/Notice data walking out the door
Notice data walking out the door
Alerts on the moves someone makes on the way out with data: sharing it outside, reading far more than usual, changing who can decrypt it, and quieting the logs.
Terraform
Why bother
Someone who already has access does not need to break in. They share a bucket with an outside account, copy a snapshot, grant themselves a way to decrypt, or read a whole dataset in an afternoon, often in the weeks before they leave. Each step uses permissions they have, so nothing is refused and nothing looks like an attack. These alerts watch for the steps themselves, and the saved queries give the investigator the history to go with them.
In a test account or project, share a test bucket outside and then undo it. The sharing alert reaches the security inbox within minutes.
How it works
Set it up
Pick your platform, then open the level you want. Each level is complete on its own. Read the comments in the files as you go. Anything with a real consequence is explained on the line where it happens.
Terraform. CloudWatch metric filters on the audit trail, and Contributor Insights on object reads
What you need first
- A multi-region CloudTrail trail delivering to CloudWatch Logs, such as the Standard audit log template builds. Apply in that log group's region.
- An email address, or for Standard an SNS topic, that reaches the security team.
- For bulk reads (Standard), the ARNs of the buckets that contain the data you most need to protect.
What it creates
- Three metric filters and alarms on the trail's log group: data shared outside the account, changes to who can use a KMS key, and trails or flow logs turned down
- Named pipeline roles left out of the alarms (Standard)
- A trail that records object reads from the named buckets only, into its own encrypted bucket and log group (Standard)
- A Contributor Insights rule ranking principals by objects read, and an alarm when the top one passes the threshold in five minutes (Standard)
- Saved Logs Insights queries for permission changes, one principal's activity, changes by person, and decrypt grants, plus bulk readers when buckets are named (Standard)
- An alert topic encrypted with a key CloudWatch alarms are allowed to use (Standard)
See the four alerts this creates
Saved queries this installs
Standard and Hardened install these five, ready for the first hour of a case. Quick start installs none.
| Saved query | What it answers | Where to open it |
|---|---|---|
insider-data-theft/permission-changes | Who gave whom new IAM access, newest first. Run it first when an alarm names a person. | CloudWatch console, Logs Insights, Queries, folder insider-data-theft |
insider-data-theft/one-principal | Everything one principal did. Replace the name in the filter first. | CloudWatch console, Logs Insights, Queries, folder insider-data-theft |
insider-data-theft/changes-by-person | The changes that alarm, with who made each one, for reviewing a week at once. | CloudWatch console, Logs Insights, Queries, folder insider-data-theft |
insider-data-theft/decrypt-grants | KMS grants that let someone decrypt, made with no AWS service acting for the caller. | CloudWatch console, Logs Insights, Queries, folder insider-data-theft |
insider-data-theft/bulk-readers | Who read the most S3 objects, hour by hour. Only when sensitive_bucket_arns is set. | CloudWatch console, Logs Insights, Queries, folder insider-data-theft |
The code
Quick startReady
trail_log_group = "your-cloudtrail-log-group"main.tf, line 18alert_email = "security-alerts@example.com"main.tf, line 19
aws sts get-caller-identity
Shows the account and role you are signed in as. Check it before every apply.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.terraform destroy
When you have finished. If it refuses, How to undo it below explains why.
Formatting passedValid passedLint passed
Security scan: two checks passed, and one rule flagged, each with a written reason:
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/aws 6.66.0.
Open main.tf as plain text
StandardReady
trail_log_group. CloudWatch log group a multi-region CloudTrail trail delivers management events to, such as the Standard audit log template builds.
aws sts get-caller-identity
Shows the account and role you are signed in as. Check it before every apply.# terraform.tfvars trail_log_group = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: 73 checks passed, and eight rules flagged, each with a written reason:
- S3 event notifications
- IAM permissions management without constraints
- IAM write access without constraints
- S3 cross-region replication
- S3 server access logging
- CloudTrail SNS topic
- CloudWatch log retention of a year
- IAM resource of *
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/aws 6.66.0.
Open main.tf as plain text
Open outputs.tf as plain text
Open queries.tf as plain text
Open reads.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
HardenedReady
trail_log_group. CloudWatch log group a multi-region CloudTrail trail delivers management events to, such as the Standard audit log template builds.
aws sts get-caller-identity
Shows the account and role you are signed in as. Check it before every apply.# terraform.tfvars trail_log_group = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: 67 checks passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/aws 6.66.0.
Open .checkov.yml as plain text
Open guard.yml as plain text
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
How to check it worked
Add and remove a statement on a test bucket's policy. The shared-outside alarm goes to ALARM and emails within about ten minutes.
The management trail does not record object reads, so bulk downloads are invisible without data events. Recording them for every bucket is expensive, which is why Standard records reads only from the buckets you name, on a trail of its own that records nothing else.
AWS services create KMS grants on a caller's behalf all day. Those calls carry the service's name as the source address, and the filter leaves them out, so the alarm fires on grants a person made directly.
Deployment pipelines change bucket and key policies as their job, and will trip these alarms on every release. Standard takes up to four role ARNs to leave out, and matches them as CloudTrail records them, by the assumed-role session. Each one is a blind spot, so name the pipeline and nothing else.
CloudWatch alarms cannot publish to an SNS topic encrypted with the AWS managed key, and nothing reports the failure. Standard creates its topic with a key whose policy allows them, and an existing topic needs the same.
How to undo it
terraform destroy removes the alarms, the queries, the read trail, and its log group. The read bucket is kept until you empty it, because it contains evidence.
What it costs
Cents a month for the filters and alarms, and a dollar a month for the KMS key in Standard. The read trail is the real cost: CloudTrail charges for each object read it records, and CloudWatch Logs charges to ingest and keep them. Contributor Insights bills per rule and per matched event. Name few buckets and check the bill after a week.
Terraform. The subscription's activity log in Log Analytics, with scheduled query alerts and per-caller bulk-read alerting on blob logs
What you need first
- A subscription, and rights to add its activity log diagnostic setting, create a Log Analytics workspace, alert rules, and an action group, and assign roles on the workspace. Standard also puts a lock on the resource group, which needs Owner or User Access Administrator.
- An existing resource group for them, kept apart from workloads, because Standard locks everything in it against deletes.
- For bulk reads (Standard), the storage accounts that contain the data you most need to protect.
What it creates
- A Log Analytics workspace receiving the subscription's activity log, which Azure does not charge to ingest
- Three alerts. The first is a storage key fetched, a SAS made through Azure Resource Manager, or a key regenerated. The second is a key vault, its access policy, or a role assignment reaching its keys, secrets, or certificates changed. The third is a diagnostic setting, workspace, alert rule, or action group changed or deleted. It also covers a workspace purged, table retention changed, a lock or resource group deleted, or an alert processing rule written.
- Three native activity log alerts, which Azure evaluates without the workspace: a diagnostic setting deleted, a diagnostic setting written, and a log search rule disabled by Azure
- A cannot-delete lock on the security resource group, made last so it covers everything there, and a native alert on the rules' role assignments deleted (Standard)
- Named callers left out of the alerts, while the workspace keeps their entries, and an identity for each rule with the Log Analytics Reader role (Standard)
- Blob read logs for the named storage accounts, and an alert per caller who reads more than a set number of gigabytes in an hour (Standard)
- A saved query behind every alert, under the category Insider data theft (Standard)
See the eight alerts this creates
Saved queries this installs
Standard and Hardened install these four, ready for the first hour of a case. Quick start installs none.
| Saved query | What it answers | Where to open it |
|---|---|---|
insider-keys-or-sas | The search behind the keys-or-sas alert, over the last seven days. | Log Analytics workspace, Logs, Queries, category Insider data theft |
insider-decrypt-rights | The search behind the decrypt-rights alert, over the last seven days. | Log Analytics workspace, Logs, Queries, category Insider data theft |
insider-logging-weakened | The search behind the logging-weakened alert, over the last seven days. | Log Analytics workspace, Logs, Queries, category Insider data theft |
insider-bulk-read | Callers who read the most from the sensitive accounts in the last hour. Only when sensitive_storage_account_ids is set. | Log Analytics workspace, Logs, Queries, category Insider data theft |
The code
Quick startReady
subscription_id = "00000000-0000-0000-0000-000000000000"main.tf, line 25resource_group_name = "rg-security"main.tf, line 26alert_email = "security-alerts@example.com"main.tf, line 27
az login
Signs the command line tool in. Terraform uses the same sign-in.export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
Tells the provider which subscription. It stopped guessing in version 4.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform destroy
When you have finished. If it refuses, How to undo it below explains why.
Formatting passedValid not runLint passed
Security scan: zero checks passed, and none flagged.
Last run 2026-11-06 with OpenTofu v1.12.6.
Open main.tf as plain text
StandardReady
subscription_id. Subscription whose activity log is watched, as a GUID. The workspace and alerts go in it too.resource_group_name. An existing resource group for the workspace, alerts, and saved queries. Keep it apart from workloads: Standard locks it, so nothing in it can be deleted.alert_emails. Addresses that receive the alerts. Prefer an on-call address over a person.
az login
Signs the command line tool in. Terraform uses the same sign-in.export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
Tells the provider which subscription. It stopped guessing in version 4.# terraform.tfvars subscription_id = "" resource_group_name = "" alert_emails = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid not runLint passed
Security scan: zero checks passed, and none flagged.
Last run 2026-11-06 with OpenTofu v1.12.6.
Open main.tf as plain text
Open outputs.tf as plain text
Open queries.tf as plain text
Open reads.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
HardenedReady
subscription_id. Subscription whose activity log is watched, as a GUID. The workspace and alerts go in it too.resource_group_name. An existing resource group for the workspace, alerts, and saved queries. Keep it apart from workloads: Standard locks it, so nothing in it can be deleted.alert_emails. Addresses that receive the alerts. Prefer an on-call address over a person.
az login
Signs the command line tool in. Terraform uses the same sign-in.export ARM_SUBSCRIPTION_ID=$(az account show --query id -o tsv)
Tells the provider which subscription. It stopped guessing in version 4.# terraform.tfvars subscription_id = "" resource_group_name = "" alert_emails = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid not runLint passed
Security scan: zero checks passed, and none flagged.
Last run 2026-11-06 with OpenTofu v1.12.6.
Open .checkov.yml as plain text
Open guard.yml as plain text
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
How to check it worked
Wait up to 90 minutes after the first apply, while the export starts. Then, on a test storage account, run az storage account keys list. The keys-or-sas alert emails once the entry reaches the workspace.
A storage key or a SAS made from it works for whoever has it, with no identity behind it, and nothing short of rotating the key revokes it. The data perimeter template's shared-key policy refuses keys outright; this alert covers accounts where keys are still on.
The portal fetches keys when someone opens a storage account's Access keys page, and so do tools that sign with keys. Expect some alerts from people at work, and name pipelines that do it as their job.
A role assignment's request body, which names the role and scope, appears on the assignment's Start event. The decrypt-rights alert reads it there, as Microsoft's own alerting guide does, so it fires on an attempt that later fails.
This template does not alert on a container or account made public. The data perimeter template's public-access policies refuse that outright.
A caller in the activity log is a UPN for a person and a GUID for an app or managed identity, and Microsoft does not say which GUID. Name both the application ID and the object ID of an expected identity.
Blob reads signed in with Microsoft Entra ID name the caller. Reads with a key or a SAS name no one, so the bulk-read alert totals them per account, wherever they came from. It counts blob downloads and Data Lake file reads.
A key vault's own write operation covers its access policies and its switch to role-based access, and also tags and other settings. Expect alerts from routine vault changes, and name the pipeline that makes them.
Every alert, the native ones included, emails through one action group. In the quick start, deleting or disabling that group, or deleting its resource group, silences them all. Standard's lock stops the deletes, but whoever can edit the group can still disable it or change its addresses.
Standard's lock blocks Terraform too. A change that replaces or removes a resource in the group fails while it is on, such as a saved query whose text or tags change. Remove the lock with terraform destroy -target=azurerm_management_lock.security, then apply, and the lock returns. Its removal fires the logging alert.
A cannot-delete lock does not stop a workspace purge, which the logging alert watches. Removing a rule's read access needs the lock lifted first, and the rule-access alert reports it without the workspace.
The rule-access alert matches the rules' role assignments by ID. Microsoft documents a role assignment's activity log entry under its full ID, scope included. That an assignment on a workspace is recorded the same way is inferred; the Standard verify output tests it.
The diagnostic-setting-written alert fires on every diagnostic setting created or changed in the subscription, policy remediation included, because a rewrite can drop a category or send logs elsewhere without a delete.
An export can take up to 90 minutes to start after it is made, so run the drills after that. Activity log entries usually take three to 20 minutes to reach the workspace.
The AzureActivity table does not exist until the first event arrives, so the rules skip Azure's query check at creation. Azure disables a rule whose query fails for a week, and the rule-disabled alert reports that without the workspace. The bulk-read query starts from an empty table, so a quiet account cannot switch it off.
How to undo it
In Standard, remove the lock first with terraform destroy -target=azurerm_management_lock.security, or module.standard.azurerm_management_lock.security in Hardened. Then terraform destroy removes the alerts, the saved queries, the diagnostic settings, and the workspace, and the copies of the activity log with it. The activity log itself is still kept by Azure for 90 days.
What it costs
Ingesting the activity log is free, with 90 days kept free. Longer retention, blob read logs, and each alert rule are billed. A busy account's read log runs large, so name only the accounts that matter.
Terraform. An organisation log sink, log-based metrics, and per-principal alerting on Data Access logs
What you need first
- An organisation, and rights to create organisation sinks and grant roles in a security project.
- The Cloud Logging and Cloud Monitoring APIs on in the security project.
- For bulk reads (Standard), the projects that contain the data you most need to protect.
What it creates
- An organisation sink copying matching Admin Activity entries from every project into one log bucket
- Three log-based metrics and alerts: anything shared with allUsers or allAuthenticatedUsers, Cloud KMS permission changes, and log sinks, buckets, exclusions, or audit settings changed
- Named service accounts left out of the alerts, while the bucket keeps their entries (Standard)
- Data Access logs for Cloud Storage reads in the named projects, routed to their own bucket (Standard)
- A metric labelled by principal and an alert when one principal reads more than the threshold in five minutes (Standard)
- Every IAM grant in the organisation kept in the same bucket for investigations, and shared saved queries for changes by person, permission changes, one principal, and object reads (Standard)
See the four alerts this creates
Saved queries this installs
Standard and Hardened install these four, ready for the first hour of a case. Quick start installs none.
| Saved query | What it answers | Where to open it |
|---|---|---|
Insider: changes by person | Every change that alerts, with who made it. | Logs Explorer, Saved queries, Shared, in the security project |
Insider: permission changes | Who was given new access. Run it first when an alert names a person. | Logs Explorer, Saved queries, Shared, in the security project |
Insider: one principal | Everything one principal did. Replace the email first. | Logs Explorer, Saved queries, Shared, in the security project |
Insider: object reads | Object reads in the sensitive projects. Only when sensitive_projects is set. | Logs Explorer, Saved queries, Shared, in the security project |
The code
Quick startReady
org_id = "123456789012"main.tf, line 18security_project = "your-security-project"main.tf, line 19alert_email = "security-alerts@example.com"main.tf, line 20
gcloud auth application-default login
The sign-in Terraform reads. A plain gcloud auth login is not enough.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform destroy
When you have finished. If it refuses, How to undo it below explains why.
Formatting passedValid passedLint passed
Security scan: six checks passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/google 8.4.0.
Open main.tf as plain text
StandardReady
org_id. Numeric organisation ID.security_project. Project that contains the log buckets, alerts, and saved queries. Keep it separate from workloads.alert_emails. Addresses that receive the alerts. Prefer an on-call address over a person.
gcloud auth application-default login
The sign-in Terraform reads. A plain gcloud auth login is not enough.# terraform.tfvars org_id = "" security_project = "" alert_emails = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: 12 checks passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/google 8.4.0.
Open main.tf as plain text
Open outputs.tf as plain text
Open queries.tf as plain text
Open reads.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
HardenedReady
org_id. Numeric organisation ID.security_project. Project that contains the log buckets, alerts, and saved queries. Keep it separate from workloads.alert_emails. Addresses that receive the alerts. Prefer an on-call address over a person.
gcloud auth application-default login
The sign-in Terraform reads. A plain gcloud auth login is not enough.# terraform.tfvars org_id = "" security_project = "" alert_emails = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: 12 checks passed, and none flagged.
Last run 2026-10-02 with OpenTofu v1.12.6 against hashicorp/google 8.4.0.
Open .checkov.yml as plain text
Open guard.yml as plain text
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
How to check it worked
Grant allUsers the Storage Object Viewer role on a test bucket, then remove it. The shared-publicly alert emails within minutes.
Log-based metrics only count entries in their own project. The organisation sink copies matches from every project into the security project first, and the metrics read that bucket.
Cloud Storage reads are Data Access logs, which are off by default and billed by volume. Standard turns them on only in the projects you name, and its audit setting is authoritative for Cloud Storage in those projects, so remove any other setting for that service there first.
The entries sit in the security project's own log buckets, which Logs Explorer does not search by default. Choose Refine scope, then Scope by storage, and pick the insider buckets before running a saved query.
BigQuery records dataset sharing under metadata.datasetChange, where most services use serviceData.policyDelta. The sharing filter reads both.
The guardrail template's domain restriction refuses grants to accounts outside your domains, allUsers included. This alert covers the projects that restriction does not reach. Grants inside your domains are for an investigation to judge.
How to undo it
terraform destroy removes the sinks, metrics, alerts, queries, and the Data Access setting. The log buckets are deleted after their pending-deletion period.
What it costs
Admin Activity logs are free. The metrics and alerts cost little. Data Access logs for Cloud Storage are billed at Cloud Logging's ingestion rate beyond the free monthly allowance, and a busy bucket produces a lot of them.
Terraform. The Audit service counted into metrics by caller, with alarms, and Object Storage read logs for bulk reads
What you need first
- Rights to create connectors, alarms, a notification topic, and policies in the tenancy root, and for Standard log groups and saved searches there.
- For bulk reads (Standard), the buckets that contain the data you most need to protect, with their compartments.
What it creates
- Six connectors reading the audit log of every compartment, counting matching events into three metrics with the caller as a dimension
- Three alarms. The first is a pre-authenticated request made, a bucket created or changed to public, or data copied or replicated to another region. The second is a policy, group membership, or dynamic group changed, a key moved compartment, or a credential made that works outside the console. The third is a log, connector, alarm, alarm suppression, notification topic or subscription, or retention rule changed, moved, or deleted.
- Named principals left out of each alarm, while the metrics keep them, and one notification per caller (Standard)
- Read logs for the named buckets, and an alarm when one principal reads more than a set number of objects in five minutes (Standard)
- A saved search behind every alarm (Standard)
See the four alerts this creates
Saved queries this installs
Standard and Hardened install these four, ready for the first hour of a case. Quick start installs none.
| Saved query | What it answers | Where to open it |
|---|---|---|
insider-shared-outside | The search behind the shared-outside alarm. | Logging, Saved searches, in the tenancy |
insider-rights-changed | The search behind the rights-changed alarm. | Logging, Saved searches, in the tenancy |
insider-logging-weakened | The search behind the logging-weakened alarm. | Logging, Saved searches, in the tenancy |
insider-bulk-read | Object reads on the sensitive buckets, by principal. Only when sensitive_buckets is set. | Logging, Saved searches, in the tenancy |
The code
Quick startReady
tenancy_ocid = "ocid1.tenancy.oc1..aaaaaaaa"main.tf, line 22region = "us-ashburn-1"main.tf, line 23alert_email = "security-alerts@example.com"main.tf, line 24
oci os ns get
Prints your Object Storage namespace, which proves ~/.oci/config works.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform destroy
When you have finished. If it refuses, How to undo it below explains why.
Formatting passedValid passedLint passed
Security scan: one check passed, and none flagged.
Last run 2026-11-12 with OpenTofu v1.12.6 against oracle/oci 9.8.0.
Open main.tf as plain text
StandardReady
tenancy_ocid. The tenancy. The connectors read its audit log, every compartment included, and the alarms live in its root.region. Home region identifier, such as us-ashburn-1.alert_emails. Addresses that receive the alarms. Prefer an on-call address over a person.
oci os ns get
Prints your Object Storage namespace, which proves ~/.oci/config works.# terraform.tfvars tenancy_ocid = "" region = "" alert_emails = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: one check passed, and none flagged.
Last run 2026-11-12 with OpenTofu v1.12.6 against oracle/oci 9.8.0.
Open main.tf as plain text
Open outputs.tf as plain text
Open queries.tf as plain text
Open reads.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
HardenedReady
tenancy_ocid. The tenancy. The connectors read its audit log, every compartment included, and the alarms live in its root.region. Home region identifier, such as us-ashburn-1.alert_emails. Addresses that receive the alarms. Prefer an on-call address over a person.
oci os ns get
Prints your Object Storage namespace, which proves ~/.oci/config works.# terraform.tfvars tenancy_ocid = "" region = "" alert_emails = ""
Create this file beside the others and fill in your values. Terraform reads it on its own.terraform init
Downloads the provider. Run it once per folder.terraform plan
Shows what will be created. Changes nothing. Read it.terraform apply
Shows the plan again and waits for you to type yes.terraform output verify
Prints the commands that prove it worked.
Formatting passedValid passedLint passed
Security scan: one check passed, and none flagged.
Last run 2026-11-12 with OpenTofu v1.12.6 against oracle/oci 9.8.0.
Open .checkov.yml as plain text
Open guard.yml as plain text
Open main.tf as plain text
Open outputs.tf as plain text
Open variables.tf as plain text
Open versions.tf as plain text
How to check it worked
Confirm the subscription email first. Then, on a test bucket, create a pre-authenticated request, and delete it. The shared-outside alarm emails within a few minutes.
Audit event names are the API operations' own names, and the connectors match them exactly. If an alarm stays quiet after a test, search the audit log for the call and read data.eventName; the Standard verify output says how.
The public-bucket detections read the bucket's new access type from the audit event's additional details, where Oracle's own connector examples read it, and match both public types.
A policy change is how decrypt rights change in Oracle Cloud, and policies change for many reasons. Name the pipeline that edits them as its job.
Oracle documents search, where, and, or, equality, and a wildcard inside a value for connector filters. It documents neither parentheses nor inequality there. A detection that needs an and is its own connector, and named principals are left out in the alarm's query.
Object Storage read logs carry no byte count, so a bulk download is counted in objects. Whether a connector posts one metric point per event or one per batch is not documented; read the metric after a test.
Connector Hub allows 20 connectors per region by default and five on a trial account. This template uses six, seven with bulk reads.
Deactivating the logging connector may stop it counting its own deactivation. Every connector is pinned active in Terraform, so the daily drift plan reports one switched off.
Whether Oracle names the caller on a read made through a pre-authenticated request is not documented. Such reads may count under an empty name, or not at all; the shared-outside alarm on making the request is the earlier warning.
Deleting the notification topic or the connectors' policy stops every alarm, and none of them can report it. The daily drift plan in Hardened is what notices.
Standard leaves one named principal out with != and several with !~ and a pipe between names, the forms Oracle documents. A name cannot contain a pipe or an asterisk, which Monitoring reads as patterns.
How to undo it
terraform destroy removes the connectors, alarms, topic, read logs, and saved searches. The Audit service keeps recording, for 365 days.
What it costs
Nothing for the Audit service, connectors, or alarms. Read logs are billed by Logging storage beyond the monthly free allowance, and a busy bucket produces a lot of them.
Good to know
- Alerts start an inquiry. Most will have an innocent explanation, and the investigation that follows should involve HR and Legal before anyone is confronted. The insider cases lesson covers how.
- Tune before you trust. Run the saved queries over a normal week first, name the pipeline identities that change policies as their job, and set the bulk read threshold from what you saw.
- The data perimeter template refuses copies to outside accounts. These alerts cover what a perimeter allows: sharing that goes through, reads by people entitled to read, and changes made by administrators.