Is it possible to use DependsOn with Fn::ImportValue like this?
"DependsOn": {"Fn::ImportValue": {
"Fn::Sub": "${MyStack1}-VPCGatewayAttachment"
}}
To be specific, I have my VPC and InternetGatewayAttchment in one stack. I'm import this stack in Stack2 where I have my ELB and I'm trying to use DependsOn to depend on this attachment
Fn::ImportValue. The intrinsic function Fn::ImportValue returns the value of an output exported by another stack. You typically use this function to create cross-stack references. In the following example template snippets, Stack A exports VPC security group values and Stack B imports them.
Listing exported output values Amazon CloudFormation shows the names and values of the exported outputs for the current region and the stack from which the outputs are exported. To reference an exported output value in a stack's template, use the export name and the Fn::ImportValue function.
To import existing resources into a CloudFormation stack, you need to provide: A template that describes the entire stack, including both the resources to import and (for existing stacks) the resources that are already part of the stack. Each resource to import must have a DeletionPolicy attribute in the template.
You can use intrinsic functions, such as Fn::If , Fn::Equals , and Fn::Not , to conditionally create stack resources. These conditions are evaluated based on input parameters that you declare when you create or update a stack.
You should not use DependsOn like this. It is only needed when creating dependencies between resources within a template. Specifically it is used to override the sequence Cloudformation creates resources.
The FN::ImportValue
is inherently a dependent function since the Exported Value must exist before stack generation. So just reference your Import Value in the appropriate resource.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With