Region selection for `trailscraper select`
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.
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'
Thanks @flosell for the prompt response and thorough feedback, that does indeed do it. Such a simple solution, thanks again!!
Reopening this to find a more permanent fix for this (and make the workaround easier to find for others)