trailscraper icon indicating copy to clipboard operation
trailscraper copied to clipboard

Region selection for `trailscraper select`

Open be-rock opened this issue 4 years ago • 3 comments

Hi,

Thanks for this great library. What is the best way to set this up? I am running from an ec2 instance with an instance profile that has access to the cloudtrail api but seeing:

trailscraper select --use-cloudtrail-api \ 
                      --filter-assumed-role-arn my-assumed-role \ 
                      --from 'one hour ago' \ 
                      --to 'now'
...
(large python stacktrace trimmed)
botocore.exceptions.NoRegionError: You must specify a region.

It does not look like there is a region option with trailscraper select --help.

Thanks again.

be-rock avatar Dec 08 '21 17:12 be-rock

Hi @be-rock,

thanks for raising this, I've reproduced the issue, looks like this is happening if you don't have a default region set (this is to be expected on an EC2 instance but maybe not in most interactive environments where I normally test :)). It is indeed a bit unintuitive and should probably be fixed by hardcoding a region (assuming that CloudTrail is a global API, need to double check this before implementing anything).

In the meantime, you can work around this by setting a default region through the AWS_DEFAULT_REGION environment variable, e.g.

$ AWS_DEFAULT_REGION=us-east-1 trailscraper select --use-cloudtrail-api \
                      --filter-assumed-role-arn my-assumed-role \
                      --from 'one hour ago' \
                      --to 'now'

flosell avatar Dec 08 '21 19:12 flosell

Thanks @flosell for the prompt response and thorough feedback, that does indeed do it. Such a simple solution, thanks again!!

be-rock avatar Dec 08 '21 19:12 be-rock

Reopening this to find a more permanent fix for this (and make the workaround easier to find for others)

flosell avatar Dec 10 '21 09:12 flosell