title: Solving resource dependency in Terraform
body: <p>I'm new to Terraform and I'm trying to create an AWS SNS topic and subscription. My code looks like the following:</p>
  
  <pre><code>provider "aws" {
    region = "${var.aws_region}"
  }
  
  resource "aws_sns_topic" "sns_my_topic" {
    name = "${var.sns_topic_name}"
  }
  
  resource "aws_sns_topic_subscription" "code_commit_notification" {
    depends_on  = ["${aws_sns_topic.sns_my_topic}"]
  
    topic_arn   = "${aws_sns_topic.sns_my_topic.arn}"
    protocol    = "email"    
    endpoint    = "${var.sns_subscribe_endpoint}"
  }
  </code></pre>
  
  <p>However, I get the following error output when running <code>terraform apply</code>:</p>
  
  <p><code>Error: aws_sns_topic_subscription.code_commit_notification: resource depends on 
   non-existent resource '${aws_sns_topic.sns_my_topic}'</code></p>
  
  <p>I was receiving the same error before adding the <code>depends on</code> block above as well (and also moved it out of a module after reading <a href="https://github.com/hashicorp/terraform/issues/10462" rel="noreferrer">https://github.com/hashicorp/terraform/issues/10462</a>). What is the proper way to get Terraform to process these?</p>