title: Terraform - Get a value from parameter store and pass to resource
body: <p>We store our latest approved AMIs in AWS parameter store. When creating new instances with Terraform I would like to programatically get this AMI ID. I have a command to pull the AMI ID but I'm not sure how to use it with Terraform.</p>
  
  <p>Here is the command I use to pull the AMI ID:</p>
  
  <pre class="lang-sh prettyprint-override"><code>$(aws ssm get-parameter --name /path/to/ami --query 'Parameter.Value' --output text)
  </code></pre>
  
  <p>And here is my Terraform script:</p>
  
  <pre><code>resource "aws_instance" "nginx" {
    ami           = "ami-c58c1dd3" # pull value from parameter store
    instance_type = "t2.micro"
    #key_name        = "${var.key_name}"
  
    provisioner "remote-exec" {
      inline = [
        "sudo yum install nginx -y",
        "sudo service nginx start"
      ]
    }
  }
  </code></pre>
  
  <p>How can I use the command to pull the AMI ID in the Terraform script?</p>