Skip to content

CFNv2: support validation of CAPABILITY_AUTO_EXPAND #12864

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
GetTemplateSummaryInput,
GetTemplateSummaryOutput,
IncludePropertyValues,
InsufficientCapabilitiesException,
InvalidChangeSetStatusException,
LogicalResourceId,
NextToken,
Expand Down Expand Up @@ -476,6 +477,14 @@ def create_stack(self, context: RequestContext, request: CreateStackInput) -> Cr
template_body = api_utils.extract_template_body(request)
structured_template = template_preparer.parse_template(template_body)

if (
"CAPABILITY_AUTO_EXPAND" not in request.get("Capabilities", [])
and "Transform" in structured_template.keys()
):
raise InsufficientCapabilitiesException(
"Requires capabilities : [CAPABILITY_AUTO_EXPAND]"
)

stack = Stack(
account_id=context.account_id,
region_name=context.region,
Expand Down Expand Up @@ -680,6 +689,14 @@ def update_stack(
template_body = api_utils.extract_template_body(request)
structured_template = template_preparer.parse_template(template_body)

if (
"CAPABILITY_AUTO_EXPAND" not in request.get("Capabilities", [])
and "Transform" in structured_template.keys()
):
raise InsufficientCapabilitiesException(
"Requires capabilities : [CAPABILITY_AUTO_EXPAND]"
)

# this is intentionally not in a util yet. Let's first see how the different operations deal with these before generalizing
# handle ARN stack_name here (not valid for initial CREATE, since stack doesn't exist yet)
stack: Stack
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,6 @@ def _check_changeset_available():
snapshot.match("postdelete_changeset_notfound", e.value)


@pytest.mark.skip("CFNV2:Capabilities")
@markers.aws.validated
def test_autoexpand_capability_requirement(cleanups, aws_client):
stack_name = f"test-stack-{short_uid()}"
Expand Down
Loading