Skip to content

CloudFormation: Fn::FindInMap needs a Mappings model, and Fn::ImportValue/Cidr/GetAZs are expanded but unresolved #522

Closed

Description

@scttfrdmn

Summary

Four intrinsics are parsed and expanded but never resolved. A template using one
deploys with a literal where a value should be:

Intrinsic Why it is unresolved
Fn::FindInMap cfnTemplate has no Mappings field at all — zero occurrences in emulator/betty_cfn.go. There is nothing to resolve against
Fn::ImportValue Cross-stack exports are not modelled: Outputs has no Export handling, so there is no export registry to import from
Fn::Cidr List-valued, so it hits the resolver-shape problem in #521 as well as being unimplemented
Fn::GetAZs List-valued likewise; needs a per-region AZ list, which EC2 already has for DescribeAvailabilityZones

Fn::FindInMap is the one that matters most: a region→AMI map is one of the most
common things a real template does, and the failure is silent —
resolveValue falls back to JSON-encoding the unrecognized intrinsic, so an
ImageId becomes the literal {"Fn::FindInMap":["RegionMap","us-east-1","AMI"]}
and the instance launches with a nonsense AMI rather than the stack failing.

v0.87.1 (#516) made all four reachable from conventional YAML: !FindInMap and
friends are now expanded to their long forms, where before the tag was dropped
entirely. Expansion is still the right behaviour — it makes the two syntaxes
identical, which is the invariant #516 was about — but "expanded" must not be read
as "resolved", and docs/services.md now says so explicitly.

Priority note

None of the five parsl-aws-provider templates use any of the four, which is why
this was not on v0.87.1's critical path. It is filed because expansion makes them
reachable and because Mappings is a real gap for anyone writing a
region-portable template.

Acceptance criteria

  • cfnTemplate carries Mappings, and Fn::FindInMap resolves a
    three-level map, including the nested-key form
    (Fn::FindInMap [Map, TopKey, SecondKey]).
  • Fn::FindInMap with an unknown key behaves as CloudFormation does (a
    template error, not a silent literal).
  • Fn::GetAZs resolves against the same AZ list EC2's
    DescribeAvailabilityZones reports, so the two cannot disagree, and
    Fn::GetAZs '' resolves against the caller's region.
  • Fn::Cidr resolves per the documented ipBlock/count/cidrBits
    semantics.
  • Fn::ImportValue resolves against an export registry populated by another
    stack's Outputs.*.Export.Name, and refuses to delete a stack whose export
    is still imported — which is the behaviour that makes exports worth modelling
    rather than faking.
  • Both list-valued cases depend on, or land with, CloudFormation: Fn::Split resolves to its first element only, so a split list silently loses everything after the first item #521.
  • The unresolved list in docs/services.md shrinks accordingly.

Provenance

Confirmed by reading resolveValue and evalConditionExpr in
emulator/betty_cfn.go: the switch handles Ref, Fn::Sub, Fn::Join,
Fn::Select, Fn::Split, Fn::Base64, Fn::GetAtt, Fn::If and the condition
functions, and nothing else. Mappings absence confirmed by grep. Documented as a
known limitation in docs/services.md.

Activity

  1. added
    type: feature
    area: cloudformation
    priority: medium
    on Aug 3, 2026
  2. added this to the v0.88.0 milestone on Aug 3, 2026
  3. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    Milestoned to v0.88.0, as the third PR of the resolver cluster.

    Depends on #521. Two of the four intrinsics here are list-valued — Fn::GetAZs returns a list of AZ names and Fn::Cidr a list of CIDR blocks — so both land on the resolveValueList seam #521 adds. Doing this first would mean writing a second list path and then merging them.

    Findings from planning, which change or sharpen the scope:

    Fn::FindInMap must fail, not fall back. resolveValue's final arm is a json.Marshal fallback, so an unresolved Fn::FindInMap today emits the literal JSON of the intrinsic itself as the property value. For the canonical region→AMI mapping that means an ImageId of {"Fn::FindInMap":["RegionMap","us-east-1","AMI"]} — and the instance launches, because substrate does not validate AMI IDs. Once Mappings exists, an unknown map name / top-level key / second-level key must fail the resource (real CloudFormation returns ValidationError), not silently produce a literal. Otherwise the fix converts a wrong-value bug into a wrong-value bug that is harder to spot.

    Fn::GetAZs has to agree with the EC2 plugin. Substrate already answers DescribeAvailabilityZones. If Fn::GetAZs synthesizes its own list, a template that selects !Select [0, !GetAZs ""] and a caller that reads DescribeAvailabilityZones see different AZs for the same region, which is a fresh inconsistency rather than a fixed one. It must resolve against the same source. !GetAZs "" uses the caller's region.

    Fn::ImportValue needs Export on cfnOutput, which does not exist. cfnOutput (emulator/betty_cfn.go:42) carries only Value and Description — there is no Export field at all, so there is nowhere for an export name to come from. The export registry has to be populated from Outputs.*.Export.Name, which means adding the field first. And the part that makes exports worth modelling rather than faking: refusing to delete a stack whose export is still imported. Real CloudFormation returns ValidationError naming the importing stacks. Without that refusal, an export registry is just a lookup table.

    Four unresolved pseudo-parameters belong in this issue. They are in the same resolveRef switch (:3157-3178) and docs/services.md:215 documents them as unresolved in the same paragraph as these intrinsics, so shortening that list without closing it leaves the docs in an odd half-state:

    • AWS::Partition → aws
    • AWS::URLSuffix → amazonaws.com
    • AWS::StackId — nearly free: cfnStackID (emulator/cloudformation_plugin.go:1086) already builds a deterministic stack ARN for CreateStack's response. It only needs threading onto cfnContext.
    • AWS::NotificationARNs → empty list, with a note that substrate has no notification model.

    Adding a criterion:

    • AWS::Partition, AWS::URLSuffix, AWS::StackId and AWS::NotificationARNs resolve, and docs/services.md's unresolved-pseudo-parameter list is removed rather than shortened.

    Possible split. If the implementation outgrows #521 and #526/#527 combined, Fn::ImportValue comes out into its own PR — the export registry plus the delete-refusal is a new cross-stack model, whereas the other three are resolvers. The Mappings work and the pseudo-parameters stay together.

    One coupling to watch, relevant to #502. Both new failure modes here (unknown map key, refusing to delete an imported-from stack) need an AWS error code on the wire, and no substring in cfnMapDeployerError matches either. If either surfaces through Deploy/DeleteStack's error return, #502's typed sentinels should land in this release rather than widening the substring switch. If both are recorded on the resource instead — which v0.87.1's #519 work makes the natural choice — the mapper is untouched. Decide that when implementing; see the note on #502.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: cloudformationpriority: mediumtype: feature

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions