# IAM policy: deny deleting critical resources

IAM policy examples · Updated 17 November 2026

**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.

## 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 to | Protects against | Weakness |
|---|---|---|
| Users, groups or roles (IAM policy) | Accidents | Anyone with IAM rights can detach it |
| [Permissions boundary](https://cloudconsole.dev/iam/permissions-boundary) | Delegated admins | Only for principals that have the boundary |
| SCP on the account | Everyone in the account, including admins | Not 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](https://cloudconsole.dev/how-to/enable-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 CloudConsole app](https://cloudconsole.dev/aws-console-app) · [Download on the App Store](https://apps.apple.com/app/cloudconsole-for-aws/id6835419710)

## Sources

- [Policy evaluation logic](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html)
- [Example IAM identity-based policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_examples.html)

## Related

- [IAM permissions boundary: let developers create roles safely](https://cloudconsole.dev/iam/permissions-boundary)
- [SCP: deny leaving the organisation](https://cloudconsole.dev/iam/scp-deny-leave-organization)
- [How to enable termination protection on EC2](https://cloudconsole.dev/how-to/enable-ec2-termination-protection)
- [How to find who deleted a resource in AWS](https://cloudconsole.dev/how-to/find-who-deleted-aws-resource)
- [AccessDeniedException: User is not authorized to perform this action because no identity-based policy allows it](https://cloudconsole.dev/errors/accessdenied-no-identity-based-policy-allows)
- [ABAC: tag-based access control policy example](https://cloudconsole.dev/iam/abac-tags)

---

Source: https://cloudconsole.dev/iam/deny-delete

CloudConsole is an independent iPhone and Android app for Amazon Web Services by Cloudconcur Ltd. It is not affiliated with Amazon Web Services.
