Repository navigation
Description
Found while re-running #516's reproduction against the released v0.87.1 binary, using the reporter's own ecs_worker.yml shape. Independent of #516 and #517; predates both. The ECS half of what I found while probing this is split out as its own defect — see below.
What happens
resolveValue (emulator/betty_cfn.go:3107) resolves a value that is an intrinsic: a scalar, or a single-key map whose key is Ref/Fn::Sub/Fn::Join/Fn::Select/Fn::Split/Fn::Base64/Fn::GetAtt/Fn::If. Nothing walks into a map or list to resolve intrinsics nested within it. So wherever a deploy path forwards a structured property whole, any intrinsic inside it survives to the plugin unresolved.
For ECS it is stored as a literal object:
"Command": {"Fn::Split": [",", "python,-m,worker"]}For DynamoDB it is a hard failure — the plugin's typed struct rejects the object, which at least reports honestly now that #519 is fixed:
aws cloudformation create-stack --stack-name ddbnested --template-body \
'{"Parameters":{"PK":{"Type":"String","Default":"pk"}},"Resources":{"T":{
"Type":"AWS::DynamoDB::Table","Properties":{"TableName":"nested-probe",
"BillingMode":"PAY_PER_REQUEST",
"KeySchema":[{"AttributeName":{"Ref":"PK"},"KeyType":"HASH"}],
"AttributeDefinitions":[{"AttributeName":{"Ref":"PK"},"AttributeType":"S"}]}}}}'
aws cloudformation describe-stack-resources --stack-name ddbnested
→ CREATE_FAILED
SerializationException: Failed to parse request: json: cannot unmarshal object
into Go struct field DynamoDBAttributeDefinition.AttributeDefinitions.AttributeName
of type string
{"Ref": "PK"} inside KeySchema is ordinary CloudFormation. Real CloudFormation resolves intrinsics at any depth in a property value.
It is per-property, not universal
AWS::EC2::LaunchTemplate resolves nested intrinsics correctly, because betty_cfn_v77_plugins.go:34 walks LaunchTemplateData key by key and calls resolveStringProp/resolveStringList on each. That is the distinction:
- Walked → intrinsics resolve.
LaunchTemplateData.ImageIdvia{"Ref": …}— verified working. - Forwarded whole → intrinsics survive.
ContainerDefinitions[].Command,KeySchema[].AttributeName,AttributeDefinitions[].AttributeName— verified broken.
So the gap tracks how each deploy path happens to have been written, which means a consumer cannot predict which of their properties will resolve.
Shape of a fix
A general resolveNested(v interface{}, cctx *cfnContext) interface{} that walks maps and lists, resolving any node resolveValue recognizes and leaving everything else structurally intact, applied at each verbatim-forwarding site. Two things need care:
- What must not be resolved. An IAM policy document's
{"Fn::Sub": …}should resolve, but a user-supplied map whose key happens to beRef— for example an ECSlogConfiguration.optionsentry — should not. A blanket walk over every property risks the second case. Fn::Splitreturns one element (CloudFormation: Fn::Split resolves to its first element only, so a split list silently loses everything after the first item #521). A list context is exactly where that is wrong. A resolvedCommandneeds the whole list, andresolveValue's string return type is what prevents it. Suggest doing CloudFormation: Fn::Split resolves to its first element only, so a split list silently loses everything after the first item #521 first or together, since a nested!Split [',', !Ref Command]is what the reporting consumer'secs_worker.yml:208writes and it is the motivating case for both issues.
Acceptance criteria
- An intrinsic nested at any depth inside a structured property resolves — at minimum
ContainerDefinitions[].Command,ContainerDefinitions[].Environment[].Value,KeySchema[].AttributeName,AttributeDefinitions[].AttributeName. - The DynamoDB
{"Ref": "PK"}-in-KeySchematemplate above reachesCREATE_COMPLETEand the table's key schema names the resolved attribute. - A property whose keys are user data (ECS
logConfiguration.options, resourceTagsvalues are fine but keys are user-supplied) is not rewritten by the walk. - A test asserting the reporter's
ecs_worker.ymlcontainer command resolves to a list rather than anFn::Splitobject (may depend on CloudFormation: Fn::Split resolves to its first element only, so a split list silently loses everything after the first item #521). -
docs/services.mdstates that nested intrinsics resolve, replacing any per-property caveat.
Related
- CloudFormation: Fn::Split resolves to its first element only, so a split list silently loses everything after the first item #521 —
Fn::Splitresolves to its first element only. Blocking for the list case above. - ECS: a CloudFormation-deployed task definition's ContainerDefinitions keep CloudFormation's PascalCase keys #527 —
AWS::ECS::TaskDefinitionforwardsContainerDefinitionsin CloudFormation's case. Same line of code (betty_cfn_v21_plugins.go:150), separate defect: that one is a key-name mapping, this one is value resolution.
Activity
[-]CloudFormation: an intrinsic nested inside a structured property is never resolved, and ECS ContainerDefinitions are forwarded in the wrong case[/-][+]CloudFormation: an intrinsic nested inside a structured property is never resolved[/+]scttfrdmn commentedon Aug 3, 2026
Milestoned to v0.88.0. Recording the dependency and three implementation constraints found while planning, since a naive fix gets each of them wrong.
Blocked on #521. The resolver returns a
stringand does not recurse; those are the same root cause. Resolving a nested intrinsic means splicing a nestedFn::Splitinto a list position, which needs #521's list-returning resolver first. Fixing this one alone would resolve a nested!Splitto its first element — trading a silent drop for a silent truncation.Constraint 1: a multi-key map is not an intrinsic. A single-key map whose key is a recognized
Fn::/Refname resolves; a map with two or more keys must be left alone even if one of them isRef, because that is user data, not an intrinsic. A walk that checksif v["Ref"] != nilrather thanlen(v) == 1 && v["Ref"] != nilcorrupts any user-supplied map that happens to contain aRefkey.Constraint 2: keys are never rewritten. This issue is about values. Rewriting keys is #527's job, and conflating the two is how
logConfiguration.optionsgets mangled — its keys are user data (awslogs-group,awslogs-stream-prefix) and must survive verbatim.Constraint 3:
Fn::IfyieldingAWS::NoValuemust remove the property, as CloudFormation does, not leave an empty string. This is on the critical path rather than a nicety: the reporting consumer's template writesand an empty-string
commandon a container definition is a different observable from an absent one.Where the fix applies — and where it must not. The gap is per-property, which is why a consumer cannot predict it:
deployEC2LaunchTemplate(emulator/betty_cfn_v77_plugins.go:34) enumeratesLaunchTemplateDatakey by key and therefore does resolve nested intrinsics, whileContainerDefinitions(betty_cfn_v21_plugins.go:150) and DynamoDB'sKeySchema/AttributeDefinitions/ProvisionedThroughput/GlobalSecondaryIndexes/LocalSecondaryIndexes/StreamSpecification(betty_cfn.go:1870-1890) are forwarded whole. Those forwarding sites are where aresolveNestedgoes.It should not be applied blindly to every
propsmap. An IAM policy document is a property whose interior is meaningful in its own right and needs a separate decision.A guard worth stating, because it is the highest-value mutation test. DynamoDB's verbatim forwarding is correct on the key-naming axis — the DynamoDB API is natively PascalCase, so
KeySchema/AttributeNameare exactly right on the wire. Only its values need resolving. A generic case-converting walk applied here would break DynamoDB, which is why #527's mapping must be a per-service table and why "apply the ECS key table to DynamoDB's properties" is one of the mutants this fix must be shown to catch.fix(cfn): resolve intrinsics at any depth, and map ECS member names (#…