title: Aws KInesis Terraform - How to connect Data Streams to Data Firehose
body: <p>I want to create using terraform, Kinesis datastream and data firehose, and connect them (as pipeline). When I use the UI, when I go to firehose I can go to source->Kinesis stream, and pick the kinesis stream I created. But I want to do it using terraform.</p>
  
  <p>This is the code to create kinesis stream (I took it from the official kinesis docs):</p>
  
  <pre><code>resource "aws_kinesis_stream" "test_stream" {
    name             = "terraform-kinesis-test"
    shard_count      = 1
    retention_period = 30
  
    shard_level_metrics = [
      "IncomingBytes",
      "OutgoingBytes",
    ]
  
    tags = {
      Environment = "test"
    }
  </code></pre>
  
  <p>And this is the code for data firehose:</p>
  
  <pre><code>resource "aws_elasticsearch_domain" "test_cluster" {
    domain_name = "firehose-es-test"
    elasticsearch_version = "6.4"
      cluster_config {
      instance_type = "t2.small.elasticsearch"
    }
    ebs_options{
      ebs_enabled = true
      volume_size = 10
    }
  
  }
  
  resource "aws_iam_role" "firehose_role" {
    name = "firehose_test_role"
  
    assume_role_policy = &lt;&lt;EOF
  {
    "Version": "2012-10-17",
    "Statement": [
      {
        "Action": "sts:AssumeRole",
        "Principal": {
          "Service": "firehose.amazonaws.com"
        },
        "Effect": "Allow",
        "Sid": ""
      }
    ]
  }
  EOF
  }
  resource "aws_kinesis_firehose_delivery_stream" "test_stream" {
    name        = "terraform-kinesis-firehose-test-stream"
    destination = "elasticsearch"
  /*
    s3_configuration {
      role_arn           = "${aws_iam_role.firehose_role.arn}"
      bucket_arn         = "${aws_s3_bucket.bucket.arn}"
      buffer_size        = 10
      buffer_interval    = 400
      compression_format = "GZIP"
    }
  */
    elasticsearch_configuration {
      domain_arn = "${aws_elasticsearch_domain.test_cluster.arn}"
      role_arn   = "${aws_iam_role.firehose_role.arn}"
      index_name = "test"
      type_name  = "test"
  
      processing_configuration {
        enabled = "true"
  
      }
    }
  }
  </code></pre>
  
  <p>So how can I connect them, is the something like ${aws_kinesis_stream.test_stream.arn} ? or something similar?</p>
  
  <p>I used the official docs of <a href="https://www.terraform.io/docs/providers/aws/r/kinesis_stream.html" rel="nofollow noreferrer">aws_kinesis_stream</a> and <a href="https://www.terraform.io/docs/providers/aws/r/kinesis_firehose_delivery_stream.html" rel="nofollow noreferrer">aws_kinesis_firehose_delivery_stream</a> (elasticsearch destination).</p>