diff --git a/cloudconnexa/data_source_host.go b/cloudconnexa/data_source_host.go index f095c89..33efb41 100644 --- a/cloudconnexa/data_source_host.go +++ b/cloudconnexa/data_source_host.go @@ -25,6 +25,16 @@ func dataSourceHost() *schema.Resource { Required: true, Description: "The name of the host.", }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "The description of the host.", + }, + "domain": { + Type: schema.TypeString, + Computed: true, + Description: "The host domain.", + }, "internet_access": { Type: schema.TypeString, Computed: true, @@ -54,6 +64,11 @@ func dataSourceHost() *schema.Resource { Computed: true, Description: "The connector name.", }, + "description": { + Type: schema.TypeString, + Computed: true, + Description: "The connector description.", + }, "network_item_id": { Type: schema.TypeString, Computed: true, @@ -95,6 +110,8 @@ func dataSourceHostRead(ctx context.Context, d *schema.ResourceData, m interface } d.Set("host_id", host.Id) d.Set("name", host.Name) + d.Set("description", host.Description) + d.Set("domain", host.Domain) d.Set("internet_access", host.InternetAccess) d.Set("system_subnets", host.SystemSubnets) d.Set("connectors", getConnectorsSliceByConnectors(&host.Connectors)) diff --git a/cloudconnexa/resource_host.go b/cloudconnexa/resource_host.go index 37657a1..424f494 100644 --- a/cloudconnexa/resource_host.go +++ b/cloudconnexa/resource_host.go @@ -34,6 +34,12 @@ func resourceHost() *schema.Resource { ValidateFunc: validation.StringLenBetween(1, 120), Description: "The description for the UI. Defaults to `Managed by Terraform`.", }, + "domain": { + Type: schema.TypeString, + Optional: true, + ValidateFunc: validation.StringLenBetween(1, 253), + Description: "The domain of the host.", + }, "internet_access": { Type: schema.TypeString, Optional: true, @@ -70,6 +76,13 @@ func resourceHost() *schema.Resource { Required: true, Description: "Name of the connector associated with this host.", }, + "description": { + Type: schema.TypeString, + Optional: true, + Default: "Managed by Terraform", + ValidateFunc: validation.StringLenBetween(1, 120), + Description: "The description for the UI. Defaults to `Managed by Terraform`.", + }, "vpn_region_id": { Type: schema.TypeString, Required: true, @@ -114,11 +127,13 @@ func resourceHostCreate(ctx context.Context, d *schema.ResourceData, m interface for _, c := range configConnectors.List() { connectors = append(connectors, cloudconnexa.Connector{ Name: c.(map[string]interface{})["name"].(string), + Description: c.(map[string]interface{})["description"].(string), VpnRegionId: c.(map[string]interface{})["vpn_region_id"].(string), }) } h := cloudconnexa.Host{ Name: d.Get("name").(string), + Domain: d.Get("domain").(string), Description: d.Get("description").(string), InternetAccess: d.Get("internet_access").(string), Connectors: connectors, @@ -153,6 +168,7 @@ func resourceHostRead(ctx context.Context, d *schema.ResourceData, m interface{} } d.Set("name", host.Name) d.Set("description", host.Description) + d.Set("domain", host.Domain) d.Set("internet_access", host.InternetAccess) d.Set("system_subnets", host.SystemSubnets) @@ -174,6 +190,7 @@ func resourceHostUpdate(ctx context.Context, d *schema.ResourceData, m interface // This happens when importing the resource newConnector := cloudconnexa.Connector{ Name: newSet.List()[0].(map[string]interface{})["name"].(string), + Description: newSet.List()[0].(map[string]interface{})["description"].(string), VpnRegionId: newSet.List()[0].(map[string]interface{})["vpn_region_id"].(string), NetworkItemType: "HOST", } @@ -194,6 +211,7 @@ func resourceHostUpdate(ctx context.Context, d *schema.ResourceData, m interface if !oldSet.Contains(n) { newConnector := cloudconnexa.Connector{ Name: n.(map[string]interface{})["name"].(string), + Description: n.(map[string]interface{})["description"].(string), VpnRegionId: n.(map[string]interface{})["vpn_region_id"].(string), NetworkItemType: "HOST", } @@ -205,14 +223,16 @@ func resourceHostUpdate(ctx context.Context, d *schema.ResourceData, m interface } } } - if d.HasChanges("name", "description", "internet_access") { + if d.HasChanges("name", "description", "domain", "internet_access") { _, newName := d.GetChange("name") _, newDescription := d.GetChange("description") + _, newDomain := d.GetChange("domain") _, newAccess := d.GetChange("internet_access") err := c.Hosts.Update(cloudconnexa.Host{ Id: d.Id(), Name: newName.(string), Description: newDescription.(string), + Domain: newDomain.(string), InternetAccess: newAccess.(string), }) if err != nil { @@ -253,6 +273,7 @@ func getConnectorsListItem(c *cloudconnexa.Client, connector cloudconnexa.Connec connectorsData := map[string]interface{}{ "id": connector.Id, "name": connector.Name, + "description": connector.Description, "vpn_region_id": connector.VpnRegionId, "ip_v4_address": connector.IPv4Address, "ip_v6_address": connector.IPv6Address, diff --git a/go.mod b/go.mod index 186d5e1..46b40fd 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/gruntwork-io/terratest v0.46.1 github.com/hashicorp/go-cty v1.4.1-0.20200414143053-d3edf31b6320 github.com/hashicorp/terraform-plugin-sdk/v2 v2.33.0 - github.com/openvpn/cloudconnexa-go-client/v2 v2.0.10 + github.com/openvpn/cloudconnexa-go-client/v2 v2.0.11 github.com/stretchr/testify v1.9.0 ) diff --git a/go.sum b/go.sum index 386f0df..3908bb0 100644 --- a/go.sum +++ b/go.sum @@ -485,8 +485,8 @@ github.com/mitchellh/reflectwalk v1.0.2 h1:G2LzWKi524PWgd3mLHV8Y5k7s6XUvT0Gef6zx github.com/mitchellh/reflectwalk v1.0.2/go.mod h1:mSTlrgnPZtwu0c4WaC2kGObEpuNDbx0jmZXqmk4esnw= github.com/oklog/run v1.1.0 h1:GEenZ1cK0+q0+wsJew9qUg/DyD8k3JzYsZAi5gYi2mA= github.com/oklog/run v1.1.0/go.mod h1:sVPdnTZT1zYwAJeCMu2Th4T21pA3FPOQRfWjQlk7DVU= -github.com/openvpn/cloudconnexa-go-client/v2 v2.0.10 h1:k5wx9syxxwNNKbfEQkVjb/4hjhBrhbgBDmeT72yNe3w= -github.com/openvpn/cloudconnexa-go-client/v2 v2.0.10/go.mod h1:udq5IDkgXvMO6mQUEFsLHzEyGGAduhO0jJvlb9f4JkE= +github.com/openvpn/cloudconnexa-go-client/v2 v2.0.11 h1:NZ5cdmKhhjIYRbmyHXvRsCUTOI4tOtPlBaXpO/PgSnI= +github.com/openvpn/cloudconnexa-go-client/v2 v2.0.11/go.mod h1:udq5IDkgXvMO6mQUEFsLHzEyGGAduhO0jJvlb9f4JkE= github.com/pjbgf/sha1cd v0.3.0 h1:4D5XXmUUBUl/xQ6IjCkEAbqXskkq/4O7LmGn0AqMDs4= github.com/pjbgf/sha1cd v0.3.0/go.mod h1:nZ1rrWOcGJ5uZgEEVL1VUM9iRQiZvWdbZjkKyFzPPsI= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=