Reputation: 6957
When creating a Custom CloudFormation Resource implementation, the created resource can later be used to "add" more dependant children onto itself.
For example:
ResourceA:
Type: Custom::Parent
ResourceB:
Type: Custom::Child
Properties:
Parent: !Ref ResourceA
Is it sufficient to just add DependsOn
to ResourceB
to make sure that it gets removed before ResourceA
receives the Delete
request? Like so -
ResourceB:
DependsOn: ResourceA
Type: Custom::Child
Properties:
Parent: !Ref ResourceA
Or will there be a case where ResourceA
receives a Delete
request and fails, before ResourceB
finished its process of removal?
Upvotes: 0
Views: 215
Reputation: 1046
In this case you don't even need the DependsOn
. Since you have a reference to A in the properties of B, cloudformation knows that B has a dependency on A, and will only start creating B when A is created.
For deleting, the reverse happens: first B will be removed, then A.
Cloudformation only deletes resources when no other resource depends on it.
Upvotes: 1