cloud-nuke uses a YAML config file for granular resource filtering. The top-level keys are resource types (use the config key column from the config support matrix). See the examples folder for more reference.
cloud-nuke aws --config path/to/file.yamlEach resource type supports include and/or exclude rules:
S3:
include:
names_regex:
- ^alb-.*-access-logs$
exclude:
names_regex:
- publicMatch resources by name using regular expressions.
S3:
include:
names_regex:
- ^alb-.*-access-logs$
- .*-prod-alb-.*
exclude:
names_regex:
- public
- prodFiltering is commutative — include and exclude filters can be applied in any order with the same result. In the example above, buckets matching ^alb-.*-access-logs$ are included unless they also match public or prod.
Filter resources by creation time.
S3:
include:
time_after: '2020-01-01T00:00:00Z'S3:
include:
time_before: '2020-01-01T00:00:00Z'Filter resources by AWS tags. Tag names are case-sensitive; tag values are lowercased before regex matching.
EC2:
include:
tags:
Environment: "test"
Owner: "dev-team"
tags_operator: "OR" # Include if ANY tag matches (default)SecurityGroup:
exclude:
tags:
Team: ".*"
Service: ".*"
tags_operator: "AND" # Exclude only if ALL tags presentThe tags_operator field supports AND and OR (case-insensitive). Default is OR.
This is useful for tagging enforcement — the example above nukes resources missing either required tag while keeping properly-tagged resources safe.
Set per-resource-type execution timeout:
S3:
timeout: 10mTime-based protection using the cloud-nuke-after tag. This feature is enabled globally by default — all resources with a valid cloud-nuke-after tag and a future timestamp are automatically protected from deletion.
To protect a resource, tag it with cloud-nuke-after and an RFC 3339 timestamp:
cloud-nuke-after = 2026-06-01T00:00:00Z
The resource will be excluded from deletion until after 2026-06-01T00:00:00Z. Once the timestamp passes, the resource becomes eligible for deletion again.
Note: This only works for resources that support tag-based filtering (see the
tagscolumn in the config support matrix). Resources without tag support cannot be protected this way.
Limit operations to AWS-managed default resources (e.g., default VPC, default security group, default subnets). This applies only to EC2 resource types: EC2Endpoint, EC2Subnet, NATGateway, VPC, InternetGateway, NetworkInterface, SecurityGroup, and RouteTable.
VPC:
default_only: trueThis is primarily used by the defaults-aws command, which sets it automatically. When set in a config file, only default resources of that type will be targeted.
For KMS customer-managed keys, controls whether keys without aliases are included. By default, unaliased keys are excluded to avoid accidentally deleting keys that may be in use but unnamed. Can also be set via the --list-unaliased-kms-keys or --delete-unaliased-kms-keys CLI flags.
KMSCustomerKeys:
include_unaliased_keys: trueResources tagged with cloud-nuke-excluded = true are excluded from deletion. The tag value must be "true" (case-insensitive) — an empty value or other values like "false" will not trigger exclusion.