Skip to content

Commit

Permalink
Remove cloud services validation from AWS/Azure/GCP integrations
Browse files Browse the repository at this point in the history
Service names are validated on the Splunk Observability Cloud API anyway so
there is no need to do the same thing on the Terraform level.
  • Loading branch information
bgola-signalfx committed Jul 5, 2023
1 parent 8e23d88 commit cd7ce6d
Show file tree
Hide file tree
Showing 19 changed files with 16 additions and 326 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ require (
github.com/hashicorp/go-retryablehttp v0.7.4
github.com/hashicorp/terraform-plugin-sdk/v2 v2.26.1
github.com/mitchellh/go-homedir v1.1.0
github.com/signalfx/signalfx-go v1.32.0
github.com/signalfx/signalfx-go v1.33.0
github.com/stretchr/testify v1.8.2
)

Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ github.com/rogpeppe/go-internal v1.6.1/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTE
github.com/rogpeppe/go-internal v1.6.2 h1:aIihoIOHCiLZHxyoNQ+ABL4NKhFTgKLBdMLyEAh98m0=
github.com/rogpeppe/go-internal v1.6.2/go.mod h1:xXDCJY+GAPziupqXw64V24skbSoqbTEfhy4qGm1nDQc=
github.com/sergi/go-diff v1.2.0 h1:XU+rvMAioB0UC3q1MFrIQy4Vo5/4VsRDQQXHsEya6xQ=
github.com/signalfx/signalfx-go v1.32.0 h1:b3zgMR8lz2EAYFbaGO0XInanWmMfkmJ5IPgKv6mstyg=
github.com/signalfx/signalfx-go v1.32.0/go.mod h1:IpGZLPvCKNFyspAXoS480jB02mocTpo0KYd8jbl6/T8=
github.com/signalfx/signalfx-go v1.33.0 h1:+v1fa+is8rYSxGoN1W+9PiDj1dCF5sVjJx60dhNLsTA=
github.com/signalfx/signalfx-go v1.33.0/go.mod h1:IpGZLPvCKNFyspAXoS480jB02mocTpo0KYd8jbl6/T8=
github.com/skeema/knownhosts v1.1.0 h1:Wvr9V0MxhjRbl3f9nMnKnFfiWTJmtECJ9Njkea3ysW0=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
Expand Down
40 changes: 0 additions & 40 deletions signalfx/data_source_aws_services.go

This file was deleted.

40 changes: 0 additions & 40 deletions signalfx/data_source_azure_services.go

This file was deleted.

40 changes: 0 additions & 40 deletions signalfx/data_source_gcp_services.go

This file was deleted.

3 changes: 0 additions & 3 deletions signalfx/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,6 @@ func Provider() *schema.Provider {
},
},
DataSourcesMap: map[string]*schema.Resource{
"signalfx_aws_services": dataSourceAwsServices(),
"signalfx_azure_services": dataSourceAzureServices(),
"signalfx_gcp_services": dataSourceGcpServices(),
"signalfx_dimension_values": dataSourceDimensionValues(),
"signalfx_pagerduty_integration": dataSourcePagerDutyIntegration(),
},
Expand Down
21 changes: 4 additions & 17 deletions signalfx/resource_signalfx_aws_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ func integrationAWSResource() *schema.Resource {
Description: "Expression that selects the data that SignalFx should sync for the custom namespace associated with this sync rule. The expression uses the syntax defined for the SignalFlow `filter()` function; it can be any valid SignalFlow filter expression.",
},
"namespace": {
Type: schema.TypeString,
Required: true,
ValidateFunc: validateAwsService,
Description: "An AWS namespace having custom AWS metrics that you want to sync with SignalFx. See the AWS documentation on publishing metrics for more information.",
Type: schema.TypeString,
Required: true,
Description: "An AWS namespace having custom AWS metrics that you want to sync with SignalFx. See the AWS documentation on publishing metrics for more information.",
},
},
},
Expand Down Expand Up @@ -157,8 +156,7 @@ func integrationAWSResource() *schema.Resource {
Type: schema.TypeSet,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validateAwsService,
Type: schema.TypeString,
},
Description: "List of AWS services that you want SignalFx to monitor. Each element is a string designating an AWS service.",
},
Expand Down Expand Up @@ -747,14 +745,3 @@ func validateFilterAction(v interface{}, k string) (we []string, errors []error)
}
return
}

func validateAwsService(v interface{}, k string) (we []string, errors []error) {
value := v.(string)
for key, _ := range integration.AWSServiceNames {
if key == value {
return
}
}
errors = append(errors, fmt.Errorf("%s not allowed; consult the documentation for a list of valid AWS Service names", value))
return
}
8 changes: 0 additions & 8 deletions signalfx/resource_signalfx_aws_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,14 +360,6 @@ func testAccIntegrationAWSDestroy(s *terraform.State) error {
return nil
}

