Repository: cloud-custodian/cloud-custodian

Issue:
0.8.45.2 - boto - Region not set
0.8.45.2 (https://github.com/cloud-custodian/cloud-custodian/pull/5026) complains about region being unset during the dryrun state in my CI pipeline.

Seems its not set here:
https://github.com/cloud-custodian/cloud-custodian/blob/21ecdd60ae8a78887cf9d135367b283ce88b0fd9/c7n/credentials.py#L107-L108

Thinking its because it is set to none in the get_sts_client logic.
https://github.com/cloud-custodian/cloud-custodian/blob/21ecdd60ae8a78887cf9d135367b283ce88b0fd9/c7n/credentials.py#L147

```
$ custodian run --dryrun --region $C7N_REGION --assume arn:aws:iam::123456789876:role/c7n_spoke_DEV --cache $C7N_CACHE --cache-period 0 --output-dir output rsop/$C7N_RSOP.yml
Traceback (most recent call last):
  File "/usr/local/bin/custodian", line 8, in <module>
    sys.exit(main())
  File "/usr/local/lib/python3.7/site-packages/c7n/cli.py", line 374, in main
    command(config)
  File "/usr/local/lib/python3.7/site-packages/c7n/commands.py", line 141, in _load_policies
    return f(options, list(policies))
  File "/usr/local/lib/python3.7/site-packages/c7n/commands.py", line 275, in run
    local_session(clouds['aws']().get_session_factory(options))
  File "/usr/local/lib/python3.7/site-packages/c7n/utils.py", line 274, in local_session
    s = factory()
  File "/usr/local/lib/python3.7/site-packages/c7n/credentials.py", line 59, in __call__
    region or self.region, self.external_id)
  File "/usr/local/lib/python3.7/site-packages/c7n/credentials.py", line 117, in assumed_session
    metadata=refresh(),
  File "/usr/local/lib/python3.7/site-packages/c7n/credentials.py", line 108, in refresh
    session, region).assume_role, **parameters)['Credentials']
  File "/usr/local/lib/python3.7/site-packages/c7n/utils.py", line 390, in _retry
    return func(*args, **kw)
  File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 648, in _make_api_call
    operation_model, request_dict, request_context)
  File "/usr/local/lib/python3.7/site-packages/botocore/client.py", line 667, in _make_request
    return self._endpoint.make_request(operation_model, request_dict)
  File "/usr/local/lib/python3.7/site-packages/botocore/endpoint.py", line 102, in make_request
    return self._send_request(request_dict, operation_model)
  File "/usr/local/lib/python3.7/site-packages/botocore/endpoint.py", line 132, in _send_request
    request = self.create_request(request_dict, operation_model)
  File "/usr/local/lib/python3.7/site-packages/botocore/endpoint.py", line 116, in create_request
    operation_name=operation_model.name)
  File "/usr/local/lib/python3.7/site-packages/botocore/hooks.py", line 356, in emit
    return self._emitter.emit(aliased_event_name, **kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/hooks.py", line 228, in emit
    return self._emit(event_name, kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/hooks.py", line 211, in _emit
    response = handler(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/signers.py", line 90, in handler
    return self.sign(operation_name, request)
  File "/usr/local/lib/python3.7/site-packages/botocore/signers.py", line 149, in sign
    auth = self.get_auth_instance(**kwargs)
  File "/usr/local/lib/python3.7/site-packages/botocore/signers.py", line 233, in get_auth_instance
    raise botocore.exceptions.NoRegionError()
botocore.exceptions.NoRegionError: You must specify a region.
```


Discussion:
ugh, working on it, brown bag release upcoming

Resolving patch:
diff --git a/c7n/credentials.py b/c7n/credentials.py
--- a/c7n/credentials.py
+++ b/c7n/credentials.py
@@ -143,7 +143,7 @@ def get_sts_client(session, region):
         endpoint_url = "https://sts.{}.amazonaws.com".format(region)
         region_name = region
     else:
-        endpoint_url = "https://sts.amazonaws.com"
+        endpoint_url = None
         region_name = None
     return session.client(
         'sts', endpoint_url=endpoint_url, region_name=region_name)
diff --git a/c7n/version.py b/c7n/version.py
--- a/c7n/version.py
+++ b/c7n/version.py
@@ -12,4 +12,4 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-version = u"0.8.45.2"
+version = u"0.8.45.3"
diff --git a/setup.py b/setup.py
--- a/setup.py
+++ b/setup.py
@@ -9,7 +9,7 @@ def read(fname):
 
 setup(
     name="c7n",
-    version='0.8.45.2',
+    version='0.8.45.3',
     description="Cloud Custodian - Policy Rules Engine",
     long_description=read('README.md'),
     long_description_content_type='text/markdown',


Test patch: