CloudConsole

IAM policy: deny deleting critical resources

Updated 17 November 2026 · How we write and check guides

Short answer

Attach an explicit Deny for the delete actions (dynamodb:DeleteTable, s3:DeleteBucket, rds:DeleteDBInstance and so on) on the specific resource ARNs. An explicit deny overrides every allow, including AdministratorAccess. Put it in an SCP or permissions boundary if the people it protects against can edit IAM.

Policy diagram: 1 statement(s); first Deny dynamodb:DeleteTable, dynamodb:DeleteBackup… on dynamodb: table/orders
The policy on this page drawn statement by statement: who it applies to, the actions, the resources and any condition.

The policy

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ProtectProductionData",
      "Effect": "Deny",
      "Action": [
        "dynamodb:DeleteTable",
        "dynamodb:DeleteBackup",
        "s3:DeleteBucket",
        "s3:DeleteBucketPolicy",
        "rds:DeleteDBInstance",
        "rds:DeleteDBCluster"
      ],
      "Resource": [
        "arn:aws:dynamodb:eu-west-2:123456789012:table/orders",
        "arn:aws:dynamodb:eu-west-2:123456789012:table/orders/backup/*",
        "arn:aws:s3:::my-bucket",
        "arn:aws:rds:eu-west-2:123456789012:db:orders-prod",
        "arn:aws:rds:eu-west-2:123456789012:cluster:orders-prod"
      ],
      "Condition": {
        "ArnNotLike": {
          "aws:PrincipalArn": "arn:aws:iam::123456789012:role/BreakGlass"
        }
      }
    }
  ]
}

How it works

IAM evaluates every applicable policy. If any statement denies the request, it is denied, regardless of how many allows match. That is why this works against admins.

  • Action lists only deletions. Everything else these principals may do is unaffected.
  • Resource names the protected resources exactly. A DynamoDB backup's ARN sits under its table; S3 buckets have no region or account in their ARN.
  • ArnNotLike on aws:PrincipalArn exempts a break-glass role, so you can still delete in a planned, logged way.

Where to attach it

Attach toProtects againstWeakness
Users, groups or roles (IAM policy)AccidentsAnyone with IAM rights can detach it
Permissions boundaryDelegated adminsOnly for principals that have the boundary
SCP on the accountEveryone in the account, including adminsNot the management account; needs Organizations
aws iam create-policy --policy-name protect-production-data \
  --policy-document file://deny-delete.json
aws iam attach-group-policy --group-name admins \
  --policy-arn arn:aws:iam::123456789012:policy/protect-production-data

Pair it with built-in protection

  • DynamoDB: turn on deletion protection on the table.
  • RDS: turn on deletion protection on the instance or cluster.
  • EC2: termination protection.
  • S3 objects: versioning plus Object Lock if deletes must be impossible for a period. Denying s3:DeleteObject in IAM still leaves lifecycle rules able to expire objects.
  • CloudFormation: DeletionPolicy: Retain and stack termination protection.

Switching deletion protection off is an ordinary modify call (rds:ModifyDBInstance, dynamodb:UpdateTable), which is too broad to deny outright, so the IAM deny above remains the backstop.

Test that the deny works

aws iam simulate-principal-policy \
  --policy-source-arn arn:aws:iam::123456789012:role/Admin \
  --action-names dynamodb:DeleteTable \
  --resource-arns arn:aws:dynamodb:eu-west-2:123456789012:table/orders

The result should be explicitDeny with the matched statement listed. The simulator evaluates identity policies and permissions boundaries, but not SCPs, so test an SCP version in a sandbox account instead.

Common mistakes

  • Using NotAction in a Deny by accident: "NotAction": "s3:DeleteBucket" denies everything except deleting the bucket.
  • Protecting the table but not its replicas in a global table: each region's ARN is separate.
  • Forgetting deletion via CloudFormation: stacks act with your credentials or a service role. A deny on the user doesn't stop a stack service role from deleting the resource.

Questions

Does an explicit Deny override AdministratorAccess?

Yes. An explicit Deny in any applicable policy always wins over Allows, whichever policy grants them.

How do I deny all actions except a few?

Use a Deny with NotAction listing the actions to keep. Be careful: it denies every other action, including ones you didn't think of.

When this happens away from your desk

A deny guard is what makes it reasonable to carry production access on a phone at all. CloudConsole is being built with its own production guardrails as well, but the IAM deny is the one AWS enforces.

About the app → · Download on the App Store

Sources