if I apply a tag of cloud-nuke-excluded to an IAM user (or any tag of my choice and configured in the config.yaml file), the user does not get excluded from a cleanup
If I use the aws cli I can see the user (the user is mine):
If I run cloud-nuke aws in dry run the user is still going to be nuked:
$ cat config.yaml
IAMUsers:
excluded:
tag: "cloud-nuke-excluded"
$ cloud-nuke aws --dry-run --region global --config config.yaml --resource-type iam
# AWS Resource Query Parameters
┌──────────────────────────────────┐
| Query Parameter | Value |
| -------------------------------- |
| Target Regions | global |
| Target Resource Types | iam |
| List Unaliased KMS Keys | false |
└──────────────────────────────────┘
INFO Found 17 iam resources in global
INFO Done searching for resources
INFO Found total of 17 resources
# Found AWS Resources
┌─────────────────────────────────────────────────────┐
| Resource Type | Region | Identifier | Nukable |
| --------------------------------------------------- |
<REDACTED>
| iam | global | jonathan.harden | - |
<REDACTED>
└─────────────────────────────────────────────────────┘
I believe the problem is the AWS API does not return tags on a list users called (in spite of the documentation), see the same issue being reported in boto3 https://github.com/boto/boto3/issues/1855. As such calling user.Tags in the context of a ListUsersOutput always returns an empty array.
if I apply a tag of
cloud-nuke-excluded
to an IAM user (or any tag of my choice and configured in the config.yaml file), the user does not get excluded from a cleanupIf I use the aws cli I can see the user (the user is mine):
and if I run get-user I can see the tags:
If I run
cloud-nuke aws
in dry run the user is still going to be nuked:To investigate this further I did a local build of cloud-nuke with some additional logging in where the user is retrieved and their tags used:
The output from that shows my user, but shows there are no Tags returned from the ListUsers command
I believe the problem is the AWS API does not return tags on a list users called (in spite of the documentation), see the same issue being reported in boto3 https://github.com/boto/boto3/issues/1855. As such calling user.Tags in the context of a ListUsersOutput always returns an empty array.