diff --git a/civo/instances/resource_instance.go b/civo/instances/resource_instance.go index 2c1f4fb..1fb8872 100644 --- a/civo/instances/resource_instance.go +++ b/civo/instances/resource_instance.go @@ -160,6 +160,11 @@ func ResourceInstance() *schema.Resource { Computed: true, Description: "Timestamp when the instance was created", }, + "reserved_ipv4": { + Type: schema.TypeString, + Optional: true, + Description: "Can be either the UUID, name, or the IP address of the reserved IP", + }, }, CreateContext: resourceInstanceCreate, ReadContext: resourceInstanceRead, @@ -174,11 +179,11 @@ func ResourceInstance() *schema.Resource { } } -// function to create a instance +// function to create an instance func resourceInstanceCreate(ctx 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) } @@ -211,6 +216,10 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, m inter config.PublicIPRequired = attr.(string) } + if v, ok := d.GetOk("reserved_ipv4"); ok { + config.ReservedIPv4 = v.(string) + } + if networtID, ok := d.GetOk("network_id"); ok { config.NetworkID = networtID.(string) } else { @@ -312,7 +321,7 @@ func resourceInstanceCreate(ctx context.Context, d *schema.ResourceData, m inter func resourceInstanceRead(_ 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) } @@ -346,6 +355,7 @@ func resourceInstanceRead(_ context.Context, d *schema.ResourceData, m interface d.Set("firewall_id", resp.FirewallID) d.Set("status", resp.Status) d.Set("script", resp.Script) + d.Set("reserved_ipv4", resp.ReservedIP) d.Set("created_at", resp.CreatedAt.UTC().String()) d.Set("notes", resp.Notes) @@ -360,11 +370,11 @@ func resourceInstanceRead(_ context.Context, d *schema.ResourceData, m interface return nil } -// function to update a instance +// function to update an instance func resourceInstanceUpdate(ctx 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) } diff --git a/go.mod b/go.mod index 3c60a9c..c53b30a 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/civo/terraform-provider-civo require ( - github.com/civo/civogo v0.3.65 + github.com/civo/civogo v0.3.68 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 diff --git a/go.sum b/go.sum index f3256c9..45acd39 100644 --- a/go.sum +++ b/go.sum @@ -27,6 +27,8 @@ github.com/civo/civogo v0.3.58 h1:FikCbwAKB5ovD8+NmSi7rzYBSpC4nUpGVpCyngEkTo4= github.com/civo/civogo v0.3.58/go.mod h1:54lv/FOf7gh6wE9ZwVdw4yBehk8V1CvU9aWa4v6dvW0= github.com/civo/civogo v0.3.65 h1:FZpkaVoTxcc4lAgRbh5fo65EPDBu/0xmJsoql5xEBHk= github.com/civo/civogo v0.3.65/go.mod h1:S/iYmGvQOraxdRtcXeq/2mVX01/ia2qfpQUp2SsTLKA= +github.com/civo/civogo v0.3.68 h1:WYqJTtMJDpNVtJE0dMpoQoU5T11A1fpHRqNPiL7hGYM= +github.com/civo/civogo v0.3.68/go.mod h1:S/iYmGvQOraxdRtcXeq/2mVX01/ia2qfpQUp2SsTLKA= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cloudflare/circl v1.3.3 h1:fE/Qz0QdIGqeWfnwq0RE0R7MI51s0M2E4Ga9kq5AEMs= github.com/cloudflare/circl v1.3.3/go.mod h1:5XYMA4rFBvNIrhs50XuiBJ15vF2pZn4nnUKZrLbUZFA=