Repository navigation
feat(infra): scoped read-only CloudTrail data events on the prod lake - #946
Merged
Merged
Conversation
Contributor
terraform plan
Warning This plan DESTROYS resources in: core. Merging applies it unattended. core — 0 to add, 1 to change, 2 to DESTROYdata.aws_iam_policy_document.ci_tf_plan_state: Reading...
data.aws_iam_policy_document.ci_tf_plan_state: Read complete after 0s [id=2883378100]
data.aws_iam_policy_document.ci_tf_drift_refresh: Reading...
data.aws_caller_identity.current: Reading...
data.aws_iam_policy_document.ci_tf_drift_refresh: Read complete after 0s [id=2350222434]
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Reading...
module.identity_center.data.aws_ssoadmin_instances.this: Reading...
data.aws_iam_policy_document.ci_tf_apply_no_prod_state: Read complete after 0s [id=2395007408]
module.github_oidc.data.aws_iam_policy_document.trust: Reading...
data.aws_iam_policy_document.obs_pod_trust: Reading...
module.github_oidc.data.aws_iam_policy_document.trust: Read complete after 0s [id=4060172364]
data.aws_iam_policy_document.cur_delivery: Reading...
data.aws_iam_policy_document.obs_pod_trust: Read complete after 0s [id=819195744]
data.aws_iam_policy_document.cur_delivery: Read complete after 0s [id=2207400467]
data.aws_iam_policy_document.openobserve: Reading...
data.aws_iam_policy_document.openobserve: Read complete after 0s [id=2662704728]
data.aws_iam_policy_document.config_bucket: Reading...
data.aws_iam_policy_document.config_bucket: Read complete after 0s [id=4067691321]
data.aws_iam_policy_document.ci_tf_apply_trust: Reading...
data.aws_iam_policy_document.sccache_trust_read: Reading...
data.aws_iam_policy_document.ci_tf_plan_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_trust: Read complete after 0s [id=2538345208]
data.aws_iam_policy_document.sccache_trust_read: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.ci_tf_plan_trust: Read complete after 0s [id=1630650595]
data.aws_iam_policy_document.sccache_trust_write: Reading...
data.aws_iam_policy_document.ci_tf_drift_trust: Reading...
data.aws_iam_policy_document.ci_tf_drift_trust: Read complete after 0s [id=2357770959]
data.aws_iam_policy_document.sccache_write: Reading...
data.aws_iam_policy_document.sccache_trust_write: Read complete after 0s [id=4060172364]
data.aws_caller_identity.current: Read complete after 0s [id=797781631727]
data.aws_iam_policy_document.sccache_read: Reading...
data.aws_iam_policy_document.sccache_write: Read complete after 0s [id=786296009]
module.github_oidc.data.aws_iam_policy_document.push: Reading...
data.aws_iam_policy_document.sccache_read: Read complete after 0s [id=2701062528]
module.github_oidc.data.aws_iam_policy_document.push: Read complete after 0s [id=2177873069]
data.aws_iam_policy_document.audit_bucket: Reading...
data.aws_iam_policy_document.audit_bucket: Read complete after 0s [id=3031279952]
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Reading...
data.aws_iam_policy_document.ci_tf_apply_prod_trust: Read complete after 0s [id=3513372776]
module.identity_center.data.aws_ssoadmin_instances.this: Read complete after 1s [id=us-east-2]
module.identity_center.data.aws_identitystore_user.admin: Reading...
module.identity_center.data.aws_identitystore_user.admin: Read complete after 0s [id=b17b2500-e0b1-7046-405b-23c088cf392b]
Terraform used the selected providers to generate the following execution
plan. Resource actions are indicated with the following symbols:
~ update in-place
- destroy
Terraform will perform the following actions:
# aws_cloudtrail.org will be updated in-place
~ resource "aws_cloudtrail" "org" {
id = "arn:aws:cloudtrail:us-east-2:797781631727:trail/er-org-trail"
name = "er-org-trail"
tags = {}
# (16 unchanged attributes hidden)
+ event_selector {
+ include_management_events = true
+ read_write_type = "ReadOnly"
+ data_resource {
+ type = "AWS::S3::Object"
+ values = [
+ "arn:aws:s3:::er-prod-lake-797781631727/",
]
}
}
}
# cloudflare_r2_bucket.sccache[0] will be destroyed
# (because index [0] is out of range for count)
- resource "cloudflare_r2_bucket" "sccache" {
- account_id = "9eefbe6bc92d11b2bb4e962494765a4c" -> null
- creation_date = "2026-11-08T20:59:18.644Z" -> null
- id = "er-ci-sccache" -> null
- jurisdiction = "default" -> null
- location = "ENAM" -> null
- name = "er-ci-sccache" -> null
- storage_class = "Standard" -> null
}
# cloudflare_r2_bucket_lifecycle.sccache[0] will be destroyed
# (because index [0] is out of range for count)
- resource "cloudflare_r2_bucket_lifecycle" "sccache" {
- account_id = "9eefbe6bc92d11b2bb4e962494765a4c" -> null
- bucket_name = "er-ci-sccache" -> null
- jurisdiction = "default" -> null
- rules = [
- {
- abort_multipart_uploads_transition = {
- condition = {
- max_age = 86400 -> null
- type = "Age" -> null
} -> null
} -> null
- conditions = {
# (1 unchanged attribute hidden)
} -> null
- delete_objects_transition = {
- condition = {
- max_age = 1209600 -> null
- type = "Age" -> null
} -> null
} -> null
- enabled = true -> null
- id = "expire-cache-objects" -> null
},
] -> null
}
Plan: 0 to add, 1 to change, 2 to destroy.
Changes to Outputs:
- r2_sccache_bucket = "er-ci-sccache" -> null
- r2_sccache_endpoint = "https://9eefbe6bc92d11b2bb4e962494765a4c.r2.cloudflarestorage.com" -> null
Warning: Resource Destruction Considerations
with cloudflare_r2_bucket_lifecycle.sccache[0],
on r2.tf line 96, in resource "cloudflare_r2_bucket_lifecycle" "sccache":
96: resource "cloudflare_r2_bucket_lifecycle" "sccache" {
Applying this resource destruction will remove the resource from the
Terraform state but will not change it in the API. If you would like to
destroy or reset this resource in the API, refer to the documentation for how
to do it manually.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #554
What
One
event_selectoron the account's one trail (aws_cloudtrail.org,envs/core/audit.tf):ReadOnlydata events onAWS::S3::Object, scoped to the constructed prod-lake ARN, withinclude_management_events = truestated explicitly so the trail's management coverage cannot change by omission.Why
§3.2's audit trail for the prod data plane: a read on the prod prefix must produce an event, a write must not, and a nonprod-bucket read must not. Writes are the engine's steady-state parquet churn at per-100k data-event pricing; reads are the exfiltration signal. Volume is near-zero until the engine's
s3://lake path lands. The ARN is constructed as a string because core cannot reference an envs/prod resource — the plan-safe pattern this repo already uses cross-stack; a wrong bucket surfaces as "no events arrive", which the probes then catch.Proof
terraform validateon envs/core — Success (1.11.4);terraform fmt -checkclean;tf-static-credentials-check.shclean. Lifecycle readback, run against the live bucket now (aws s3api get-bucket-lifecycle-configuration --bucket er-prod-lake-797781631727):noncurrent-expiryEnabled, NoncurrentDays 30, AbortIncompleteMultipartUpload 7 — the issue's third checkbox, already satisfied by the lake module and verified from the API.Risk & rollback
Risk: the selector could silently log nothing if the ARN were wrong — the post-merge probes exist precisely to catch that. Rollback:
git revert <merge-sha>; removing the selector restores management-only logging.Post-merge ledger
Closed by: agent · codex session on
Athvins-MacBook-Pro· 2026-11-09T01:35:00Zmainis green with this change on it — mergeb0c55d74; rust run 42543569780 success, frontend 42543569764 success, devcontainer 42543569769 success, infra 42543569816 success.imagescorrectly never ran — a terraform-only merge matches none of images.yml's push paths, and no images run exists forb0c55d74.deployn/a by the same mechanism — deploy is reachable only through images'workflow_run(deploy.yml header), and images never ran.1 to change; the destroy guard passed with noALLOW-DESTROYbecause the apply tier setsTF_VAR_cloudflare_account_idand the R2 pair's DESTROY is a plan-tier artifact of the opt-in. Last scheduled drift run 42453080846 green (daily 06:02Z cadence).Closes.lookup-events; only the delivered log files carry them. (2) A selector change has a capture gap — round 1 at +1m45s after the apply never appeared, so probes must run afterget-event-selectorsconfirms, or an absent event is ambiguous.Specific to this change
get-objecton.cloudtrail-probe/probe2.txtat 01:22:28Z appears asGetObjectat 01:22:29Z in...T0130Z_GaEj7tqlPWWv0xA6.json.gz, principaldupezone, resources = the prod lake bucket + object ARN.put-object(01:22:27Z) is absent from that same delivered file, and zeroPutObject/DeleteObjectevents exist across all seven delivered files (00:45Z-01:30Z). Object-level scan: exactly ONE data event in the whole trail — the probe-1 GetObject.get-objecton er-dev-lake (01:09:13Z and 01:22:29Z, both NoSuchKey) andlist-objects-v2(01:08:54Z) are all absent; the dev bucket appears only as management-planeGetBucket*calls from the drift workflow, which are global by design, not data events.get-bucket-lifecycle-configurationoner-prod-lake-797781631727→noncurrent-expiryEnabled, NoncurrentDays 30, AbortIncompleteMultipartUpload 7.Context — plan, discoveries, measurements, files
Plan
aws_cloudtrail.org. 2. Validate + gates. 3. On merge, watch the core apply. 4. Run the three §3.2 probes against delivered logs (data events are not inlookup-events; allow for delivery lag). 5. Lifecycle readback — DONE, pre-merge (below).Discoveries
modules/lake/main.tf) already declares exactly the lifecycle §3.2 asks for, so that checkbox is a readback, not a change.event_selectorwithinclude_management_events = truekeeps that coverage verbatim.aws cloudtrail lookup-events; the probes must read the delivered log files iner-audit-archive-797781631727.Measurements
aws s3api get-bucket-lifecycle-configuration --bucket er-prod-lake-797781631727→ NoncurrentDays 30, DaysAfterInitiation 7 (2026-11-09).terraform -chdir=infra/terraform/envs/core validate→ Success.Files
infra/terraform/envs/core/audit.tf— the selector, with the why.