Context
We have code which gets IPs from many AWS accounts within our organisation. Running this code returns IPs from each enabled region but throws exceptions for each disabled region.
We have wrapped the code in a guard clause, ensuring we only pull IPs if the region is enabled. This guard clause uses boto3's 'ec2' client to describe_regions
.
We want to test the guard clause functionality with Moto.
Current State
Moto provides a @mock_ec2
decorator and has implemented describe_regions
. We use this, but the mock returns all regions by default. We want to change the number of regions returned.
A stubbed response for the mocked describe_regions
would work best, but having experience with Moto, I've never seen anything like this.
We've attempted to use boto3's 'account' client enable_region
and disable_region
. Moto does not provide any mocking functionality for the account level. As a result, we cannot make calls against the virtual account in use by Moto.
Desired State
We can change the response Moto generates when it makes the describe_regions
call.
We use Moto extensively