Skip to content

Defer CDK imports in infra provisioning #12591

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion localstack-core/localstack/packages/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from threading import RLock
from typing import Any, Callable, Generic, List, Optional, ParamSpec, TypeVar

from plux import Plugin, PluginManager, PluginSpec # type: ignore[import-untyped]
from plux import Plugin, PluginManager, PluginSpec # type: ignore

from localstack import config

Expand Down
4 changes: 3 additions & 1 deletion tests/aws/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

from localstack import config as localstack_config
from localstack import constants
from localstack.testing.scenario.provisioning import InfraProvisioner
from localstack.testing.snapshots.transformer_utility import (
SNAPSHOT_BASIC_TRANSFORMER,
SNAPSHOT_BASIC_TRANSFORMER_NEW,
Expand Down Expand Up @@ -85,6 +84,9 @@ def cdk_template_path():
# Note: Don't move this into testing lib
@pytest.fixture(scope="session")
def infrastructure_setup(cdk_template_path, aws_client):
# Note: import needs to be local to avoid CDK import on every test run, which takes quite some time
from localstack.testing.scenario.provisioning import InfraProvisioner
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick (non-blocking): ‏I think it would make sense to add a comment here explaining why it is important to have this import deferred. :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I meant to do that and got distracted, will add!


def _infrastructure_setup(
namespace: str, force_synth: Optional[bool] = False
) -> InfraProvisioner:
Expand Down
Loading