def __init__(self,
            boto_session=None,
            profile_name=None,
            aws_region=None,
            load_credentials=True,
            desired_role_name=None,
            desired_role_arn=None,
            runtime='python2.7', # Detected at runtime in CLI
            tags=(),
            endpoint_urls={},
            xray_tracing=False
        ):
        """
        Instantiate this new Zappa instance, loading any custom credentials if necessary.
        """

        # Set aws_region to None to use the system's region instead
        if aws_region is None:
            # https://github.com/Miserlou/Zappa/issues/413
            self.aws_region = boto3.Session().region_name
            logger.debug("Set region from boto: %s", self.aws_region)
        else:
            self.aws_region = aws_region

        if desired_role_name:
            self.role_name = desired_role_name

        if desired_role_arn:
            self.credentials_arn = desired_role_arn

        self.runtime = runtime

        if self.runtime == 'python2.7':
            self.manylinux_wheel_file_suffix = 'cp27mu-manylinux1_x86_64.whl'
        elif self.runtime == 'python3.6':
            self.manylinux_wheel_file_suffix = 'cp36m-manylinux1_x86_64.whl'
        else:
            self.manylinux_wheel_file_suffix = 'cp37m-manylinux1_x86_64.whl'

        self.endpoint_urls = endpoint_urls
        self.xray_tracing = xray_tracing

        # Some common invocations, such as DB migrations,
        # can take longer than the default.

        # Note that this is set to 300s, but if connected to
        # APIGW, Lambda will max out at 30s.
        # Related: https://github.com/Miserlou/Zappa/issues/205
        long_config_dict = {
            'region_name': aws_region,
            'connect_timeout': 5,
            'read_timeout': 300
        }
        long_config = botocore.client.Config(**long_config_dict)

        if load_credentials:
            self.load_credentials(boto_session, profile_name)

            # Initialize clients
            self.s3_client = self.boto_client('s3')
            self.lambda_client = self.boto_client('lambda', config=long_config)
            self.elbv2_client = self.boto_client('elbv2')
            self.events_client = self.boto_client('events')
            self.apigateway_client = self.boto_client('apigateway')
            # AWS ACM certificates need to be created from us-east-1 to be used by API gateway
            east_config = botocore.client.Config(region_name='us-east-1')
            self.acm_client = self.boto_client('acm', config=east_config)
            self.logs_client = self.boto_client('logs')
            self.iam_client = self.boto_client('iam')
            self.iam = self.boto_resource('iam')
            self.cloudwatch = self.boto_client('cloudwatch')
            self.route53 = self.boto_client('route53')
            self.sns_client = self.boto_client('sns')
            self.cf_client = self.boto_client('cloudformation')
            self.dynamodb_client = self.boto_client('dynamodb')
            self.cognito_client = self.boto_client('cognito-idp')
            self.sts_client = self.boto_client('sts')

        self.tags = tags
        self.cf_template = troposphere.Template()
        self.cf_api_resources = []
        self.cf_parameters = {}
def __init__ ( self , boto_session = None , profile_name = None , aws_region = None , load_credentials = True , desired_role_name = None , desired_role_arn = None , runtime = 'python2.7' , tags = ( ) , endpoint_urls = { } , xray_tracing = False ) : if aws_region is None : self . aws_region = boto3 . Session ( ) . region_name logger . debug ( "Set region from boto: %s" , self . aws_region ) else : self . aws_region = aws_region if desired_role_name : self . role_name = desired_role_name if desired_role_arn : self . credentials_arn = desired_role_arn self . runtime = runtime if self . runtime == 'python2.7' : self . manylinux_wheel_file_suffix = 'cp27mu-manylinux1_x86_64.whl' elif self . runtime == 'python3.6' : self . manylinux_wheel_file_suffix = 'cp36m-manylinux1_x86_64.whl' else : self . manylinux_wheel_file_suffix = 'cp37m-manylinux1_x86_64.whl' self . endpoint_urls = endpoint_urls self . xray_tracing = xray_tracing long_config_dict = { 'region_name' : aws_region , 'connect_timeout' : 5 , 'read_timeout' : 300 } long_config = botocore . client . Config ( ** long_config_dict ) if load_credentials : self . load_credentials ( boto_session , profile_name ) self . s3_client = self . boto_client ( 's3' ) self . lambda_client = self . boto_client ( 'lambda' , config = long_config ) self . elbv2_client = self . boto_client ( 'elbv2' ) self . events_client = self . boto_client ( 'events' ) self . apigateway_client = self . boto_client ( 'apigateway' ) east_config = botocore . client . Config ( region_name = 'us-east-1' ) self . acm_client = self . boto_client ( 'acm' , config = east_config ) self . logs_client = self . boto_client ( 'logs' ) self . iam_client = self . boto_client ( 'iam' ) self . iam = self . boto_resource ( 'iam' ) self . cloudwatch = self . boto_client ( 'cloudwatch' ) self . route53 = self . boto_client ( 'route53' ) self . sns_client = self . boto_client ( 'sns' ) self . cf_client = self . boto_client ( 'cloudformation' ) self . dynamodb_client = self . boto_client ( 'dynamodb' ) self . cognito_client = self . boto_client ( 'cognito-idp' ) self . sts_client = self . boto_client ( 'sts' ) self . tags = tags self . cf_template = troposphere . Template ( ) self . cf_api_resources = [ ] self . cf_parameters = { }
Instantiate this new Zappa instance, loading any custom credentials if necessary.