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

Postgres provider: failure on destroy #5340

Closed
saliceti opened this issue Feb 26, 2016 · 2 comments
Closed

Postgres provider: failure on destroy #5340

saliceti opened this issue Feb 26, 2016 · 2 comments

Comments

@saliceti
Copy link
Contributor

It looks like the dependency is not respected when destroying postgres roles, databases and RDS instance. However, the graph shows the dependency clearly.
image
This is with terraform 0.6.12.

Code:

resource "aws_db_instance" "cf" {
  identifier = "cf"
  allocated_storage = 10
  engine = "postgres"
  engine_version = "9.4.5"
  instance_class = "db.t2.micro"
  username = "dbadmin"
  password = "abcd"
  db_subnet_group_name = "${aws_db_subnet_group.cf_rds.name}"
  parameter_group_name = "${aws_db_parameter_group.default.id}"

  vpc_security_group_ids = ["${aws_security_group.cf_rds.id}"]
}

provider "postgresql" {
  host = "${aws_db_instance.cf.address}"
  username = "abcd"
  password = "abcd"
}

resource "postgresql_role" "api" {
  name = "api"
  login = true
  password = "abcd"
}

resource "postgresql_database" "apidb" {
   name = "apidb"
   owner = "${postgresql_role.api.name}"
}

Error:

...
aws_db_instance.cf: Destroying...
...
aws_db_instance.cf: Destruction complete
...
postgresql_database.uaadb: Destroying...
postgresql_database.apidb: Destroying...
Error applying plan:

2 error(s) occurred:

* postgresql_database.uaadb: Error granting membership: dial tcp 10.0.1.185:5432: getsockopt: connection timed out
* postgresql_database.apidb: Error granting membership: dial tcp 10.0.1.185:5432: getsockopt: connection timed out

The only way to solve this issue is to edit the state file manually...

The state file shows only the remaining postgres resources:

{
    "version": 1,
    "serial": 24,
    "modules": [
        {
            "path": [
                "root"
            ],
            "resources": {
                "postgresql_database.apidb": {
                    "type": "postgresql_database",
                    "depends_on": [
                        "postgresql_role.api"
                    ],
                    "primary": {
                        "id": "apidb",
                        "attributes": {
                            "id": "apidb",
                            "name": "apidb",
                            "owner": "api"
                        }
                    }
                },
                "postgresql_role.api": {
                    "type": "postgresql_role",
                    "primary": {
                        "id": "api",
                        "attributes": {
                            "encrypted": "false",
                            "id": "api",
                            "login": "true",
                            "name": "api",
                            "password": "abcd"
                        }
                    }
                }
            }
        }
    ]
}
@saliceti saliceti changed the title postgres provider: failure on destroy Postgres provider: failure on destroy Feb 26, 2016
saliceti added a commit to alphagov/paas-cf that referenced this issue Feb 29, 2016
The previous postgres job was doing some work to initialise
the databases: create roles, create databases, enable extensions.

Most of this work should have been done with the postgres terraform
provider, but it has bugs and can't destroy the resources properly:
hashicorp/terraform#5340

When this is fixed, we can move the create role and db tasks to
terraform, but we still need to enable extensions.
saliceti added a commit to alphagov/paas-cf that referenced this issue Feb 29, 2016
The previous postgres job was doing some work to initialise
the databases: create roles, create databases, enable extensions.

Most of this work should have been done with the postgres terraform
provider, but it has bugs and can't destroy the resources properly:
hashicorp/terraform#5340

When this is fixed, we can move the create role and db tasks to
terraform, but we still need to enable extensions.
saliceti added a commit to alphagov/paas-cf that referenced this issue Feb 29, 2016
The previous postgres job was doing some work to initialise
the databases: create roles, create databases, enable extensions.

Most of this work should have been done with the postgres terraform
provider, but it has bugs and can't destroy the resources properly:
hashicorp/terraform#5340

When this is fixed, we can move the create role and db tasks to
terraform, but we still need to enable extensions.
saliceti added a commit to alphagov/paas-cf that referenced this issue Feb 29, 2016
The previous postgres job was doing some work to initialise
the databases: create roles, create databases, enable extensions.

Most of this work should have been done with the postgres terraform
provider, but it has bugs and can't destroy the resources properly:
hashicorp/terraform#5340

When this is fixed, we can move the create role and db tasks to
terraform, but we still need to enable extensions.
saliceti added a commit to alphagov/paas-cf that referenced this issue Mar 1, 2016
The previous postgres job was doing some work to initialise
the databases: create roles, create databases, enable extensions.

Most of this work should have been done with the postgres terraform
provider, but it has bugs and can't destroy the resources properly:
hashicorp/terraform#5340

When this is fixed, we can move the create role and db tasks to
terraform, but we still need to enable extensions.
saliceti added a commit to alphagov/paas-cf that referenced this issue Mar 1, 2016
The previous postgres job was doing some work to initialise
the databases: create roles, create databases, enable extensions.

Most of this work should have been done with the postgres terraform
provider, but it has bugs and can't destroy the resources properly:
hashicorp/terraform#5340

When this is fixed, we can move the create role and db tasks to
terraform, but we still need to enable extensions.
saliceti added a commit to alphagov/paas-cf that referenced this issue Mar 1, 2016
The previous postgres job was doing some work to initialise
the databases: create roles, create databases, enable extensions.

Most of this work should have been done with the postgres terraform
provider, but it has bugs and can't destroy the resources properly:
hashicorp/terraform#5340

When this is fixed, we can move the create role and db tasks to
terraform, but we still need to enable extensions.
@mitchellh
Copy link
Contributor

Fixed by #10659

@ghost
Copy link

ghost commented Apr 18, 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 18, 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