Esempio n. 1
0
def resolve_roles(env_request, interactive):
    """
    Resolves instance-profile and service-role
    :param env_request: environment request
    :param interactive: boolean
    """
    LOG.debug('Resolving roles')

    if (not env_request.instance_profile
            or env_request.instance_profile == iam_attributes.DEFAULT_ROLE_NAME
        ) and not env_request.template_name:
        env_request.instance_profile = commonops.create_default_instance_profile(
        )

    if (env_request.platform and env_request.platform.has_healthd_support
            and not env_request.service_role
            and not env_request.template_name):
        role = get_service_role()
        if role is None:
            if interactive:
                io.echo()
                io.echo(prompts['create.servicerole.info'])
                input = io.get_input(prompts['create.servicerole.view'],
                                     default='')

                if input.strip('"').lower() == 'view':
                    for policy_arn in DEFAULT_SERVICE_ROLE_POLICIES:
                        document = iam.get_managed_policy_document(policy_arn)
                        io.echo(json.dumps(document, indent=4))
                    io.get_input(prompts['general.pressenter'])

            role = create_default_service_role()

        env_request.service_role = role
Esempio n. 2
0
def resolve_roles(env_request, interactive):
    """
    Resolves instance-profile and service-role
    :param env_request: environment request
    :param interactive: boolean
    """
    LOG.debug('Resolving roles')

    if (
	        (
	            not env_request.instance_profile or
	            env_request.instance_profile == iam_attributes.DEFAULT_ROLE_NAME
	        ) and not env_request.template_name
    ):
        # Service supports no profile, however it is not good/recommended
        # Get the eb default profile
        env_request.instance_profile = commonops.create_default_instance_profile()

    if (
        env_request.platform and
        env_request.platform.has_healthd_support and
        not env_request.service_role and
        not env_request.template_name
    ):
        role = get_service_role()
        if role is None:
            if interactive:
                io.echo()
                io.echo(prompts['create.servicerole.info'])
                input = io.get_input(prompts['create.servicerole.view'],
                                     default='')

                if input.strip('"').lower() == 'view':
                    for policy_arn in DEFAULT_SERVICE_ROLE_POLICIES:
                        document = iam.get_managed_policy_document(policy_arn)
                        io.echo(json.dumps(document, indent=4))
                    io.get_input(prompts['general.pressenter'])

            # Create the service role if it does not exist
            role = create_default_service_role()

        env_request.service_role = role
Esempio n. 3
0
def resolve_roles(env_request, interactive):
    """
    Resolves instance-profile and service-role
    :param env_request: environment request
    :param interactive: boolean
    """
    LOG.debug('Resolving roles')

    if (env_request.instance_profile is None or env_request.instance_profile == iam_attributes.DEFAULT_ROLE_NAME) \
            and env_request.template_name is None:
        # Service supports no profile, however it is not good/recommended
        # Get the eb default profile
        env_request.instance_profile = commonops.create_default_instance_profile(
        )

    if (env_request.platform is not None
            and env_request.platform.has_healthd_support()
            and  # HealthD enabled
        (env_request.service_role is None) and
        (env_request.template_name is None)):
        role = get_service_role()
        if role is None:
            if interactive:
                io.echo()
                io.echo(prompts['create.servicerole.info'])
                input = io.get_input(prompts['create.servicerole.view'],
                                     default='')

                if input.strip('"').lower() == 'view':
                    for policy_arn in DEFAULT_SERVICE_ROLE_POLICIES:
                        document = iam.get_managed_policy_document(policy_arn)
                        io.echo(json.dumps(document, indent=4))
                    io.get_input(prompts['general.pressenter'])

            # Create the service role if it does not exist
            role = create_default_service_role()

        env_request.service_role = role