using one terraform inventory into another terrafo

2019-09-19 07:32发布

问题:

I am trying to write a seperate terraform script for aws cloudwatch alerts apart from creating aws instances, i want to use terraform inventory of different terraform script which will build aws instances.How to access the inventory of one terraform script and use it in the cloudwatch alerts terraform script?

Thank you!

回答1:

This is possible if you are using remote state. You will have to use root-level outputs to expose the values you want to be able to access from the second Terraform state (in your example, the aws_instance ids, most likely). You can then use the terraform_remote_state data source in your second terraform configuration to access those outputs.