From e21203a36973ef3dd7ec47b8202da6ea96a3e1f0 Mon Sep 17 00:00:00 2001 From: Joern Barthel Date: Fri, 5 Aug 2016 17:08:22 +0200 Subject: [PATCH] Changed sync token to int and use it as id. --- .../providers/aws/data_source_aws_ip_ranges.go | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/builtin/providers/aws/data_source_aws_ip_ranges.go b/builtin/providers/aws/data_source_aws_ip_ranges.go index c530d981d..c71eb0a72 100644 --- a/builtin/providers/aws/data_source_aws_ip_ranges.go +++ b/builtin/providers/aws/data_source_aws_ip_ranges.go @@ -6,8 +6,8 @@ import ( "io/ioutil" "log" "sort" + "strconv" "strings" - "time" "github.com/hashicorp/go-cleanhttp" "github.com/hashicorp/terraform/helper/schema" @@ -50,7 +50,7 @@ func dataSourceAwsIPRanges() *schema.Resource { Elem: &schema.Schema{Type: schema.TypeString}, }, "sync_token": &schema.Schema{ - Type: schema.TypeString, + Type: schema.TypeInt, Computed: true, }, }, @@ -62,7 +62,6 @@ func dataSourceAwsIPRangesRead(d *schema.ResourceData, meta interface{}) error { conn := cleanhttp.DefaultClient() log.Printf("[DEBUG] Reading IP ranges") - d.SetId(time.Now().UTC().String()) res, err := conn.Get("https://ip-ranges.amazonaws.com/ip-ranges.json") @@ -88,7 +87,15 @@ func dataSourceAwsIPRangesRead(d *schema.ResourceData, meta interface{}) error { return fmt.Errorf("Error setting create date: %s", err) } - if err := d.Set("sync_token", result.SyncToken); err != nil { + syncToken, err := strconv.Atoi(result.SyncToken) + + if err != nil { + return fmt.Errorf("Error while converting sync token: %s", err) + } + + d.SetId(result.SyncToken) + + if err := d.Set("sync_token", syncToken); err != nil { return fmt.Errorf("Error setting sync token: %s", err) }