def resolve_roles()

in ebcli/operations/createops.py [0: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