Skip to content
This repository was archived by the owner on Mar 1, 2023. It is now read-only.

Commit ef19e59

Browse files
committed
remote_ip_prefix added to security group
1 parent 21c390a commit ef19e59

File tree

8 files changed

+26
-4
lines changed

8 files changed

+26
-4
lines changed

docs/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ terraform {
1818
required_providers {
1919
gcore = {
2020
source = "G-Core/gcorelabs"
21-
version = "0.1.3"
21+
version = "0.1.8"
2222
}
2323
}
2424
}

docs/resources/gcore_securitygroup.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ Optional:
8181
- **description** (String)
8282
- **port_range_max** (Number)
8383
- **port_range_min** (Number)
84+
- **remote_ip_prefix** (String)
8485

8586
Read-Only:
8687

examples/provider/provider.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ terraform {
33
required_providers {
44
gcore = {
55
source = "G-Core/gcorelabs"
6-
version = "0.1.3"
6+
version = "0.1.8"
77
}
88
}
99
}

gcore/resource_gcore_securitygroup.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ func resourceSecurityGroup() *schema.Resource {
134134
Type: schema.TypeString,
135135
Optional: true,
136136
},
137+
"remote_ip_prefix": &schema.Schema{
138+
Type: schema.TypeString,
139+
Optional: true,
140+
},
137141
"updated_at": &schema.Schema{
138142
Type: schema.TypeString,
139143
Computed: true,
@@ -187,6 +191,7 @@ func resourceSecurityGroupCreate(ctx context.Context, d *schema.ResourceData, m
187191
portRangeMax := rule["port_range_max"].(int)
188192
portRangeMin := rule["port_range_min"].(int)
189193
descr := rule["description"].(string)
194+
remoteIPPrefix := rule["remote_ip_prefix"].(string)
190195

191196
sgrOpts := securitygroups.CreateSecurityGroupRuleOpts{
192197
Direction: types.RuleDirection(rule["direction"].(string)),
@@ -195,6 +200,10 @@ func resourceSecurityGroupCreate(ctx context.Context, d *schema.ResourceData, m
195200
Description: &descr,
196201
}
197202

203+
if remoteIPPrefix != "" {
204+
sgrOpts.RemoteIPPrefix = &remoteIPPrefix
205+
}
206+
198207
if portRangeMax != 0 && portRangeMin != 0 {
199208
sgrOpts.PortRangeMax = &portRangeMax
200209
sgrOpts.PortRangeMin = &portRangeMin
@@ -275,6 +284,10 @@ func resourceSecurityGroupRead(ctx context.Context, d *schema.ResourceData, m in
275284
r["description"] = *sgr.Description
276285
}
277286

287+
if sgr.RemoteIPPrefix != nil {
288+
r["remote_ip_prefix"] = *sgr.RemoteIPPrefix
289+
}
290+
278291
r["updated_at"] = sgr.UpdatedAt.String()
279292
r["created_at"] = sgr.CreatedAt.String()
280293

gcore/resource_gcore_snapshot_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestAccSnapshot(t *testing.T) {
7878

7979
func testAccSnapshotDestroy(s *terraform.State) error {
8080
config := testAccProvider.Meta().(*Config)
81-
client, err := CreateTestClient(config.Provider, snapshotsPoint)
81+
client, err := CreateTestClient(config.Provider, snapshotsPoint, versionPointV1)
8282
if err != nil {
8383
return err
8484
}

gcore/utils.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,10 +527,16 @@ func extractSecurityGroupRuleMap(r interface{}, gid string) securitygroups.Creat
527527
opts.PortRangeMin = &minP
528528
opts.PortRangeMax = &maxP
529529
}
530+
530531
descr := rule["description"].(string)
531532
if descr != "" {
532533
opts.Description = &descr
533534
}
535+
536+
remoteIPPrefix := rule["remote_ip_prefix"].(string)
537+
if remoteIPPrefix != "" {
538+
opts.RemoteIPPrefix = &remoteIPPrefix
539+
}
534540
return opts
535541
}
536542

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/terraform-providers/terraform-provider-gcorelabs
33
go 1.14
44

55
require (
6-
github.com/G-Core/gcorelabscloud-go v0.3.43
6+
github.com/G-Core/gcorelabscloud-go v0.4.3
77
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
88
github.com/hashicorp/terraform-plugin-sdk/v2 v2.3.0
99
github.com/mitchellh/mapstructure v1.4.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03
4343
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
4444
github.com/G-Core/gcorelabscloud-go v0.3.43 h1:DF90DkCD1LketaXjBN1imqlUv4GDfBxh6s+YlQpcjVM=
4545
github.com/G-Core/gcorelabscloud-go v0.3.43/go.mod h1:Z1MF80mWagEUrxygtYkvW/MJEYNmIUPsIEYBB3cKjOM=
46+
github.com/G-Core/gcorelabscloud-go v0.4.3 h1:woDCm0rTiGq0F+nr+RZ33nc5YXcxdBWkeaPRROQ3qcM=
47+
github.com/G-Core/gcorelabscloud-go v0.4.3/go.mod h1:Z1MF80mWagEUrxygtYkvW/MJEYNmIUPsIEYBB3cKjOM=
4648
github.com/NYTimes/gziphandler v0.0.0-20170623195520-56545f4a5d46/go.mod h1:3wb06e3pkSAbeQ52E9H9iFoQsEEwGN64994WTCIhntQ=
4749
github.com/PuerkitoBio/purell v1.0.0/go.mod h1:c11w/QuzBsJSee3cPx9rAFu61PvFxuPbtSwDGJws/X0=
4850
github.com/PuerkitoBio/urlesc v0.0.0-20160726150825-5bd2802263f2/go.mod h1:uGdkoq3SwY9Y+13GIhn11/XLaGBb4BfwItxLd5jeuXE=

0 commit comments

Comments
 (0)