...
Code Block |
---|
""" Example script showing how to onboard ana AWScloud environmentauthenticator. """ import logging from dt_api_security_results.client import ApiSecurityResultsClient, from dt_api_security_results.messages import \ CloudAuthenticatorCreateRequest from dt_api_security_results.models.cloud_authenticators import AwsAuthenticatorAwsCredential, \ CloudAuthenticatorTypesEnum # TODO: Replace these values API_KEY = "MDAwMDAwMDAwMDAwMDAwMA==API_KEY = "REPLACE WITH YOUR API KEY" ROLE_ARN = "arn:aws:iam::12345678:role/DataTheoremAccessREPLACE WITH YOUR ROLE ARN" EXTERNAL_ID = "z96hmxdd96fm37sfeyavnbmu4pz510qxREPLACE WITH YOUR EXTERNAL ID" logging.basicConfig( level=logging.INFO, format="%(asctime)s %(levelname)s %(message)s" ) if __name__ == "__main__": client = ApiSecurityResultsClient( api_key=API_KEY, base_url="https://dev-horizon.appspot.com/customer/beta" ) ) request = CloudAuthenticatorCreateRequest( cloud_authenticator_type=CloudAuthenticatorTypesEnum.AMAZON_WEB_SERVICES, aws_credential=AwsAuthenticatorAwsCredential(role_arn=ROLE_ARN, external_id=EXTERNAL_ID,), ) try: response = client.cloud_authenticator_create(authenticator_request=request) except Exception: logging.exception("An error occurred.") else: logging.info( f"Successfully addedonboarded cloud authenticator: {response.json()}" ) logging.info("All done.") |