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

provider/aws: fix force_delete on ASGs #3485

Merged
merged 1 commit into from
Oct 12, 2015
Merged

Conversation

phinze
Copy link
Contributor

@phinze phinze commented Oct 12, 2015

The ForceDelete parameter was getting sent to the upstream API call,
but only after we had already finished draining instances from
Terraform, so it was a moot point by then.

This fixes that by skipping the drain when force_delete is true, and it
also simplifies the field config a bit:

  • set a default of false to simplify the logic
  • remove ForceNew since there's no need to replace the resource to
    flip this value
  • pull a detail comment from code into the docs

@@ -414,6 +407,11 @@ func getAwsAutoscalingGroup(
func resourceAwsAutoscalingGroupDrain(d *schema.ResourceData, meta interface{}) error {
conn := meta.(*AWSClient).autoscalingconn

if d.Get("force_delete").(bool) {
log.Printf("[DEBUG] Skipping ASG drain, force_delete was set.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nitpick, force_delete may not have been set since it now has a default

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean - it's true if we get to line 411. Is it just the log wording you'd like changed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nope, ignore me I misread that

@catsby
Copy link
Contributor

catsby commented Oct 12, 2015

LGTM

The `ForceDelete` parameter was getting sent to the upstream API call,
but only after we had already finished draining instances from
Terraform, so it was a moot point by then.

This fixes that by skipping the drain when force_delete is true, and it
also simplifies the field config a bit:

 * set a default of false to simplify the logic
 * remove `ForceNew` since there's no need to replace the resource to
   flip this value
 * pull a detail comment from code into the docs
phinze added a commit that referenced this pull request Oct 12, 2015
provider/aws: fix force_delete on ASGs
@phinze phinze merged commit 2978a9f into master Oct 12, 2015
@phinze phinze deleted the b-aws-asg-force-delete branch October 12, 2015 22:18
@maratoid
Copy link

I still seem to be getting blocked on ASG deletion:

https://gist.github.com/maratoid/faa8262aed30400a69f2

Output:

terraform destroy -input=false -force
aws_vpc_dhcp_options.vpc_dhcp: Refreshing state... (ID: dopt-85f008e0)
aws_key_pair.keypair: Refreshing state... (ID: force_delete_key)
aws_vpc.vpc: Refreshing state... (ID: vpc-35530650)
aws_network_acl.vpc_acl: Refreshing state... (ID: acl-a2b5fec7)
aws_security_group.vpc_secgroup: Refreshing state... (ID: sg-ae7313ca)
aws_subnet.vpc_subnet: Refreshing state... (ID: subnet-c4a93a9d)
aws_internet_gateway.vpc_gateway: Refreshing state... (ID: igw-8c0097e9)
aws_vpc_dhcp_options_association.vpc_dhcp_association: Refreshing state... (ID: dopt-85f008e0-vpc-35530650)
aws_launch_configuration.node_autoscaled: Refreshing state... (ID: terraform-uxvbdyi2vnhabd3fqu7bkzjyj4)
aws_route_table.vpc_rt: Refreshing state... (ID: rtb-d51a46b0)
aws_instance.node_special: Refreshing state... (ID: i-54eab18f)
aws_route_table_association.vpc_rt_association: Refreshing state... (ID: rtbassoc-7bdde91e)
aws_main_route_table_association.a: Refreshing state... (ID: rtbassoc-7adde91f)
aws_autoscaling_group.nodes_autoscaled: Refreshing state... (ID: force_delete_nodes)
aws_instance.node_dependent: Refreshing state... (ID: i-00e9b2db)
aws_instance.node_dependent: Destroying...
aws_network_acl.vpc_acl: Destroying...
aws_vpc_dhcp_options_association.vpc_dhcp_association: Destroying...
aws_instance.node_special: Destroying...
aws_main_route_table_association.a: Destroying...
aws_route_table_association.vpc_rt_association: Destroying...
aws_route_table_association.vpc_rt_association: Destruction complete
aws_vpc_dhcp_options_association.vpc_dhcp_association: Destruction complete
aws_vpc_dhcp_options.vpc_dhcp: Destroying...
aws_main_route_table_association.a: Destruction complete
aws_route_table.vpc_rt: Destroying...
aws_route_table.vpc_rt: Destruction complete
aws_internet_gateway.vpc_gateway: Destroying...
aws_network_acl.vpc_acl: Destruction complete
aws_vpc_dhcp_options.vpc_dhcp: Destruction complete
aws_instance.node_dependent: Destruction complete
aws_autoscaling_group.nodes_autoscaled: Destroying...
aws_instance.node_special: Destruction complete
Error applying plan:

2 error(s) occurred:

* aws_internet_gateway.vpc_gateway: Error waiting for internet gateway (igw-8c0097e9) to detach: couldn't find resource
* aws_autoscaling_group.nodes_autoscaled: Auto Scaling Group still exists

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.

@phinze
Copy link
Contributor Author

phinze commented Oct 13, 2015

Thanks for testing @maratoid - reproduced locally and digging in...

@maratoid
Copy link

Much appreciated.

@maratoid
Copy link

BTW, should I open a tracking issue, or is the conversation in here sufficient?
Thanks!

@phinze
Copy link
Contributor Author

phinze commented Oct 13, 2015

@maratoid turned into a bit of a rabbit hole - i will open a fresh issue 👍 🐰

@ghost
Copy link

ghost commented Apr 30, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

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

Successfully merging this pull request may close these issues.

3 participants