Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add missing PrivateLink URLs to datasource #1603

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions pkg/datasources/system_get_privatelink_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
),
},
},
Expand Down
15 changes: 15 additions & 0 deletions pkg/snowflake/system_get_privatelink_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {
Expand All @@ -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 != "" {
Expand Down
6 changes: 5 additions & 1 deletion pkg/snowflake/system_get_privatelink_config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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) {
Expand Down