diff --git a/cloudconnexa/data_source_connector.go b/cloudconnexa/data_source_connector.go index aef6612..7e8ed18 100644 --- a/cloudconnexa/data_source_connector.go +++ b/cloudconnexa/data_source_connector.go @@ -56,6 +56,11 @@ func dataSourceConnector() *schema.Resource { Computed: true, Description: "OpenVPN profile", }, + "token": { + Type: schema.TypeString, + Computed: true, + Description: "Connector token", + }, }, } } @@ -71,6 +76,10 @@ func dataSourceConnectorRead(ctx context.Context, d *schema.ResourceData, m inte if connector == nil { return append(diags, diag.Errorf("Connector with name %s was not found", name)...) } + token, err := c.Connectors.GetToken(connector.Id) + if err != nil { + return append(diags, diag.FromErr(err)...) + } d.SetId(connector.Id) d.Set("name", connector.Name) @@ -80,6 +89,8 @@ func dataSourceConnectorRead(ctx context.Context, d *schema.ResourceData, m inte d.Set("vpn_region_id", connector.VpnRegionId) d.Set("ip_v4_address", connector.IPv4Address) d.Set("ip_v6_address", connector.IPv6Address) + d.Set("token", token) + profile, err := c.Connectors.GetProfile(connector.Id) if err != nil { return append(diags, diag.FromErr(err)...) diff --git a/cloudconnexa/resource_connector.go b/cloudconnexa/resource_connector.go index ef78191..05909f8 100644 --- a/cloudconnexa/resource_connector.go +++ b/cloudconnexa/resource_connector.go @@ -66,6 +66,11 @@ func resourceConnector() *schema.Resource { Computed: true, Description: "OpenVPN profile of the connector.", }, + "token": { + Type: schema.TypeString, + Computed: true, + Description: "Connector token.", + }, }, } } @@ -111,6 +116,11 @@ func resourceConnectorCreate(ctx context.Context, d *schema.ResourceData, m inte return append(diags, diag.FromErr(err)...) } d.Set("profile", profile) + token, err := c.Connectors.GetToken(conn.Id) + if err != nil { + return append(diags, diag.FromErr(err)...) + } + d.Set("token", token) return append(diags, diag.Diagnostic{ Severity: diag.Warning, Summary: "Connector needs to be set up manually", @@ -125,6 +135,11 @@ func resourceConnectorRead(ctx context.Context, d *schema.ResourceData, m interf if err != nil { return append(diags, diag.FromErr(err)...) } + token, err := c.Connectors.GetToken(connector.Id) + if err != nil { + return append(diags, diag.FromErr(err)...) + } + if connector == nil { d.SetId("") } else { @@ -135,6 +150,7 @@ func resourceConnectorRead(ctx context.Context, d *schema.ResourceData, m interf d.Set("network_item_id", connector.NetworkItemId) d.Set("ip_v4_address", connector.IPv4Address) d.Set("ip_v6_address", connector.IPv6Address) + d.Set("token", token) profile, err := c.Connectors.GetProfile(connector.Id) if err != nil { return append(diags, diag.FromErr(err)...)