首页 > 解决方案 > Terraform:无法指定加密标志,因为设备 /dev/sda1 已指定快照

问题描述

我正在迁移我的Autoscaling 组以使用launch_template而不是launch_configuration。(支持T2无限

下面是我的代码片段。

resource "aws_launch_template" "test_launch_template" {
  image_id = "ami_id"
  name_prefix     = "test-pref"
  instance_type   = "t2.small"
  key_name        = "jayesh"
  vpc_security_group_ids = ["sg-23423432","sg-23452115"]
  user_data       = "${base64encode(data.template_file.user_data.rendered)}"
  
  iam_instance_profile {
    name = "test"
  } 
  disable_api_termination = true
  instance_initiated_shutdown_behavior = "terminate"

  block_device_mappings {
    device_name = "/dev/sda1"
    ebs {
      delete_on_termination = true
      volume_size           = "${var.volume_size}"
    }
  }
    
  credit_specification {
    cpu_credits = "unlimited"
  }
  lifecycle {
    create_before_destroy = "true"
  }  
}

运行 terraform apply 时出现以下错误。

发生 1 个错误:

aws_autoscaling_group.test_asg:发生 1 个错误:

aws_autoscaling_group.test_asg:创建 AutoScaling 组时出错:

ValidationError:您必须使用有效的全格式启动模板。无法指定加密标志,因为设备 /dev/sda1 已指定快照。

状态码:400,请求 ID:7902a390-58de-11e8-af77-87d327f8b121

可能是缺少任何参数,但我不确定是哪一个。

根据错误,它看起来指定了加密参数。但我还没有通过。那么为什么会出现这个错误呢?

提前致谢!

标签: amazon-web-servicesterraform

解决方案


推荐阅读