Skip to content

fix: topologically sort CloudFormation resources before provisioning#332

Merged
hectorvent merged 1 commit intofloci-io:mainfrom
ctnnguyen:fix/cloudformation-dependency-ordering
Apr 11, 2026
Merged

fix: topologically sort CloudFormation resources before provisioning#332
hectorvent merged 1 commit intofloci-io:mainfrom
ctnnguyen:fix/cloudformation-dependency-ordering

Conversation

@ctnnguyen
Copy link
Copy Markdown
Contributor

@ctnnguyen ctnnguyen commented Apr 10, 2026

Summary

Fixes #331

CloudFormationService.executeTemplate provisioned resources in JSON/YAML field iteration order with no dependency analysis. If a resource referenced another via Ref, Fn::GetAtt, or Fn::Sub, and the referenced resource appeared later in the template, the intrinsic function fell back to a literal string (e.g. CredentialsQueue.Arn instead of the actual ARN).

Adds a topological sort (Kahn's algorithm) that scans resource Properties for Ref, Fn::GetAtt, Fn::Sub variable references (including ${Resource} and ${Resource.Attr} shorthand), and explicit DependsOn declarations. Resources with false conditions are excluded from the graph. Cycles fall back to original ordering.

Type of change

  • Bug fix (fix:)
  • New feature (feat:)
  • Breaking change (feat!: or fix!:)
  • Docs / chore

AWS Compatibility

CloudFormation provisions resources respecting implicit dependencies from Ref, Fn::GetAtt, Fn::Sub, and explicit DependsOn. Without dependency ordering, templates where a resource appears before its dependency in the file would fail to resolve intrinsic functions correctly.

Checklist

  • ./mvnw test passes locally
  • New or updated integration test added
  • Commit messages follow Conventional Commits

@ctnnguyen ctnnguyen force-pushed the fix/cloudformation-dependency-ordering branch 2 times, most recently from b4a73e8 to c35707b Compare April 10, 2026 14:57
@ctnnguyen ctnnguyen force-pushed the fix/cloudformation-dependency-ordering branch from c35707b to 67d83de Compare April 10, 2026 15:04
@ctnnguyen ctnnguyen marked this pull request as ready for review April 10, 2026 15:08
@ctnnguyen ctnnguyen marked this pull request as draft April 10, 2026 15:09
@ctnnguyen ctnnguyen marked this pull request as ready for review April 10, 2026 15:10
@hectorvent
Copy link
Copy Markdown
Collaborator

Thanks @ctnnguyen,

I will take a look soon.

Copy link
Copy Markdown
Collaborator

@hectorvent hectorvent left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ctnnguyen

@hectorvent hectorvent self-assigned this Apr 11, 2026
@hectorvent hectorvent merged commit 7b28155 into floci-io:main Apr 11, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] CloudFormation provisions resources without dependency ordering, causing !GetAtt to fail

2 participants