aws-nuke icon indicating copy to clipboard operation
aws-nuke copied to clipboard

GovCloud support

Open ericfrederich opened this issue 5 years ago • 7 comments

This tool currently does not work with GovCloud. The only region I have specified in my config is us-gov-west-1. I get the following error:

Error: failed get caller identity: InvalidClientTokenId: The security token included in the request is invalid.

I've been working with GovCloud enough to know that this typically means it's using GovCloud credentials against the regular commercial AWS endpoints. I tried exporting AWS_DEFAULT_REGION to us-gov-west-1 in hopes that maybe the underlying golang SDK would pick up on this and use the proper endpoints but this did not work.

ericfrederich avatar Dec 16 '19 15:12 ericfrederich

If you want to change the source and recompile you can make the following changes in pkg/awsutil/session.go:

  • Replace endpoints.UsEast1RegionID with endpoints.UsGovWest1RegionID
  • Replace endpoints.AwsPartitionID with endpoints.AwsUsGovPartitionID

Hopefully when #391 is resolved GovCloud support will work too.

laurelmay avatar Dec 16 '19 15:12 laurelmay

Another thing that might be worth mentioning is that since the GovCloud Administrator user is just a regular IAM user, aws-nuke will try to delete it as well as the Administrators group attachment (and the AdminPolicy policy attachment to that group). The API seems to happily allow these resources (and Login Profiles and Access Keys) to be deleted. You will want to ensure that these resources are excluded when running aws-nuke or that you have your GovCloud root access keys (though it is not necessarily typical to have them).

laurelmay avatar Dec 19 '19 20:12 laurelmay

Native support for GovCloud regions would be immensely beneficial as the error is the same when pointing to us-gov-east-1 as well.

aghassemlouei avatar Feb 22 '20 18:02 aghassemlouei

@ericfrederich @kylelaker @aghassemlouei - I have a pull request open which ought to address this for you. At least you could pull the code from my branch and compile it if that helps.

chrisgilmerproj avatar Jun 02 '21 18:06 chrisgilmerproj

Noting that even with the above merge, this remains a problem in 2.17.0

lohman avatar Apr 18 '22 21:04 lohman

running with --default-region us-gov-west-1 worked for me 🎉

yuvalyacoby avatar Apr 25 '22 14:04 yuvalyacoby

Yep, that's the trick. It requires that we specify that parameter even if the config has been updated with that region. So maybe the dev could eliminate the need for that --default-region statement?

lohman avatar Apr 25 '22 19:04 lohman