diff --git a/src/starfleet/worker_ships/plugins/iam/iambic_imports.py b/src/starfleet/worker_ships/plugins/iam/iambic_imports.py new file mode 100644 index 0000000..4be9689 --- /dev/null +++ b/src/starfleet/worker_ships/plugins/iam/iambic_imports.py @@ -0,0 +1,20 @@ +"""File to handle the IAMbic imports. This is done to avoid logger issues. + +:Module: starfleet.worker_ships.plugins.iam.iambic_imports +:Copyright: (c) 2023 by Gemini Trust Company, LLC., see AUTHORS for more info +:License: See the LICENSE file for details +:Author: Mike Grima +""" +# pylint: disable=unused-import,wrong-import-position,wrong-import-order +from unittest import mock + +from starfleet.utils.logging import LOGGER + +# Mock out the iambic logger, as it's bossy and overrides Starfleet's: +mock.patch("iambic.core.logger.log", LOGGER).start() + +# Now continue to import the rest: +from iambic.core.context import ctx as iambic_ctx # noqa: E402,F401 +from iambic.core.models import Variable # noqa: E402,F401 +from iambic.plugins.v0_1_0.aws.iam.role.models import AwsIamRoleTemplate # noqa: E402,F401 +from iambic.plugins.v0_1_0.aws.models import AWSAccount # noqa: E402,F401 diff --git a/src/starfleet/worker_ships/plugins/iam/role_ship.py b/src/starfleet/worker_ships/plugins/iam/role_ship.py index cb4002e..97765f9 100644 --- a/src/starfleet/worker_ships/plugins/iam/role_ship.py +++ b/src/starfleet/worker_ships/plugins/iam/role_ship.py @@ -19,15 +19,14 @@ import click import yaml from click import Context -from iambic.core.context import ctx as iambic_ctx -from iambic.plugins.v0_1_0.aws.iam.role.models import AwsIamRoleTemplate -from iambic.plugins.v0_1_0.aws.models import AWSAccount + from marshmallow import ValidationError as MarshmallowError from pydantic import ValidationError as PydanticError from starfleet.account_index.loader import ACCOUNT_INDEX from starfleet.utils.configuration import STARFLEET_CONFIGURATION from starfleet.utils.logging import LOGGER + from starfleet.worker_ships.cli_utils import StarfleetAccountCommand, StarfleetSingleInvokeCommand from starfleet.worker_ships.lambda_utils import worker_lambda from starfleet.worker_ships.plugins.iam.schemas import ( @@ -38,6 +37,7 @@ make_iambic_variables, ) from starfleet.worker_ships.ship_schematics import StarfleetWorkerShip, FanOutStrategy, AlertPriority +from starfleet.worker_ships.plugins.iam.iambic_imports import AWSAccount, AwsIamRoleTemplate, iambic_ctx class IambicFailedError(Exception): diff --git a/src/starfleet/worker_ships/plugins/iam/schemas.py b/src/starfleet/worker_ships/plugins/iam/schemas.py index a3e766c..6e182e2 100644 --- a/src/starfleet/worker_ships/plugins/iam/schemas.py +++ b/src/starfleet/worker_ships/plugins/iam/schemas.py @@ -9,13 +9,13 @@ from enum import Enum from typing import Any, Dict, List -from iambic.core.models import Variable from marshmallow import ValidationError, fields, Schema, validate from starfleet.account_index.resolvers import resolve_account_specification, resolve_include_account_specification from starfleet.utils.logging import LOGGER from starfleet.worker_ships.base_payload_schemas import IncludeAccountsSpecificationSchema, AccountsSpecificationSchema, BaseAccountPayloadTemplate from starfleet.worker_ships.ship_schematics import WorkerShipBaseConfigurationTemplate +from starfleet.worker_ships.plugins.iam.iambic_imports import Variable class IambicTemplateTypes(Enum):