title: Terraform circular dependency between services
body: <p>I'm just starting learning terraform and am trying to setup an elastic search cluster with an API gateway in front of it.   I've successfully built the service such that the Elastic Search cluster is built and the output endpoint is passed into the API gateway for the integration request via output variables. </p>
  
  <p>In my initial trials I was using wide open access in the <code>aws_elasticsearch_domain.my_name.access_policies</code> for testing my template code.  This worked fine for testing purposes but for real world use I want to use the ARN of the API gateway in the <code>aws_elasticsearch_domain.my_name.access_policies</code>.  This is problematic seemingly because the <code>aws_api_gateway_integration.my_name.uri</code> needs the <code>aws_elasticsearch_domain.my_name.endpoint</code> to setup the but <code>aws_elasticsearch_domain.my_name.access_policies</code> needs the <code>aws_api_gateway_deployment.my_name.execution_arn</code>. </p>
  
  <p>I'm guessing this is fairly common but I can't figure out how to achieve this through outputs or variables.  </p>
  
  <p>Thanks for any help. </p>