Hi,
Appreciate any suggestions, recommendations, guidance on following scenario.
I have a requirement to create multiple ec2 instances and of different types with different configuration.
I have created a yaml file for this structure and produced a terraform output using locals to see the structure that terraform sees.
Now what is the variable structure for this scenario (tomcat-variables.tf) and whether it is a good practice to have such structure as future changes on any specific instance shouldn’t impact others?
tomcat (parent module)
- providers.tf
- tomcat.tf
- tomcat-variables.tf
- ec2 (child module)
- main.tf
- outputs.tf
- variables.tf
- ec2 (child module)
Thanks,
Prabhu
yaml content:
tomcat_node_config:
node_type:
- support:
- inv_hostname:
- TOMCAT_SUPPORT_01
- TOMCAT_SUPPORT_02
- instance_type: r6i.xlarge
- app:
- inv_hostname:
- TOMCAT_APP_01
- TOMCAT_APP_02
- instance_type: r6i.large
Terraform outputs:
Changes to Outputs:
- configop = {
- tomcat_node_config = {
- node_type = [
- {
- support = [
- {
- inv_hostname = [
- “TOMCAT_SUPPORT_01”,
- “TOMCAT_SUPPORT_02”,
]
},
- inv_hostname = [
- {
- instance_type = “r6i.xlarge”
},
]
},
- instance_type = “r6i.xlarge”
- {
- support = [
- {
- app = [
- {
- inv_hostname = [
- “TOMCAT_APP_01”,
- “TOMCAT_APP_02”,
]
},
- inv_hostname = [
- {
- instance_type = “r6i.large”
},
]
},
]
}
}
- instance_type = “r6i.large”
- {
- app = [
- {
- node_type = [
- tomcat_node_config = {