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

Timeout destroying aws_db_instance #310

Closed
ncraike opened this issue Sep 19, 2014 · 5 comments
Closed

Timeout destroying aws_db_instance #310

ncraike opened this issue Sep 19, 2014 · 5 comments

Comments

@ncraike
Copy link

ncraike commented Sep 19, 2014

I've created an AWS RDS instance with Terraform, but since I can't currently control what VPC it's created in, for the moment I'd like to destroy the one I've made and create the RDS by hand outside of Terraform.

As such, I've removed the aws_db_instance resource from my Terraform config by renaming the .tf file. terraform plan correctly shows that Terraform plans to destroy the instance, but when I try to apply the plan, Terraform never completes destroying the instance.

The console output for the plan and apply is below, along with timestamps so the length of timeout can be seen:

$ terraform plan -out latest.tfplan; date; terraform apply latest.tfplan; date 
Refreshing Terraform state prior to plan...

aws_db_instance.db: Refreshing state... (ID: watt-realty)
aws_vpc.main_vpc: Refreshing state... (ID: vpc-6a08e30f)
aws_security_group.http_from_juniorcru_bne_office: Refreshing state... (ID: sg-f3a96a96)
aws_security_group.ssh_from_juniorcru_bne_office: Refreshing state... (ID: sg-f2a96a97)
aws_internet_gateway.gateway: Refreshing state... (ID: igw-ac0b11ce)
aws_subnet.main_subnet: Refreshing state... (ID: subnet-4b53b53c)
aws_security_group.ssh_from_matt_daniels_home_ip: Refreshing state... (ID: sg-c1a86ba4)
aws_security_group.http_from_anywhere: Refreshing state... (ID: sg-fda96a98)
aws_route_table.main_routes: Refreshing state... (ID: rtb-860ef9e3)
aws_instance.webserver: Refreshing state... (ID: i-313ab10f)
aws_route_table_association.associate_main_subnet_to_main_routes: Refreshing state... (ID: rtbassoc-0c718069)

The Terraform execution plan has been generated and is shown below.
Resources are shown in alphabetical order for quick scanning. Green resources
will be created (or destroyed and then created if an existing resource
exists), yellow resources are being changed in-place, and red resources
will be destroyed.

Your plan was also saved to the path below. Call the "apply" subcommand
with this plan file and Terraform will exactly execute this execution
plan.

Path: latest.tfplan

- aws_db_instance.db


Fri Sep 19 10:19:39 AEST 2014
aws_db_instance.db: Destroying...
aws_db_instance.db: Error: timeout while waiting for state to become ''
Error applying plan:

1 error(s) occurred:

* timeout while waiting for state to become ''

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.
Fri Sep 19 10:29:39 AEST 2014

The config for the aws_db_instance was this:

resource "aws_db_instance" "db" {
    identifier = "${var.project_hyphenated}"
    allocated_storage = 10
    engine = "mysql"
    engine_version = "5.6.17"
    instance_class = "db.t2.small"
    name = "${var.project}_production"
    username = "root"
    password = "${var.db_root_password}"
    security_group_names = []
}

The project and project_hyphenated variables are simply strings like "project_name" and "project-name". As mentioned above, I've disabled the resource config by renaming the file to "database-instance.tf.disabled".

The rest of the config is spread across multiple files, and quite long, and I don't think is relevant to the configuration of this resource. Let me know if any more details are useful, though.

@ncraike ncraike changed the title Time out destroying aws_db_instance Timeout destroying aws_db_instance Sep 19, 2014
@ncraike
Copy link
Author

ncraike commented Sep 19, 2014

I should mention that the AWS account is brand new (created yesterday), so the RDS instance was created in a VPC (as opposed to the "EC2 classic"-style instances which have no explicit VPC, use DB security groups, etc).

@shogs
Copy link

shogs commented Sep 19, 2014

Just on this, I had the same issue, the timeout for aws db instance in Terraform is set to 10 minutes. I had to modify the terraform code to extend that as creating an aws rds (postgresql) takes just over 10 minutes.

It would be nice to have timeouts configurable somehow, was planning to look into that myself but haven't had much time recently.

@ncraike
Copy link
Author

ncraike commented Sep 19, 2014

Looking at the AWS console during the run, and even now, there weren't any signs the RDS instance was actually being destroyed (it didn't appear to change state at any point). And it's still alive now. So... although some RDS operations can take a while, that doesn't seem like the problem here.

@wilb
Copy link

wilb commented Sep 25, 2014

This appears to be happening with RDS instances that have been created with the recently merged VPC code too - I can now create them fine but not destroy them unfortunately.

@mitchellh
Copy link
Contributor

This should be fixed now. It looks like we werent properly reporting the destroy error.

@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

4 participants