V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
wandehul
V2EX  ›  程序员

terraform 的 output 问题

  •  
  •   wandehul · 2021-05-28 17:37:08 +08:00 · 688 次点击
    这是一个创建于 1035 天前的主题,其中的信息可能已经有所发展或是发生改变。

    内容:

    子 mudule main.tf

        module "ec2s"  {
         source = "xxxxx/aws"
    
         count = 3
         xxxxx
         instance_type = var.instance_type
    
         xxxxxx
        }
    

    main.tf:

    module "create_ec2s" { 
    	source = "./path/ec2s"
        
    	for_each = var.instance_types
        
        instance_type = each.value.types
    	xxxxx
    
    }
    

    这种嵌套引用,又有 for_each 又有 count 的 instance ip 怎么 output 出来:

    output "ips" {
    	value = {for p in keys(var.instance_types) : p => module.ec2s[p].xxxx_ip}
    }
    

    总是报错, 我也不知道这个 ec2s[p] 是一个什么结构,如何知道这个结构呢 ,

    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5390 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 33ms · UTC 07:02 · PVG 15:02 · LAX 00:02 · JFK 03:02
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.