From 1e9e477f161e0054324e8870afedd0baf5793638 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Gniewek-W=C4=99grzyn?= Date: Mon, 6 Mar 2023 09:45:20 +0100 Subject: [PATCH 1/2] feat: add missing PrivateLink URLs to datasource --- .../system_get_privatelink_config.go | 52 +++++++++++++++++++ ..._get_privatelink_config_acceptance_test.go | 3 ++ .../system_get_privatelink_config.go | 15 ++++++ .../system_get_privatelink_config_test.go | 6 ++- 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/pkg/datasources/system_get_privatelink_config.go b/pkg/datasources/system_get_privatelink_config.go index f9dad6cafd..f1876d0511 100644 --- a/pkg/datasources/system_get_privatelink_config.go +++ b/pkg/datasources/system_get_privatelink_config.go @@ -39,6 +39,30 @@ var systemGetPrivateLinkConfigSchema = map[string]*schema.Schema{ Computed: true, Description: "The Azure Private Link Service ID for your account.", }, + + "regionless_account_url": { + Type: schema.TypeString, + Computed: true, + Description: "The regionless URL to connect to your Snowflake account using AWS PrivateLink, Azure Private Link, or Google Cloud Private Service Connect..", + }, + + "regionless_snowsight_url": { + Type: schema.TypeString, + Computed: true, + Description: "The URL for your organization to access Snowsight using Private Connectivity to the Snowflake Service.", + }, + + "snowsight_url": { + Type: schema.TypeString, + Computed: true, + Description: "The URL containing the cloud region to access Snowsight and the Snowflake Marketplace using Private Connectivity to the Snowflake Service.", + }, + + "internal_stage": { + Type: schema.TypeString, + Computed: true, + Description: "The endpoint to connect to your Snowflake internal stage using AWS PrivateLink or Azure Private Link..", + }, } func SystemGetPrivateLinkConfig() *schema.Resource { @@ -98,5 +122,33 @@ func ReadSystemGetPrivateLinkConfig(d *schema.ResourceData, meta interface{}) er } } + if config.InternalStage != "" { + intStgErr := d.Set("internal_stage", config.InternalStage) + if intStgErr != nil { + return intStgErr + } + } + + if config.SnowsightURL != "" { + snowSigURLErr := d.Set("snowsight_url", config.SnowsightURL) + if snowSigURLErr != nil { + return snowSigURLErr + } + } + + if config.RegionlessSnowsightURL != "" { + reglssSnowURLErr := d.Set("regionless_snowsight_url", config.RegionlessSnowsightURL) + if reglssSnowURLErr != nil { + return reglssSnowURLErr + } + } + + if config.RegionlessAccountURL != "" { + reglssAccURLErr := d.Set("regionless_account_url", config.RegionlessAccountURL) + if reglssAccURLErr != nil { + return reglssAccURLErr + } + } + return nil } diff --git a/pkg/datasources/system_get_privatelink_config_acceptance_test.go b/pkg/datasources/system_get_privatelink_config_acceptance_test.go index bacca7117e..854e255937 100644 --- a/pkg/datasources/system_get_privatelink_config_acceptance_test.go +++ b/pkg/datasources/system_get_privatelink_config_acceptance_test.go @@ -18,6 +18,9 @@ func TestAcc_SystemGetPrivateLinkConfig_aws(t *testing.T) { resource.TestCheckResourceAttrSet("data.snowflake_system_get_privatelink_config.p", "account_url"), resource.TestCheckResourceAttrSet("data.snowflake_system_get_privatelink_config.p", "ocsp_url"), resource.TestCheckResourceAttrSet("data.snowflake_system_get_privatelink_config.p", "aws_vpce_id"), + resource.TestCheckResourceAttrSet("data.snowflake_system_get_privatelink_config.p", "regionless_account_url"), + resource.TestCheckResourceAttrSet("data.snowflake_system_get_privatelink_config.p", "regionless_snowsight_url"), + resource.TestCheckResourceAttrSet("data.snowflake_system_get_privatelink_config.p", "snowsight_url"), ), }, }, diff --git a/pkg/snowflake/system_get_privatelink_config.go b/pkg/snowflake/system_get_privatelink_config.go index 75d4e110b6..89b2406ce2 100644 --- a/pkg/snowflake/system_get_privatelink_config.go +++ b/pkg/snowflake/system_get_privatelink_config.go @@ -21,6 +21,11 @@ type privateLinkConfigInternal struct { AccountURL string `json:"privatelink-account-url"` OCSPURL string `json:"privatelink-ocsp-url,omitempty"` TypodOCSPURL string `json:"privatelink_ocsp-url,omitempty"` // because snowflake returns this for AWS, but don't have an Azure account to verify against + InternalStage string `json:"privatelink-internal-stage,omitempty"` + SnowsightURL string `json:"snowsight-privatelink-url,omitempty"` + RegionlessSnowsightURL string `json:"regionless-snowsight-privatelink-url,omitempty"` + RegionlessAccountURL string `json:"regionless-privatelink-account-url,omitempty"` + ConnectionURLs string `json:"privatelink-connection-urls,omitempty"` } type PrivateLinkConfig struct { @@ -29,6 +34,11 @@ type PrivateLinkConfig struct { AzurePrivateLinkServiceID string AccountURL string OCSPURL string + InternalStage string + SnowsightURL string + RegionlessSnowsightURL string + RegionlessAccountURL string + ConnectionURLs string } func ScanPrivateLinkConfig(row *sqlx.Row) (*RawPrivateLinkConfig, error) { @@ -54,6 +64,11 @@ func (i *privateLinkConfigInternal) getPrivateLinkConfig() (*PrivateLinkConfig, i.AzurePrivateLinkServiceID, i.AccountURL, i.OCSPURL, + i.InternalStage, + i.SnowsightURL, + i.RegionlessSnowsightURL, + i.RegionlessAccountURL, + i.ConnectionURLs, } if i.TypodOCSPURL != "" { diff --git a/pkg/snowflake/system_get_privatelink_config_test.go b/pkg/snowflake/system_get_privatelink_config_test.go index 604bfaa6e1..dce8de351b 100644 --- a/pkg/snowflake/system_get_privatelink_config_test.go +++ b/pkg/snowflake/system_get_privatelink_config_test.go @@ -17,7 +17,7 @@ func TestSystemGetPrivateLinkGetStructuredConfigAws(t *testing.T) { r := require.New(t) raw := &RawPrivateLinkConfig{ - Config: `{"privatelink-account-name":"ab1234.eu-west-1.privatelink","privatelink-vpce-id":"com.amazonaws.vpce.eu-west-1.vpce-svc-123456789abcdef12","privatelink-account-url":"ab1234.eu-west-1.privatelink.snowflakecomputing.com","privatelink_ocsp-url":"ocsp.ab1234.eu-west-1.privatelink.snowflakecomputing.com"}`, + Config: `{"privatelink-account-name":"ab1234.eu-west-1.privatelink","privatelink-vpce-id":"com.amazonaws.vpce.eu-west-1.vpce-svc-123456789abcdef12","privatelink-account-url":"ab1234.eu-west-1.privatelink.snowflakecomputing.com","privatelink_ocsp-url":"ocsp.ab1234.eu-west-1.privatelink.snowflakecomputing.com","regionless-snowsight-privatelink-url":"app-snoworg-snow_account.privatelink.snowflakecomputing.com","privatelink-internal-stage":"sfc-xx-xx1-12-customer-stage.s3.eu-west-1.amazonaws.com","snowsight-privatelink-url":"app.eu-west-1.privatelink.snowflakecomputing.com","regionless-privatelink-account-url":"snoworg-snow_account.privatelink.snowflakecomputing.com"}`, } c, e := raw.GetStructuredConfig() @@ -28,6 +28,10 @@ func TestSystemGetPrivateLinkGetStructuredConfigAws(t *testing.T) { r.Equal("", c.AzurePrivateLinkServiceID) r.Equal("ab1234.eu-west-1.privatelink.snowflakecomputing.com", c.AccountURL) r.Equal("ocsp.ab1234.eu-west-1.privatelink.snowflakecomputing.com", c.OCSPURL) + r.Equal("snoworg-snow_account.privatelink.snowflakecomputing.com", c.RegionlessAccountURL) + r.Equal("app.eu-west-1.privatelink.snowflakecomputing.com", c.SnowsightURL) + r.Equal("sfc-xx-xx1-12-customer-stage.s3.eu-west-1.amazonaws.com", c.InternalStage) + r.Equal("app-snoworg-snow_account.privatelink.snowflakecomputing.com", c.RegionlessSnowsightURL) } func TestSystemGetPrivateLinkGetStructuredConfigAwsAsPerDocumentation(t *testing.T) { From 5b0ce894e6c9bbccdae05a090b016991b4a2400e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Gniewek-W=C4=99grzyn?= Date: Mon, 6 Mar 2023 11:32:14 +0100 Subject: [PATCH 2/2] fix: remove double dots from description --- pkg/datasources/system_get_privatelink_config.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/datasources/system_get_privatelink_config.go b/pkg/datasources/system_get_privatelink_config.go index f1876d0511..04dfbbd090 100644 --- a/pkg/datasources/system_get_privatelink_config.go +++ b/pkg/datasources/system_get_privatelink_config.go @@ -43,7 +43,7 @@ var systemGetPrivateLinkConfigSchema = map[string]*schema.Schema{ "regionless_account_url": { Type: schema.TypeString, Computed: true, - Description: "The regionless URL to connect to your Snowflake account using AWS PrivateLink, Azure Private Link, or Google Cloud Private Service Connect..", + Description: "The regionless URL to connect to your Snowflake account using AWS PrivateLink, Azure Private Link, or Google Cloud Private Service Connect.", }, "regionless_snowsight_url": { @@ -61,7 +61,7 @@ var systemGetPrivateLinkConfigSchema = map[string]*schema.Schema{ "internal_stage": { Type: schema.TypeString, Computed: true, - Description: "The endpoint to connect to your Snowflake internal stage using AWS PrivateLink or Azure Private Link..", + Description: "The endpoint to connect to your Snowflake internal stage using AWS PrivateLink or Azure Private Link.", }, }