Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to launch autoscaling group using launch template #4577

Closed
au78 opened this issue May 18, 2018 · 3 comments
Closed

Unable to launch autoscaling group using launch template #4577

au78 opened this issue May 18, 2018 · 3 comments
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.

Comments

@au78
Copy link

au78 commented May 18, 2018

Terraform Version

terraform - 0.11.7
provider.aws - 1.19.0

Affected Resource(s)

  • aws_launch_template

Terraform Configuration Files

# Launch Template config used by cloudformation stack below
resource "aws_launch_template" "mymodule_launch_template" {
  name_prefix                          = "mymodule-lt-"
  image_id                             = "mymodule-ami"
  instance_initiated_shutdown_behavior = "terminate"
  instance_type                        = "m4.xlarge"
  vpc_security_group_ids               = ["group1", "group2"]

  block_device_mappings {
    device_name = "/dev/xvds"

    ebs {
      volume_type = "io1"
      volume_size = "100"
      iops        = "3000"
      encrypted   = false
    }
  }

  iam_instance_profile {
    name = "my_iam_profile"
  }
}
==============================================================
# Cloudformation stack used launch template defined above
resource "aws_cloudformation_stack" "mymodule_asg" {
  name          = "mymodule-stack"
  depends_on    = ["aws_launch_template.mymodule_launch_template"]

  lifecycle {
    create_before_destroy = true
  }

  template_body = <<EOF
{
  "Resources": {
    "${local.resource_name}": {
      "Type": "AWS::AutoScaling::AutoScalingGroup",
      "Properties": {
        "VPCZoneIdentifier": ${jsonencode(var.subnet_ids)},
        "LaunchTemplate": {
          "LaunchTemplateId": "${aws_launch_template.mymodule_launch_template.id}"
        },
        "MaxSize": ${var.number_of_instances},
        "MinSize": ${var.number_of_instances},
        "DesiredCapacity": ${var.number_of_instances},
        "LoadBalancerNames": ["${aws_elb.mymodule_elb.id}"],
        "TerminationPolicies": ["OldestLaunchConfiguration", "OldestInstance"],
        "HealthCheckType": "ELB",
        "HealthCheckGracePeriod" : ${var.instance_health_grace_period_secs},
        "Tags" : ${jsonencode(local.module_tag_list)}
      },
      "CreationPolicy" : {
        "AutoScalingCreationPolicy" : {
          "MinSuccessfulInstancesPercent" : 100
        },
        "ResourceSignal" : {
          "Count" : ${var.number_of_instances},
          "Timeout" : "PT${var.creation_timeout_mins}M"
        }
      },
      "UpdatePolicy": {
        "AutoScalingRollingUpdate": {
          "MinInstancesInService": 1,
          "MaxBatchSize": 1,
          "PauseTime": "PT${var.instance_upgrade_timeout_mins}M",
          "WaitOnResourceSignals" : true
        }
      }
    }
  },
  "Outputs": {
    "AsgName": {
      "Description": "The name of the auto scaling group",
       "Value": {"Ref": "mymoduleAsg"}
    }
  }
}
EOF
}

Panic Output

Expected Behavior

launch template should have been created successfully

Actual Behavior

2018/05/18 00:10:12 [ERROR] root.mymodule: eval: *terraform.EvalApplyPost, err: 1 error(s) occurred:

* aws_cloudformation_stack.mymodule_asg: ROLLBACK_COMPLETE: ["The following resource(s) failed to create: [TfEsTestClusterAsg]. . Rollback requested by user." "You must use a valid fully-formed launch template. the encrypted flag cannot be specified since device /dev/xvds has a snapshot specified."]
2018/05/18 00:10:12 [ERROR] root.mymodule: eval: *terraform.EvalSequence, err: 1 error(s) occurred:

* aws_cloudformation_stack.mymodule_asg: ROLLBACK_COMPLETE: ["The following resource(s) failed to create: [TfEsTestClusterAsg]. . Rollback requested by user." "You must use a valid fully-formed launch template. the encrypted flag cannot be specified since device /dev/xvds has a snapshot specified."]
2018/05/18 00:10:12 [TRACE] [walkApply] Exiting eval tree: module.mymodule.aws_cloudformation_stack.mymodule_asg

Error: Error applying plan:

1 error(s) occurred:

* module.mymodule.aws_cloudformation_stack.mymodule_asg: 1 error(s) occurred:

* aws_cloudformation_stack.mymodule_asg: ROLLBACK_COMPLETE: ["The following resource(s) failed to create: [TfEsTestClusterAsg]. . Rollback requested by user." "You must use a valid fully-formed launch template. the encrypted flag cannot be specified since device /dev/xvds has a snapshot specified."]

Steps to Reproduce

  1. terraform apply

Important Factoids

  • The AMI used is a custom AMI that is created using packer. This AMI add a block device called /dev/xvds. But encryption has been turned off.
  • Autoscaling group is uses the custom AMI to launch an ec2 instance.

References

Checked the following similar issues but none helped... thus opening this new ticket

@au78 au78 changed the title Unable to create autoscaling group using launch template Unable to launch autoscaling group using launch template May 18, 2018
@djdevin
Copy link

djdevin commented May 18, 2018

Same issue here #4553

@bflad
Copy link
Contributor

bflad commented May 18, 2018

Thanks for this report @au78 and sorry you're having trouble. Let's consolidate discussion and efforts in the earlier bug report: #4553

@bflad bflad closed this as completed May 18, 2018
@bflad bflad added bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service. labels May 18, 2018
@ghost
Copy link

ghost commented Apr 5, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality. service/ec2 Issues and PRs that pertain to the ec2 service.
Projects
None yet
Development

No branches or pull requests

3 participants