Skip to content

Commit

Permalink
Big Black PR (ansible-collections#1784)
Browse files Browse the repository at this point in the history
* Black prep

* Black

* changelog

* Fix pylint unused-import in tests

* Split SSM connection plugin changes

* disable glue tests - bucket's missing

* Disable s3_logging and s3_sync tests

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@2c4575c
  • Loading branch information
tremble authored and mandar242 committed Oct 6, 2023
1 parent bf3231c commit 98339bf
Showing 1 changed file with 17 additions and 18 deletions.
35 changes: 17 additions & 18 deletions plugins/modules/sts_assume_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,29 +112,28 @@


def _parse_response(response):
credentials = response.get('Credentials', {})
user = response.get('AssumedRoleUser', {})
credentials = response.get("Credentials", {})
user = response.get("AssumedRoleUser", {})

sts_cred = {
'access_key': credentials.get('AccessKeyId'),
'secret_key': credentials.get('SecretAccessKey'),
'session_token': credentials.get('SessionToken'),
'expiration': credentials.get('Expiration')

"access_key": credentials.get("AccessKeyId"),
"secret_key": credentials.get("SecretAccessKey"),
"session_token": credentials.get("SessionToken"),
"expiration": credentials.get("Expiration"),
}
sts_user = camel_dict_to_snake_dict(user)
return sts_cred, sts_user


def assume_role_policy(connection, module):
params = {
'RoleArn': module.params.get('role_arn'),
'RoleSessionName': module.params.get('role_session_name'),
'Policy': module.params.get('policy'),
'DurationSeconds': module.params.get('duration_seconds'),
'ExternalId': module.params.get('external_id'),
'SerialNumber': module.params.get('mfa_serial_number'),
'TokenCode': module.params.get('mfa_token')
"RoleArn": module.params.get("role_arn"),
"RoleSessionName": module.params.get("role_session_name"),
"Policy": module.params.get("policy"),
"DurationSeconds": module.params.get("duration_seconds"),
"ExternalId": module.params.get("external_id"),
"SerialNumber": module.params.get("mfa_serial_number"),
"TokenCode": module.params.get("mfa_token"),
}
changed = False

Expand All @@ -154,19 +153,19 @@ def main():
argument_spec = dict(
role_arn=dict(required=True),
role_session_name=dict(required=True),
duration_seconds=dict(required=False, default=None, type='int'),
duration_seconds=dict(required=False, default=None, type="int"),
external_id=dict(required=False, default=None),
policy=dict(required=False, default=None),
mfa_serial_number=dict(required=False, default=None),
mfa_token=dict(required=False, default=None, no_log=True)
mfa_token=dict(required=False, default=None, no_log=True),
)

module = AnsibleAWSModule(argument_spec=argument_spec)

connection = module.client('sts')
connection = module.client("sts")

assume_role_policy(connection, module)


if __name__ == '__main__':
if __name__ == "__main__":
main()

0 comments on commit 98339bf

Please sign in to comment.