LoginSignup
1
0

More than 1 year has passed since last update.

aws-nukeでつまづいたこと

Last updated at Posted at 2022-06-10

個人用備忘録

以下のConfigでaws-nukeを実行したが、エラーが発生した。

Your account ID 'XXXXXXXXXX' isn't listed in the config. Aborting.
config.yaml
regions:
- "global"

account-blocklist:
- "999999999" # production

resource-types:
  # IAMユーザは消したくない
  excludes:
  - IAMUser
実行コマンド
docker run --rm -it -v ./nuke-config.yml:/home/aws-nuke/config.yml -v ~\.aws\:/home/aws-nuke/.aws rebuy/aws-nuke --config /home/aws-nuke/config.yml --profile e1 --no-dry-run

結論

config.yamlにaccountsを指定する必要があった。
加えてIAM系は消したくないので適当に追加して以下とした。

config.yaml
regions:
- "global"

account-blocklist:
- "999999999" 

resource-types:
  excludes:
  - IAMUser
  - IAMGroup
  - IAMGroupPolicy
  - IAMGroupPolicyAttachment
  - IAMInstanceProfile
  - IAMInstanceProfileRole
  - IAMLoginProfile
  - IAMOpenIDConnectProvider
  - IAMPolicy
  - IAMRole
  - IAMRolePolicy
  - IAMRolePolicyAttachment
  - IAMSAMLProvider
  - IAMServerCertificate
  - IAMServiceSpecificCredential
  - IAMSigningCertificate
  - IAMUser
  - IAMUserAccessKey
  - IAMUserGroupAttachment
  - IAMUserPolicy
  - IAMUserPolicyAttachment

accounts:
  0000000000: {}
  

参考にした記事に「削除対象のアカウントを記載」とあり、「アカウントは消さないからいらないか~」って書かなかった。
しかしそうではなく「指定したアカウント内のリソースを削除する」だった。
aws-nukeでは削除するリソースを指定する際にtargetでできるため、リソースを絞る場合はここに書くと思い込んでいたのも原因

メモ追記

除外リソース表示コマンド
docker run --rm -it -v ./nuke-config.yml:/home/aws-nuke/config.yml -v ~\.aws\:/home/aws-nuke/.aws rebuy/aws-nuke --config /home/aws-nuke/config.yml --profile e1 -c aws-nuke resource-types
1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0