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

aws_autoscaling_group and aws_launch_config set for destruction 2nd time running #425

Closed
mahnve opened this issue Oct 16, 2014 · 2 comments

Comments

@mahnve
Copy link

mahnve commented Oct 16, 2014

I have a aws_autoscaling_group and a aws_launch_configuration like so:

resource "aws_launch_configuration" "cyclops_lc" {
  name="dryleaf-cyclops-lc"
  image_id="..."
  instance_type="t2.medium"
  key_name="..."
  security_groups=["...", "..."]
}

resource "aws_autoscaling_group" "cyclops_asg" {
  name="dryleaf-cyclops-asg"
  max_size=6
  min_size=2
  desired_capacity=2
  availability_zones=["us-east-1a", "us-east-1d"]
  health_check_grace_period=300
  force_delete="false"
  default_cooldown=300
  health_check_type="ELB"
  launch_configuration="${aws_launch_configuration.cyclops_lc.name}"
  load_balancers=["${aws_elb.web_elb.name}"]
  vpc_zone_identifier=["...", "..."]
}

running it the first time goes fine. Second time though, it seems to infer changes without the config have changed, which makes it want to recreate the auto scaling group:

$ make tf-apply
mkdir -p build
cd terraform; terraform apply
aws_security_group.nat: Refreshing state... (ID: sg-f3969396)
aws_security_group.db: Refreshing state... (ID: sg-59f6ae3c)
aws_security_group.ssh: Refreshing state... (ID: sg-71c8cc14)
aws_security_group.external_web: Refreshing state... (ID: sg-60d7f005)
aws_security_group.jump: Refreshing state... (ID: sg-51f6ae34)
aws_vpc.dryleaf: Refreshing state... (ID: vpc-129a2c77)
aws_launch_configuration.cyclops_lc: Refreshing state... (ID: dryleaf-cyclops-lc)
aws_internet_gateway.gw: Refreshing state... (ID: igw-7d1fd718)
aws_subnet.db-1d: Refreshing state... (ID: subnet-d1f027a6)
aws_subnet.db-1a: Refreshing state... (ID: subnet-1685744f)
aws_subnet.private-1d: Refreshing state... (ID: subnet-16329661)
aws_subnet.private-1a: Refreshing state... (ID: subnet-1ac50343)
aws_subnet.app-1d: Refreshing state... (ID: subnet-17329660)
aws_subnet.app-1a: Refreshing state... (ID: subnet-1fc50346)
aws_subnet.front-1d: Refreshing state... (ID: subnet-d4f027a3)
aws_subnet.front-1a: Refreshing state... (ID: subnet-09857450)
aws_route_table.public: Refreshing state... (ID: rtb-c55feba0)
aws_instance.wolverine: Refreshing state... (ID: i-e68cc50b)
aws_instance.nat_box: Refreshing state... (ID: i-f13f701c)
aws_route_table_association.app-1a: Refreshing state... (ID: rtbassoc-62009007)
aws_route_table_association.app-1d: Refreshing state... (ID: rtbassoc-61009004)
aws_route_table_association.front-1a: Refreshing state... (ID: rtbassoc-60009005)
aws_route_table_association.front-1d: Refreshing state... (ID: rtbassoc-63009006)
aws_elb.web_elb: Refreshing state... (ID: dryleaf-web)
aws_autoscaling_group.cyclops_asg: Refreshing state... (ID: dryleaf-cyclops-asg)
aws_autoscaling_group.cyclops_asg: Destroying...
aws_security_group.db: Modifying...
  ingress.0.security_groups.#: "0" => "1"
  ingress.0.security_groups.0: "" => "sg-59f6ae3c"
  ingress.0.self:              "1" => ""
aws_security_group.external_web: Modifying...
  ingress.0.cidr_blocks.#: "1" => "0"
  ingress.0.cidr_blocks.0: "0.0.0.0/0" => ""
  ingress.0.from_port:     "80" => "443"
  ingress.0.self:          "0" => ""
  ingress.0.to_port:       "80" => "443"
  ingress.1.cidr_blocks.#: "1" => "0"
  ingress.1.cidr_blocks.0: "0.0.0.0/0" => ""
  ingress.1.from_port:     "443" => "80"
  ingress.1.self:          "0" => ""
  ingress.1.to_port:       "443" => "80"
aws_autoscaling_group.cyclops_asg: Error: ResourceInUse: You cannot delete an AutoScalingGroup while there are instances or pending Spot instance request(s) still in the group.
aws_security_group.db: Modifications complete
aws_security_group.external_web: Modifications complete
aws_launch_configuration.cyclops_lc: Modifying...
  image_id:          "ami-24ac174c" => "ami-24ac174c"
  instance_type:     "t2.medium" => "t2.medium"
  key_name:          "qwaya-default" => "qwaya-default"
  name:              "dryleaf-cyclops-lc" => "dryleaf-cyclops-lc"
  security_groups.#: "1" => "2"
  security_groups.0: "sg-71c8cc14" => "sg-71c8cc14"
  security_groups.1: "" => "sg-60d7f005"
aws_elb.web_elb: Modifying...
  health_check.0.healthy_threshold:   "10" => "3"
  health_check.0.target:              "TCP:80" => "HTTP:80/_monitor"
  health_check.0.timeout:             "5" => "3"
  health_check.0.unhealthy_threshold: "2" => "3"
  listener.0.instance_protocol:       "HTTP" => "http"
  listener.0.lb_protocol:             "HTTP" => "http"
aws_launch_configuration.cyclops_lc: Error: ResourceInUse: Cannot delete launch configuration dryleaf-cyclops-lc because it is attached to AutoScalingGroup dryleaf-cyclops-asg
aws_elb.web_elb: Modifications complete
Error applying plan:

1 error(s) occurred:

* ResourceInUse: You cannot delete an AutoScalingGroup while there are instances or pending Spot instance request(s) still in the group.

Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
Makefile:15: recipe for target 'build/terraform_marker_file' failed
make: *** [build/terraform_marker_file] Error 1
@mitchellh
Copy link
Contributor

Looks like a bug. Thanks.

@mitchellh
Copy link
Contributor

Fixed

@ghost ghost locked and limited conversation to collaborators May 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants