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

resource depends on non-existent resource when using depends_on #985

Closed
tigreverde opened this issue Feb 17, 2015 · 4 comments · Fixed by #1015
Closed

resource depends on non-existent resource when using depends_on #985

tigreverde opened this issue Feb 17, 2015 · 4 comments · Fixed by #1015
Assignees

Comments

@tigreverde
Copy link

Hi,
I have ran into an issue with a simple config trying to use depends_on and receiving an error.

  • aws_db_instance.db_main: resource depends on non-existent resource '${aws_db_subnet_group.db_subnet}'

tf.config:

tell terraform what provider we are gonig to use

provider "aws" {
    region = "us-west-2"
}

resource "aws_db_subnet_group" "db_subnet" {
    name = "DBSubnet"
    description = "assign the other two VPC subnets"

    subnet_ids = ["${var.second_subnet}", "${var.third_subnet}"]
}

resource "aws_db_instance" "db_main" {
    #depends_on = ["${var.dbsg_name}"]
    #depends_on = "DBSubnet"
    depends_on = "${aws_db_subnet_group.db_subnet}"
    identifier = "DBONE"
    allocated_storage = 5
    engine = "mysql"
    engine_version = "5.6.19b"
    instance_class = "db.t1.micro"
    name = "mydb"
    username = "jason"
    password = "DB0p3nm3"
    vpc_security_group_ids = ["${var.sg_name}"]
    #security_group_names = ["${aws_db_security_group.db.name}"]
    db_subnet_group_name = "DB Subnet"
    #parameter_group_name = "default.mysql5.6"
    final_snapshot_identifier = "snap"
    skip_final_snapshot = "true"
}

This my RDS module to spin up a sql DB, I am wanting terraform to wait an attempt to provision the DB until after the DB subnet net group is online to avoid this issue when I apply my plan:

module.rds2.aws_db_instance.db_main: Error: Error creating DB Instance: DBSubnetGroupNotFoundFault: DBSubnetGroup 'db subnet' not found.

module.rds.aws_db_subnet_group.db_subnet: Creation complete

I tried using depends_on with a variable populated from another module, failed also tried using it in various ways within the same .tf file and still fails. I am rather new to using Terraform, so if it is a simple syntax issue sorry to bother you, but it seems like it should be correct. Any help would be appreciated.

@mitchellh
Copy link
Contributor

depends_on can't contain variables. It must be hardcoded. We should add validation to verify this.

@tigreverde
Copy link
Author

Thanks makes sense

@mitchellh mitchellh reopened this Feb 20, 2015
@mitchellh
Copy link
Contributor

Reopening until we get the PR merged in to do the validation. :)

@ghost
Copy link

ghost commented May 4, 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 May 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants