Files
floci/docs
Alessandro Lattao e12b878b77 fix(cloudformation): resolve Fn::GetStackOutput as CloudFormation does (#5848)
* fix(cloudformation): resolve Fn::GetStackOutput as CloudFormation does

Fn::GetStackOutput was not implemented, and an intrinsic the template
engine does not know falls through to the node's text, which for an
object is "". A weak cross-stack reference, which aws-cdk-lib synthesizes
as Fn::GetStackOutput, therefore deployed CREATE_COMPLETE with an empty
string wherever the value was used.

The engine now resolves it through a StackOutputResolver that
CloudFormationService answers as DescribeStacks would in the referenced
account and Region, and the YAML parser maps the !GetStackOutput short
form. Every rule follows what CloudFormation does, measured in eu-west-1,
where that departs from the function's reference page: a missing stack
or output fails the resource and the stack rolls back, an output that
cannot be read rolls the stack back once the resources exist, an output
whose Condition is false is never read, a dynamic reference reaches
DescribeStacks unresolved, and the function is refused in Conditions and
inside Fn::ImportValue when the operation is requested, AWS::Include
fragments included. A RoleArn has to name an existing role: Floci runs
no stack operation under an execution role, so, as AssumeRole does with
IAM enforcement off, its trust policy is not evaluated.

* fix(cloudformation): refuse Fn::GetStackOutput in export names and nested stacks as AWS does

Answers the review of #5848, each point measured on CloudFormation in
eu-west-1 on 2026-10-17.

An output's Export.Name holding Fn::GetStackOutput is refused when the
operation is requested, with "Template format error: Output O is
malformed.  The Name field of Export must not depend on any resources,
imported values, or Fn::GetAZs.", so it never reaches execution. A
nested stack's template is checked when the child is created: the Child
resource fails with the template error and the parent rolls back.

A dynamic reference inside an Fn::Sub variable map of the function's
arguments is left as written too: CloudFormation hands it to
DescribeStacks unresolved, which refuses the name. The engine suspends
dynamic references while it resolves the arguments.

An output that cannot be read now logs the stack and the output before
the rollback, and the placement check skips only a template that does
not parse or an AWS::Include that fails, which the operation reports
where it processes them.

* fix(cloudformation): check a Fn::GetStackOutput role's trust and permissions under IAM enforcement

With IAM enforcement on, a RoleArn only had to name an existing role, so a
stack could read another account's outputs through any role there,
whatever the role trusted. GetStackOutputRoleAuthorizer now decides the
role as AssumeRole and AppSyncDataSourceAuthorizer do: its trust policy
has to allow a principal in the consuming account, and its policies,
through IamPolicyEvaluator, have to allow cloudformation:DescribeStacks
on the referenced stack. The refusals carry the messages measured on
CloudFormation: STS's AccessDenied, and DescribeStacks' for the
GetStackOutput session. With enforcement off nothing changes.

Which principal CloudFormation acts as is not known in Floci, which runs
stack operations under no execution role and keeps no caller, so a grant
to any principal of the consuming account is enough: its root, or any
principal of it the policy names, such as the CDK's execution role.
That question is AssumeRolePolicyEvaluator.allowsAnyPrincipalOf, built on
its own decide(), so the trust policy is parsed and evaluated in one
place.

Reuse instead of copies: the tests use EnforcementFixtures.auth, a new
EnforcementFixtures.createRole overload taking the trust policy, and
PartitionCleanup, and the two GetStackOutput tests share their stack and
parameter helpers. The placement checks find the function with
JsonNode.findValues instead of three hand-written walks, and the
resolveOutputValue wrapper of resolve() is gone.
2026-10-17 09:09:24 -04:00
..
2026-03-15 17:43:56 -05:00