Skip to content

Commit

Permalink
Support Private IP for Instance create (#210)
Browse files Browse the repository at this point in the history
* Support Private IP for Instance create
  • Loading branch information
uzaxirr authored May 7, 2024
1 parent 0cb12ba commit 8f906b9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 226 deletions.
11 changes: 10 additions & 1 deletion civo/instances/resource_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,11 @@ func ResourceInstance() *schema.Resource {
Computed: true,
Description: "Timestamp when the instance was created",
},
"private_ipv4": {
Type: schema.TypeString,
Optional: true,
Description: "The private IPv4 address for the instance (optional)",
},
"reserved_ipv4": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -216,6 +221,10 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, m inter
config.PublicIPRequired = attr.(string)
}

if privateIPv4, ok := d.GetOk("private_ipv4"); ok {
config.PrivateIPv4 = privateIPv4.(string)
}

if v, ok := d.GetOk("reserved_ipv4"); ok {
config.ReservedIPv4 = v.(string)
}
Expand Down Expand Up @@ -471,7 +480,7 @@ func resourceInstanceUpdate(ctx context.Context, d *schema.ResourceData, m inter
func resourceInstanceDelete(_ context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
apiClient := m.(*civogo.Client)

// overwrite the region if is define in the datasource
// overwrite the region if is defined in the datasource
if region, ok := d.GetOk("region"); ok {
apiClient.Region = region.(string)
}
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
module github.com/civo/terraform-provider-civo

require (
github.com/civo/civogo v0.3.68
github.com/civo/civogo v0.3.69
github.com/google/uuid v1.3.1
github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320
github.com/hashicorp/terraform-plugin-sdk/v2 v2.31.0
github.com/stretchr/testify v1.8.4
golang.org/x/crypto v0.18.0
golang.org/x/crypto v0.21.0
k8s.io/api v0.29.1
)

Expand Down Expand Up @@ -59,8 +59,8 @@ require (
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
github.com/zclconf/go-cty v1.14.1 // indirect
golang.org/x/mod v0.16.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/net v0.23.0 // indirect
golang.org/x/sys v0.18.0 // indirect
golang.org/x/text v0.14.0 // indirect
google.golang.org/appengine v1.6.8 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231002182017-d307bd883b97 // indirect
Expand Down
Loading

0 comments on commit 8f906b9

Please sign in to comment.