How can this be accomplished with the LEAST amount of administrative effort?
Add an export field to the outputs of the first template and import the values in the second template.
Create a custom resource that queries the stack created by the first template and retrieves the required values.
Create a mapping in the first template that is referenced by the second template.
Input the names of resources in the first template and refer to those names in the second template as a parameter.
Explanations:
This option is the most efficient method, as it allows the first template to export necessary values (such as VPC ID, subnet IDs, etc.) using theOutputssection. The second template can then use theFn::ImportValuefunction to reference these exported values directly, which minimizes manual effort and ensures that the templates are linked properly without the need for additional resource queries or mappings.
Creating a custom resource to query the first stack adds unnecessary complexity and overhead. This method would require additional coding and management of the custom resource, which increases administrative effort and does not leverage the built-in CloudFormation capabilities for resource sharing effectively.
Mappings in CloudFormation are used for defining constant values that can be looked up based on specific keys. They cannot reference dynamic resources created by another stack, so this option would not work for passing values between the two templates and would require hardcoding values, which is not ideal for flexibility and maintenance.
This approach requires manual input of resource names or identifiers as parameters in the second template. This can lead to errors and inconsistencies, as any changes to the first template would require manual updates in the second template, making it less efficient and more prone to mistakes compared to using exported values.