@@ -13,6 +13,7 @@ func resourceScalewayInstanceIP() *schema.Resource {
13
13
return & schema.Resource {
14
14
CreateContext : resourceScalewayInstanceIPCreate ,
15
15
ReadContext : resourceScalewayInstanceIPRead ,
16
+ UpdateContext : resourceScalewayInstanceIPUpdate ,
16
17
DeleteContext : resourceScalewayInstanceIPDelete ,
17
18
Importer : & schema.ResourceImporter {
18
19
StateContext : schema .ImportStatePassthroughContext ,
@@ -37,6 +38,14 @@ func resourceScalewayInstanceIP() *schema.Resource {
37
38
Computed : true ,
38
39
Description : "The server associated with this IP" ,
39
40
},
41
+ "tags" : {
42
+ Type : schema .TypeList ,
43
+ Elem : & schema.Schema {
44
+ Type : schema .TypeString ,
45
+ },
46
+ Optional : true ,
47
+ Description : "The tags associated with the ip" ,
48
+ },
40
49
"zone" : zoneSchema (),
41
50
"organization_id" : organizationIDSchema (),
42
51
"project_id" : projectIDSchema (),
@@ -53,6 +62,7 @@ func resourceScalewayInstanceIPCreate(ctx context.Context, d *schema.ResourceDat
53
62
res , err := instanceAPI .CreateIP (& instance.CreateIPRequest {
54
63
Zone : zone ,
55
64
Project : expandStringPtr (d .Get ("project_id" )),
65
+ Tags : expandStrings (d .Get ("tags" )),
56
66
}, scw .WithContext (ctx ))
57
67
if err != nil {
58
68
return diag .FromErr (err )
@@ -62,6 +72,28 @@ func resourceScalewayInstanceIPCreate(ctx context.Context, d *schema.ResourceDat
62
72
return resourceScalewayInstanceIPRead (ctx , d , meta )
63
73
}
64
74
75
+ func resourceScalewayInstanceIPUpdate (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
76
+ instanceAPI , zone , ID , err := instanceAPIWithZoneAndID (meta , d .Id ())
77
+ if err != nil {
78
+ return diag .FromErr (err )
79
+ }
80
+ req := & instance.UpdateIPRequest {
81
+ IP : ID ,
82
+ Zone : zone ,
83
+ }
84
+
85
+ if d .HasChange ("tags" ) {
86
+ req .Tags = scw .StringsPtr (expandStrings (d .Get ("tags" )))
87
+ }
88
+
89
+ _ , err = instanceAPI .UpdateIP (req , scw .WithContext (ctx ))
90
+ if err != nil {
91
+ return diag .FromErr (err )
92
+ }
93
+
94
+ return resourceScalewayInstanceIPRead (ctx , d , meta )
95
+ }
96
+
65
97
func resourceScalewayInstanceIPRead (ctx context.Context , d * schema.ResourceData , meta interface {}) diag.Diagnostics {
66
98
instanceAPI , zone , ID , err := instanceAPIWithZoneAndID (meta , d .Id ())
67
99
if err != nil {
@@ -87,6 +119,7 @@ func resourceScalewayInstanceIPRead(ctx context.Context, d *schema.ResourceData,
87
119
_ = d .Set ("organization_id" , res .IP .Organization )
88
120
_ = d .Set ("project_id" , res .IP .Project )
89
121
_ = d .Set ("reverse" , res .IP .Reverse )
122
+ _ = d .Set ("tags" , res .IP .Tags )
90
123
91
124
if res .IP .Server != nil {
92
125
_ = d .Set ("server_id" , newZonedIDString (res .IP .Zone , res .IP .Server .ID ))
0 commit comments