func TestValidateAwsService(t *testing.T) {
_, errors := validateAwsService("AWS/Logs", "")
assert.Equal(t, 0, len(errors), "No errors for valid value")

_, errors = validateAwsService("InvalidService", "")
assert.Equal(t, 1, len(errors), "Errors for invalid value")
}

func TestValidateFilterAction(t *testing.T) {
_, errors := validateFilterAction("Exclude", "")
assert.Equal(t, 0, len(errors), "No errors for valid value")
Expand Down
20 changes: 4 additions & 16 deletions signalfx/resource_signalfx_azure_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ func integrationAzureResource() *schema.Resource {
Required: true,
MinItems: 1,
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validateAzureService,
Type: schema.TypeString,
},
Description: "List of Microsoft Azure service names for the Azure services you want SignalFx to monitor. SignalFx only supports certain services, and if you specify an unsupported one, you receive an API error.",
},
Expand Down Expand Up @@ -286,9 +285,9 @@ func getPayloadAzureIntegration(d *schema.ResourceData) (*integration.AzureInteg
if val, ok := d.GetOk("services"); ok {
tfServices := val.(*schema.Set).List()
services := make([]integration.AzureService, len(tfServices))
for i, s := range tfServices {
s := s.(string)
services[i] = integration.AzureServiceNames[s]
for i, v := range tfServices {
v := integration.AzureService(v.(string))
services[i] = v
}
azure.Services = services
}
Expand Down Expand Up @@ -391,14 +390,3 @@ func integrationAzureDelete(d *schema.ResourceData, meta interface{}) error {

return config.Client.DeleteAzureIntegration(context.TODO(), d.Id())
}

func validateAzureService(v interface{}, k string) (we []string, errors []error) {
value := v.(string)
for key, _ := range integration.AzureServiceNames {
if key == value {
return
}
}
errors = append(errors, fmt.Errorf("%s not allowed; consult the documentation for a list of valid Azure service names", value))
return
}
10 changes: 0 additions & 10 deletions signalfx/resource_signalfx_azure_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/stretchr/testify/assert"
)

const newIntegrationAzureConfig = `
Expand Down Expand Up @@ -143,11 +141,3 @@ func testAccIntegrationAzureDestroy(s *terraform.State) error {

return nil
}

func TestValidateAzureService(t *testing.T) {
_, errors := validateAzureService("microsoft.batch/batchaccounts", "")
assert.Equal(t, 0, len(errors), "No errors for valid value")

_, errors = validateAzureService("unknown/service", "")
assert.Equal(t, 1, len(errors), "Errors for invalid value")
}
14 changes: 1 addition & 13 deletions signalfx/resource_signalfx_gcp_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ func integrationGCPResource() *schema.Resource {
Optional: true,
Description: "GCP enabled services",
Elem: &schema.Schema{
Type: schema.TypeString,
ValidateFunc: validateGcpService,
Type: schema.TypeString,
},
},
"custom_metric_type_domains": &schema.Schema{
Expand Down Expand Up @@ -274,14 +273,3 @@ func integrationGCPDelete(d *schema.ResourceData, meta interface{}) error {

return config.Client.DeleteGCPIntegration(context.TODO(), d.Id())
}

func validateGcpService(v interface{}, k string) (we []string, errors []error) {
value := v.(string)
for key, _ := range integration.GcpServiceNames {
if key == value {
return
}
}
errors = append(errors, fmt.Errorf("%s not allowed; consult the documentation for a list of valid GCP service names", value))
return
}
10 changes: 0 additions & 10 deletions signalfx/resource_signalfx_gcp_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource"
"github.com/hashicorp/terraform-plugin-sdk/v2/terraform"

"github.com/stretchr/testify/assert"
)

const newIntegrationGCPConfig = `
Expand Down Expand Up @@ -140,11 +138,3 @@ func testAccIntegrationGCPDestroy(s *terraform.State) error {

return nil
}

func TestValidateGcpService(t *testing.T) {
_, errors := validateGcpService("appengine", "")
assert.Equal(t, 0, len(errors), "No errors for valid value")

_, errors = validateGcpService("InvalidService", "")
assert.Equal(t, 1, len(errors), "Errors for invalid value")
}
35 changes: 0 additions & 35 deletions website/docs/d/aws_services.markdown

This file was deleted.

35 changes: 0 additions & 35 deletions website/docs/d/azure_services.markdown

This file was deleted.

Loading

0 comments on commit cd7ce6d

Please sign in to comment.