Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 20 additions & 3 deletions pacu/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -941,18 +941,29 @@ def print_web_console_url(self) -> None:
})
}

fed_resp = requests.get(url='https://signin.aws.amazon.com/federation', params=params)
region_name = sts.meta.region_name
partition = botocore.session.Session().get_partition_for_region(region_name)

domain_map = {
"aws": "aws.amazon.com",
"aws-us-gov": "amazonaws-us-gov.com",
"aws-cn": "amazonaws.cn",
}

partition_domain = domain_map.get(partition, "aws.amazon.com")

fed_resp = requests.get(url=f'https://signin.{partition_domain}/federation', params=params)

signin_token = fed_resp.json()['SigninToken']

params = {
'Action': 'login',
'Issuer': active_session.key_alias or '',
'Destination': 'https://console.aws.amazon.com/console/home',
'Destination': f'https://console.{partition_domain}/console/home',
'SigninToken': signin_token
}

url = 'https://signin.aws.amazon.com/federation?' + urllib.parse.urlencode(params)
url = f'https://signin.{partition_domain}/federation?' + urllib.parse.urlencode(params)

print('Paste the following URL into a web browser to login as session {}...\n'.format(active_session.name))

Expand Down Expand Up @@ -1622,6 +1633,12 @@ def get_boto3_client(
print(e.args)
return None

# To support GovCloud we can update the region here from self.get_active_session.session_regions[0] UNLESS regions == all
if region is None:
session_regions = self.get_active_session().session_regions
if 'all' not in session_regions:
region = session_regions[0]

conf = self.get_botocore_conf(region, user_agent, parameter_validation)
return aws_sess.client(service, config=conf)

Expand Down
Loading