Back to Terraform

AWS Governance: IAM Boundaries, Encryption, Logs and Cost Ownership

November 6, 2026 Wasil Zafar 23 min read

Combine supported security and telemetry resources with least privilege and accountable operational evidence

Table of Contents

  1. Separate Account Policies from Organization Guardrails
  2. Trace KMS, Secrets Manager and Workload Authorization
  3. Choose CloudWatch and Audit Signals for Real Failure Modes
  4. Make Tags, Budgets and Ownership Reviewable
  5. Review a Denial and a Missing-Telemetry Incident

Separate Account Policies from Organization Guardrails

Two teams, two blast radii. An account policy decides what a role in one account may do. An organization guardrail decides what every role in a set of accounts may ever do, and it lives in a different root with a different approver. Folding both into one Terraform stack means the team that ships a database can also widen the ceiling over production.

Only one of them grants. An identity policy or a resource policy grants permission. A service control policy never does — it removes permissions that would otherwise be granted, and it applies to IAM principals in member accounts, including each account's root user.

The management account is outside the fence. SCPs do not apply there, and they do not apply to service-linked roles. That is why the guardrail root and its state belong in the management account or a delegated administrator, not in a workload account the guardrail is meant to bound.

A denial can arrive from five places, and each names a different owner. Read the message before editing anything:

  • Identity policy deny — refuses that principal even when a resource policy would allow it.
  • Resource policy deny — refuses every principal the statement names, including one from another account.
  • Permissions boundary — caps one role or user; the identity policy may grant more than the boundary allows.
  • SCP — caps every principal in a member account, root user included, and ignores the management account.
  • RCP — caps resource-based access for the services that support it, so a bucket policy cannot widen past it.

Deny wins; allow must be unanimous. Any single deny is enough to block a call, while an allow must survive every layer. That asymmetry is why a deny-list SCP layered on the default FullAWSAccess policy is safer than an allow-list: the allow-list fails closed at whichever level someone forgot to edit.

Replacing FullAWSAccess is a service-wide decision. When the default allow policy is removed, every level from root to account needs an explicit allow for a service, and any OU without one blocks its accounts. The change is valid JSON, plans cleanly, and can take a whole class of workloads offline at apply time.

The attachment is the dangerous resource. aws_organizations_policy creates an inert document; aws_organizations_policy_attachment is what makes it live. Treat the attachment as the change that needs a named reviewer, a quiet window and a rollback already written down.

Test on one OU, not the root. AWS recommends moving accounts into a test OU one at a time instead of attaching to the root first. Service last-accessed data and CloudTrail show what an account actually calls, which turns a guess about impact into evidence.

Guardrails that earn their place are few. Deny leaving the organization, disabling the audit trail, using an unapproved region, and creating a root access key; protect the log archive account from every other account. Each one is a deny because none of them needs to grant anything.

The flow separates the layers a request crosses, and keeps the two bypasses visible.

Separate Account Policies from Organization Guardrails
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    R["Principal in a member account
IAM role or user"] --> S1{"SCP at the root
denies this action?"} S1 -->|"yes"| X1["AccessDenied
IAM is never reached"] S1 -->|"no"| S2{"Every level below
has an explicit allow?"} S2 -->|"no"| X2["AccessDenied
implicit deny from a missing allow"] S2 -->|"yes"| B{"Permissions boundary
allows the action?"} B -->|"no"| X3["AccessDenied
the boundary caps the role"] B -->|"yes"| P{"Identity policy or
resource policy allows?"} P -->|"no"| X4["AccessDenied
no grant exists anywhere"] P -->|"yes"| OK["Action allowed"] M["Management account
principal"] -.->|"SCPs do not apply"| P E["Principal outside
the organization"] -.->|"resource policy decides,
the resource account SCP does not"| P classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class R,S1,S2 primary; class B,P secondary; class OK ok; class X1,X2,X3,X4 danger; class M,E warn;

Read the diagram as an intersection, not a sequence. The order explains which service logs the failure first, but the decision is the smallest permission set every layer accepts. Adding a grant to the identity policy changes nothing while a boundary or an SCP still refuses it.

Organization guardrails, account policies and the decision they share The organization root holds service control and resource control policies, which attach to organizational units and then to a member account. Inside the account, identity policies, permissions boundaries, trust policies and resource policies decide access. The management account is drawn outside the SCP boundary as the recovery owner. Effective permission is the smallest set every layer allows, and any deny ends the request. Five layers, one decision Any deny wins. An allow has to survive every layer above it. Organization root: SCP and RCP an allow must exist at every level below; one deny ends the request Management account outside the SCP recovery owner here Workloads OU deny list on top of FullAWSAccess Sandbox OU allow list tested here first Member account: the account team's boundary identity policies, permissions boundaries, role trust, resource policies Principal: role or user the trust policy decides who may assume it Resource policy: bucket, key, secret it names a principal, not a team or an OU Effective permission is the smallest set every layer allows. A deny anywhere ends the request. Write the management-account recovery owner into the runbook before the first attachment, not after the first lockout.

Keep the guardrail root small. It should own policies, attachments and the audit trail — nothing that serves traffic. A guardrail stack that also deploys workloads inherits their review cadence, and a routine application change becomes a change to the ceiling over every account.

Trace KMS, Secrets Manager and Workload Authorization

A secret read is two authorizations, not one. Secrets Manager decides whether the caller may call GetSecretValue; KMS decides whether the same caller may decrypt the payload. A role can pass the first check and fail the second, and the second failure names KMS rather than the secret.

The key policy is not a formality. Unlike most resource policies, a KMS key policy does not grant the account anything by default. If you replace it, keep a statement that lets the account delegate through IAM, or every IAM allow on the key becomes ineffective while IAM denies still apply.

Separate the administrator from the user. A key administrator can change the policy and create grants, which is equivalent to granting themselves use. A workload needs Encrypt, Decrypt, GenerateDataKey and DescribeKey at most, ideally narrowed with a kms:ViaService condition so the key is only usable through Secrets Manager in the expected region.

Grants are the service path. Many AWS services take a grant rather than a policy statement, created by a principal holding kms:CreateGrant under the kms:GrantIsForAWSResource condition. Revoking a grant is faster than editing a key policy, and it is also easier to leave behind during an incident review.

The container and the value are separate resources. aws_secretsmanager_secret holds the name, encryption key, recovery window and resource policy; aws_secretsmanager_secret_version holds the bytes. Only the version carries the secret, and it stores the value in state.

Read-back is the assumption to avoid. A data source that fetches the current version writes the plaintext into state on every refresh, and a saved plan can carry it. Let the rotation function own the value and pass the ARN to consumers; keep Terraform as the owner of the container, the policy and the schedule.

Rotation is a change with a deadline. Enabling aws_secretsmanager_secret_rotation rotates the secret once immediately, so any consumer still reading a cached credential breaks at that moment. Update consumers to fetch at runtime before you enable the schedule, not after the first alarm.

Deletion has a window and a name lock. The default recovery window is 30 days; during it the name stays reserved and creating a replacement fails. A zero-day window deletes immediately and irreversibly, which is a decision for a disposable lab only.

Cross-account reads need three grants. The caller's identity policy must allow the read, the secret's resource policy must name the caller, and the key policy must allow the caller to decrypt. A green apply on the secret says nothing about the third.

Prove the chain as the workload. Call the API with the workload role, not an administrator, and record the version stage and version ID rather than the value. A describe call that shows rotation enabled is configuration evidence; a successful read as the role is authorization evidence.

Figure 2 follows one call and keeps the failure branches attached to the layer that produces them.

Trace KMS, Secrets Manager and Workload Authorization
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','signalColor':'#5a6e82','noteBkgColor':'#c4873b','noteTextColor':'#132440','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    W["Workload role
task, function or pod"] --> G["GetSecretValue
secret ARN"] G --> A{"Secrets Manager
authorizes the caller?"} A -->|"no"| F1["AccessDeniedException
from secretsmanager"] A -->|"yes"| K{"Key policy or grant
allows Decrypt?"} K -->|"no"| F2["AccessDeniedException
from kms, after the first allow"] K -->|"yes"| V{"AWSCURRENT
version exists?"} V -->|"no"| F3["ResourceNotFoundException
or only AWSPENDING"] V -->|"yes"| S["SecretString returned
never logged or printed"] S --> C["Consumer connects
with the credential"] C -.->|"rotation enables and
runs once immediately"| F4["Old cached credential rejected
consumer was not updated"] classDef primary fill:#132440,color:#ffffff,stroke:#0b172b; classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a; classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f; classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420; classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f; class W,G,A,K,V primary; class S,C secondary; class F1,F2,F3 danger; class F4 warn;

The second denial is the one teams misread. A KMS error arrives after Secrets Manager has authorized the call, so editing the secret policy cannot fix it. The key policy, the caller's decrypt grant and the key's enabled state are the three things to check, in that order.

Choose CloudWatch and Audit Signals for Real Failure Modes

Start from the failure, not from the service list. "Who changed this?" is CloudTrail. "Did the request fail?" is a log line or a metric. "Is this resource still compliant?" is AWS Config. "Is there traffic I did not expect?" is VPC Flow Logs. One trail and one log group will not answer all four.

The audit trail is an organization resource. An organization trail is created in the management account or a delegated administrator, appears in every member account, and cannot be modified from a member account. Setting is_organization_trail is a management-account change; members can read its validation status but cannot repair it.

Trail creation succeeds even when delivery is broken. CloudTrail creates the member-account copy even if the bucket policy, log group, SNS topic or KMS grant is wrong. The apply is evidence that the API accepted a definition, not that an event reached storage; the trail's delivery status is the evidence that matters.

Event history is not the trail. The console's event history holds 90 days for the account you are signed in to. It answers a single-account question and is useless as an organization-wide record.

Log groups expire only if you say so. A log group has no retention by default, so a verbose application bills forever. Set retention_in_days on the group Terraform owns, and create the group before the service does, or the service creates an unmanaged twin with a different policy.

Silence needs a decision. An alarm's treat_missing_data setting decides what no data means: breaching for a metric that must always report, such as a delivery heartbeat; notBreaching for a sparse error metric that only exists when something failed. The default, missing, ends in a state that pages nobody.

An alarm action is not a delivered page. CloudWatch does not validate the SNS topic, the subscription or the endpoint, and an email subscription stays pending until a human confirms it. A perfect alarm graph can notify an empty room.

Config has a switch of its own. Creating the recorder and delivery channel does not start recording; aws_config_configuration_recorder_status enables it. A recorder that exists but is stopped is the most common form of "we have Config" that does not.

Retention and volume are the cost knobs. Management events are small; data events on busy buckets and functions are not. Keep the audit trail long, keep debug logs short, and archive rather than delete when a retention obligation exists.

The table pairs each failure mode with the signal that answers it and the check that proves delivery.

Failure modeSignal that answers itWhy the apply is not proofIndependent check
Who changed a role or policyCloudTrail management eventthe trail exists even when delivery validation failslatest delivery time plus one known event in the bucket
A workload cannot decryptKMS denial in CloudTrail and service logssecret and key apply as separate resourcesread as the workload role and record the error
No logs from a servicelog group and metric filterthe service may create its own grouplist groups and compare names, retention and key
An alarm never firesmetric alarm statemissing data defaults to insufficient dataforce the alarm state and confirm the notification
Configuration driftAWS Config rulethe recorder can exist while stoppedrecorder status plus a compliance result
Unexpected egressVPC Flow Logsthe destination may be unreadable by the reviewerquery one known connection end to end

Read the third column as a review question. If the evidence for a row is "the plan was empty", the row has no evidence. The check column names something an operator can repeat next month without trusting the pipeline that produced the change.

Make Tags, Budgets and Ownership Reviewable

A tag has three jobs and three activation paths. It can allocate cost, drive attribute-based access, or name an owner. Cost allocation needs explicit activation, access needs a policy condition, and ownership needs a report someone reads. A tag doing none of these is decoration with a bill.

Apply tags at the provider, then verify the union. The provider's default_tags block covers most taggable resources, per-resource tags win on a key collision, and tags_all is the effective set. The autoscaling group is the known exception in this provider version, so a compliance query must read the resource rather than the provider block.

Cost allocation is a separate switch. aws_ce_cost_allocation_tag with status Active is what makes a key appear in cost reports, and a new key can take up to a day to show up. Tagging every resource and activating the key are two changes with two owners, which is why "we tag everything" and "we can see cost by team" are different claims.

Budgets are lagging by design. AWS updates budget data up to three times a day, typically 8 to 12 hours apart, and billing itself lags usage. A forecast notification can arrive after the spend it warns about; treat it as a review trigger, not a brake.

A budget filter is only as good as the tag. A tag filter uses TagKeyValue with a dollar sign between key and value, and the newer filter expression can combine a tag with a service or account. A budget on the whole account tells finance that something happened; a budget on one owner tells that owner.

Notification and enforcement are different resources. A notification sends a message. aws_budgets_budget_action can apply an IAM deny policy or an SCP, or stop EC2 and RDS instances, either automatically or after approval. Only the second changes what the account can do, and it arrives after the threshold.

Enforcement can be worse than the overspend. An automatic SCP at the limit can block the remediation that would fix the cost, and an automatic instance stop can take down the service that pays for itself. Use manual approval for the first quarter of any action, and name the approver.

Ownership is a review, not a label. Keep a small required set: owner, environment, service and cost centre. Query it monthly, publish untagged spend as its own line, and give each resource class one accountable person rather than a distribution list.

Tag policies standardize; they do not enforce. An Organizations tag policy normalizes key casing and allowed values and reports noncompliance. If a tag must exist at creation, that is an SCP condition on the request tag — and it only works for APIs that accept tags in the create call.

Figure 3 contrasts a tag that exists with a cost that is allocated, owned and reviewed.

A tag applied but not allocated compared with an activated, filtered and owned cost The left panel shows an owner tag applied by a module, a cost allocation key left inactive, an account-wide budget and a forecast email to a shared inbox, ending in a real bill with no name attached. The right panel shows an active cost allocation key, a budget filtered by owner tag, a notification to the owner topic and a manual-approval budget action, ending in a monthly review where the owner has the number. A footer notes that budgets refresh up to three times a day and only a budget action changes what the account can do. Two ways to own a bill The tag is the easy part. Activation, filtering and a named owner are the work. Tagged, not allocated owner tag applied by a module cost allocation key never activated budget covers the whole account forecast email to a shared inbox no one can name the spender Month end: the bill is real, the owner is not. The tag exists in the console. activate filter own Allocated and reviewable cost allocation key active budget filtered by the owner tag notification to the owner topic budget action on manual approval monthly untagged-spend review Month end: the owner has the number. The report has a reader. Budgets refresh up to three times a day. A notification is a lagging signal, not a cap. Only a budget action changes what the account can do, and it arrives after the threshold.

The left column is a common false comfort. Tagging is visible in the console within minutes, while activation, filtering and reporting each lag behind it. A review that only checks whether the tag exists confirms the cheapest part of the design.

Review a Denial and a Missing-Telemetry Incident

Two incidents, one method. Read the error before changing a policy; read the delivery path before adding an alarm. Both exercises run in a disposable account, deny only a harmless action, and leave the production trail, key and budget untouched.

Preserve a recovery owner first. The management account is the escape hatch for an SCP mistake, and an out-of-band contact is the escape hatch for a broken alert path. Write both names into the lab record before the first apply, and confirm the second person can actually sign in.

Lab

Review a Denial and a Missing-Telemetry Incident

Execution status: design-only. These steps were not run against a live account. Use a disposable sandbox and a dedicated OU, keep the transcripts, and treat the evidence as yours rather than a transcript.

Prerequisites. Terraform 1.17.1 with provider 6.72.0, a sandbox account, a test bucket with one small object, an SNS topic with one confirmed subscription, and permission to manage IAM policies, alarms and log groups. The SCP step needs the management account; if you do not have it, stop after step 2 and record that boundary in the evidence.

  1. Create a sandbox role whose identity policy allows listing the bucket but not reading the object. Assume the role, request the object, and record the exact error, the request ID and the time. Expect a denial that names the role and the action.
  2. Add the read action, apply, and repeat the request. Expect the object to return. This proves the identity policy was the only gate in the first attempt.
  3. Attach a deny for the same read to the sandbox OU only, after confirming the OU contains exactly the test account and nothing else. Repeat the read as the same role. Expect a denial even though the identity policy allows the action, and confirm the call appears in CloudTrail.
  4. Detach the SCP, confirm the read works again, and keep both transcripts. This is the evidence that the guardrail, not the role, made the decision.
  5. Create a log group with one day of retention, a metric filter that matches a string you never log, and an alarm with the default missing-data setting. Send no matching line and wait past the evaluation periods. Expect insufficient data and no notification.
  6. Change the alarm to treat missing data as breaching and wait again. Expect an alarm state, and a notification only if the subscription is confirmed. Check the subscription before concluding the alarm is broken.
  7. Use set-alarm-state for one evaluation period to test the action path without waiting. Confirm the message arrived, then let the alarm return to its real state.
  8. Destroy in order: alarm, metric filter, log group, SCP attachment if it remains, role policy, role. Run a final plan and confirm the production trail, key and budget are unchanged.
CheckEvidencePass looks like
Identity denialerror text and request IDdenial names the role and the read action
Guardrail denialsame call after the SCP attachesdenied while the identity policy still allows
Guardrail removalrepeat after detachthe same call succeeds again
Silent alarmalarm state before the setting changeinsufficient data with no notification
Delivery proofalarm state and confirmed subscriptiona message arrives at a human endpoint

Expected observation. The first read fails on the identity policy, the second succeeds, and the third fails again under the SCP with the identity policy unchanged. The silent alarm reports insufficient data, then alarms once missing data is treated as breaching. The SNS message arrives only after the subscription is confirmed, which is the point of the exercise rather than a side note.

Failure checks. If the SCP changes nothing, the role may be in another account, the attachment may point at the wrong OU, or the call may be served by a service-linked role. If the alarm never changes state, the metric filter may be attached to a different log group than the one receiving events.

SymptomLikely layerNext check
Denied despite an allowboundary, SCP or RCPread the full error and the policy type it names
Secret read fails on decryptKMS key policy or granttest as the workload role, not an administrator
Alarm stays insufficientmissing-data setting or filterconfirm the filter matches a real log line
Alarm fires, nobody is pagedSNS subscription or endpointconfirm the subscription and send a test message
Nothing in CloudTrailtrail delivery or regioncheck delivery status and the trail home region

Cost dimensions. The lab is close to free: a few API calls, one short-lived log group and one SNS message. Keeping the log group without retention, or leaving data events enabled on a busy bucket, is where a test starts to cost money.

Cleanup. Delete the test object, remove the alarm, filter and log group, detach and delete the SCP if it was created for the lab, then remove the role and its policies. Run a final plan and confirm the production trail still delivers and the production budget still has its owner.

References (checked 6 November 2026): service control policies, SCP evaluation, resource control policies, default KMS key policy, Secrets Manager rotation, organization trails, CloudWatch missing data, AWS Budgets, budget actions, cost allocation tags, organizations policy, KMS key, secret rotation, CloudTrail, budget, cost allocation tag.

Next in the Series

In Operate the AWS Provider: Imports, Upgrades, Drift and Team Delivery, we'll explore Maintain AWS roots through provider changes and partial failures with resource-specific evidence.