【问题标题】:Terraform: Error while passing autoscaling group name in aws_autoscaling_schedule resourceTerraform:在 aws_autoscaling_schedule 资源中传递自动缩放组名称时出错
【发布时间】:2019-03-17 04:22:22
【问题描述】:

将模块输出解析到另一个模块资源时出现错误。

错误:

* module.scheduled_action.aws_autoscaling_schedule.asg[0]: 1 error(s) occurred:

    * aws_autoscaling_schedule.asg.0: Error Creating Autoscaling Scheduled Action: ValidationError: AutoScalingGroup name not found - null
        status code: 400, request id: eedacea2-4819-11e9-a48e-2178a7946e4b
    * module.scheduled_action.aws_autoscaling_schedule.asg[1]: 1 error(s) occurred:

    * aws_autoscaling_schedule.asg.1: Error Creating Autoscaling Scheduled Action: ValidationError: AutoScalingGroup name not found - null
        status code: 400, request id: eedbb8f2-4819-11e9-a103-ed59f82b87f3

代码:

scheduled.tf

resource "aws_autoscaling_schedule" "asg" {
  count = "${var.actions_count}"
  ..
  ...
  ....
  autoscaling_group_name = "{var.autoscaling_group_name}"
}

变量.tf

variable "autoscaling_group_name" {}

main.tf

autoscaling_group_name = "${module.launch_configs.asg_name}"

【问题讨论】:

    标签: terraform terraform-provider-aws


    【解决方案1】:

    您将模块变量与局部变量混合在一起。

    main.tf 中,autoscaling_group_name 的值来自名为launch_configs 的模块,因此您可以在资源aws_autoscaling_schedule 中使用相同的名称

    代码可以改成

    resource "aws_autoscaling_schedule" "asg" {
      count = "${var.actions_count}"
      ..
      ...
      ....
      autoscaling_group_name = "${module.launch_configs.asg_name}"
    }
    

    在您的情况下,variables.tf 中变量 autoscaling_group_name 的定义是无用的。你可以删除它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-22
      • 2017-10-20
      • 1970-01-01
      • 2018-03-03
      • 2019-01-23
      • 2021-04-12
      • 2020-09-13
      • 2021-10-26
      相关资源
      最近更新 更多