简体   繁体   中英

How to add a data resource within a Terraform module

I have a data resource and module like

 data "aws_instances" "XXX" { instance_tags = { Name = "XXXX" } instance_state_names = ["running", "stopped"] } module "XXXX" { count = length(data.aws_instances.ids) source = "./alarms" id = data.aws_instances.ids[count.index] }

How can I move the data block inside the module

Why would you do that?

Data source is a kind of resource.

If you want to use some data out of data source use syntax: data.aws_instances.xxxxx

See terraform docs for that.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM