def add_role_to_cloudcheckr()

in AccountCreationLambda.py [0:0]


def add_role_to_cloudcheckr(env, adminapikey, accountname, rolearn):
    """
	Uses the cross-account role created by the cloud formation stack to add it to CloudCheckr.
	Uses the edit_credential Admin API call.
	"""

    if rolearn is None:
        print("Role Arn from Cloudformation stack was not found, so not \
                credentials were added to CloudCheckr")
        return None

    api_url = env + "/api/account.json/edit_credential"

    edit_credential_info = json.dumps({"use_account": accountname, "aws_role_arn": rolearn})

    response_post = requests.post(api_url, headers={"Content-Type": "application/json",
                         "access_key": adminapikey}, data=edit_credential_info
                      )

    if "Message" in response_post.json():
        print("Successfully added the role " + str(rolearn) + " \
                to the CloudCheckr Account " + accountname)
        print(response_post.json())
        print("CloudChecker Integration Complete for the Account " + accountname)
    else:
        print("FAILED to add the role " + str(rolearn) + " to the \
                CloudCheckr Account " + accountname)
        print(response_post.json())
    return None