def createRoleAlias()

in codes/lambda/custom_iot_role_alias/src/handler.py [0:0]


def createRoleAlias(props):
    alias_role_name = str(props['IoTRoleAliasName'])
    token_role_arn = str(props['TokenRoleARN'])
    print('Role creation: requested', alias_role_name)

    try:
        client = boto3.client('iot')
        response = client.create_role_alias(
            roleAlias=alias_role_name,
            roleArn=token_role_arn,
            credentialDurationSeconds=credentialDurationInSec
        )
        print('Role creation: success', response)
        return response['roleAlias']
    except Exception as e:
        print("Role creation: fail", e)
        return None