Skip to content
Merged
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
15 changes: 11 additions & 4 deletions localstack-core/localstack/testing/scenario/provisioning.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from typing import TYPE_CHECKING, Callable, ContextManager, Optional

import aws_cdk as cdk
from botocore.exceptions import WaiterError
from botocore.exceptions import ClientError, WaiterError

from localstack.config import is_env_true
from localstack.testing.aws.util import is_aws_cloud
Expand All @@ -28,7 +28,8 @@
"Delay": 6,
"MaxAttempts": 600,
} # total timeout ~1 hour (6 * 600 = 3_600 seconds)
WAITER_CONFIG_LS = {"Delay": 1, "MaxAttempts": 600} # total timeout ~10 minutes
# total timeout ~10 minutes
WAITER_CONFIG_LS = {"Delay": 1, "MaxAttempts": 600}
CFN_MAX_TEMPLATE_SIZE = 51_200


Expand Down Expand Up @@ -320,7 +321,8 @@ def add_cdk_stack(
with open(template_path, "wt") as fd:
template_json = cdk.assertions.Template.from_stack(cdk_stack).to_json()
json.dump(template_json, fd, indent=2)
fd.write("\n") # add trailing newline for linter and Git compliance
# add trailing newline for linter and Git compliance
fd.write("\n")

self.cloudformation_stacks[cdk_stack.stack_name] = {
"StackName": cdk_stack.stack_name,
Expand Down Expand Up @@ -402,7 +404,12 @@ def _template_bucket_name(self):
return f"localstack-testing-assets-{account_id}-{region}"

def _create_bucket_if_not_exists(self, template_bucket_name: str):
create_s3_bucket(template_bucket_name, s3_client=self.aws_client.s3)
try:
self.aws_client.s3.head_bucket(Bucket=template_bucket_name)
except ClientError as exc:
if exc.response["Error"]["Code"] != "404":
raise
create_s3_bucket(template_bucket_name, s3_client=self.aws_client.s3)

def _synth(self):
# TODO: this doesn't actually synth a CloudAssembly yet
Expand Down
Loading