diff --git a/builtin/providers/scaleway/resource_scaleway_server.go b/builtin/providers/scaleway/resource_scaleway_server.go index 0dddfa8e7..659c5c29f 100644 --- a/builtin/providers/scaleway/resource_scaleway_server.go +++ b/builtin/providers/scaleway/resource_scaleway_server.go @@ -82,8 +82,10 @@ func resourceScalewayServerCreate(d *schema.ResourceData, m interface{}) error { server.Bootscript = String(bootscript.(string)) } - if tags, ok := d.GetOk("tags"); ok { - server.Tags = tags.([]string) + if raw, ok := d.GetOk("tags"); ok { + for _, tag := range raw.([]interface{}) { + server.Tags = append(server.Tags, tag.(string)) + } } id, err := scaleway.PostServer(server) @@ -129,6 +131,7 @@ func resourceScalewayServerRead(d *schema.ResourceData, m interface{}) error { d.Set("ipv4_address_public", server.PublicAddress.IP) d.Set("state", server.State) d.Set("state_detail", server.StateDetail) + d.Set("tags", server.Tags) d.SetConnInfo(map[string]string{ "type": "ssh", @@ -148,6 +151,16 @@ func resourceScalewayServerUpdate(d *schema.ResourceData, m interface{}) error { req.Name = &name } + if d.HasChange("tags") { + if raw, ok := d.GetOk("tags"); ok { + var tags []string + for _, tag := range raw.([]interface{}) { + tags = append(tags, tag.(string)) + } + req.Tags = &tags + } + } + if d.HasChange("dynamic_ip_required") { req.DynamicIPRequired = Bool(d.Get("dynamic_ip_required").(bool)) } diff --git a/builtin/providers/scaleway/resource_scaleway_server_test.go b/builtin/providers/scaleway/resource_scaleway_server_test.go index b8fa3ff48..27fdab537 100644 --- a/builtin/providers/scaleway/resource_scaleway_server_test.go +++ b/builtin/providers/scaleway/resource_scaleway_server_test.go @@ -23,6 +23,8 @@ func TestAccScalewayServer_Basic(t *testing.T) { "scaleway_server.base", "type", "C1"), resource.TestCheckResourceAttr( "scaleway_server.base", "name", "test"), + resource.TestCheckResourceAttr( + "scaleway_server.base", "tags.0", "terraform-test"), ), }, }, @@ -110,4 +112,5 @@ resource "scaleway_server" "base" { # ubuntu 14.04 image = "%s" type = "C1" + tags = [ "terraform-test" ] }`, armImageIdentifier)