title: Initial setup of terraform backend using terraform
body: <p>I'm just getting started with terraform and I'd like to be able to use AWS S3 as my backend for storing the state of my projects. </p>
  
  <pre class="lang-hcl prettyprint-override"><code>terraform {
      backend "s3" {
        bucket = "tfstate"
        key = "app-state"
        region = "us-east-1"
      }
  }
  </code></pre>
  
  <p>I feel like it is sensible to setup my S3 bucket, IAM groups and polices for the backend storage infrastructure with terraform as well. </p>
  
  <p>If I setup my backend state before I apply my initial terraform infrastructure, it reasonably complains that the backend bucket is not yet created. So, my question becomes, how do I setup my terraform backend with terraform, while keeping my state for the backend tracked by terraform. Seems like a nested dolls problem.</p>
  
  <p>I have some thoughts about how to script around this, for example, checking to see if the bucket exists or some state has been set, then bootstrapping terraform and finally copying the terraform tfstate up to s3 from the local file system after the first run. But before going down this laborious path, I thought I'd make sure I wasn't missing something obvious.</p>