github.com/danp/terraform@v0.9.5-0.20170426144147-39d740081351/builtin/providers/aws/data_source_aws_kinesis_stream.go (about) 1 package aws 2 3 import ( 4 "github.com/aws/aws-sdk-go/aws" 5 "github.com/aws/aws-sdk-go/service/kinesis" 6 "github.com/hashicorp/terraform/helper/schema" 7 ) 8 9 func dataSourceAwsKinesisStream() *schema.Resource { 10 return &schema.Resource{ 11 Read: dataSourceAwsKinesisStreamRead, 12 13 Schema: map[string]*schema.Schema{ 14 "name": &schema.Schema{ 15 Type: schema.TypeString, 16 Required: true, 17 }, 18 19 "arn": &schema.Schema{ 20 Type: schema.TypeString, 21 Computed: true, 22 }, 23 24 "creation_timestamp": &schema.Schema{ 25 Type: schema.TypeInt, 26 Computed: true, 27 }, 28 29 "status": &schema.Schema{ 30 Type: schema.TypeString, 31 Computed: true, 32 }, 33 34 "retention_period": &schema.Schema{ 35 Type: schema.TypeInt, 36 Computed: true, 37 }, 38 39 "open_shards": &schema.Schema{ 40 Type: schema.TypeSet, 41 Computed: true, 42 Elem: &schema.Schema{Type: schema.TypeString}, 43 Set: schema.HashString, 44 }, 45 46 "closed_shards": &schema.Schema{ 47 Type: schema.TypeSet, 48 Computed: true, 49 Elem: &schema.Schema{Type: schema.TypeString}, 50 Set: schema.HashString, 51 }, 52 53 "shard_level_metrics": &schema.Schema{ 54 Type: schema.TypeSet, 55 Computed: true, 56 Elem: &schema.Schema{Type: schema.TypeString}, 57 Set: schema.HashString, 58 }, 59 60 "tags": &schema.Schema{ 61 Type: schema.TypeMap, 62 Computed: true, 63 }, 64 }, 65 } 66 } 67 68 func dataSourceAwsKinesisStreamRead(d *schema.ResourceData, meta interface{}) error { 69 conn := meta.(*AWSClient).kinesisconn 70 sn := d.Get("name").(string) 71 72 state, err := readKinesisStreamState(conn, sn) 73 if err != nil { 74 return err 75 } 76 d.SetId(state.arn) 77 d.Set("arn", state.arn) 78 d.Set("name", sn) 79 d.Set("open_shards", state.openShards) 80 d.Set("closed_shards", state.closedShards) 81 d.Set("status", state.status) 82 d.Set("creation_timestamp", state.creationTimestamp) 83 d.Set("retention_period", state.retentionPeriod) 84 d.Set("shard_level_metrics", state.shardLevelMetrics) 85 86 tags, err := conn.ListTagsForStream(&kinesis.ListTagsForStreamInput{ 87 StreamName: aws.String(sn), 88 }) 89 if err != nil { 90 return err 91 } 92 d.Set("tags", tagsToMapKinesis(tags.Tags)) 93 94 return nil 95 }