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

Add use_metric_source_project_for_quota field to the GCP integration #382

Merged
merged 1 commit into from
Jul 19, 2022
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 6.14.0

IMPROVEMENTS:
* resource/signalfx_gcp_integration: add `use_metric_source_project_for_quota` field to the GCP integration [#382](https://github.com/splunk-terraform/terraform-provider-signalfx/pull/382)

## 6.13.1

BUGFIXES:
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/bgentry/go-netrc v0.0.0-20140422174119-9fd32a8b3d3d
github.com/hashicorp/terraform-plugin-sdk v1.15.0
github.com/mitchellh/go-homedir v1.1.0
github.com/signalfx/signalfx-go v1.21.0
github.com/signalfx/signalfx-go v1.22.0
github.com/stretchr/testify v1.6.1
)

Expand Down
6 changes: 2 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,8 @@ github.com/signalfx/golib/v3 v3.3.37 h1:CvL6Q8hySjm7D82P039qH2lFWJvBa18IJdAwa4LH
github.com/signalfx/golib/v3 v3.3.37/go.mod h1:zH70SVnrzVUqDmUFEwDk1HSwS71Pi2w3bSsNpnOtYuQ=
github.com/signalfx/gomemcache v0.0.0-20180823214636-4f7ef64c72a9/go.mod h1:Ytb8KfCSyuwy/VILnROdgCvbQLA5ch0nkbG7lKT0BXw=
github.com/signalfx/sapm-proto v0.4.0/go.mod h1:x3gtwJ1GRejtkghB4nYpwixh2zqJrLbPU959ZNhM0Fk=
github.com/signalfx/signalfx-go v1.19.0 h1:ZjHL7DRLsKfM1j87q0FjqVMx3zxYfd5zyRg2Kx0Nbec=
github.com/signalfx/signalfx-go v1.19.0/go.mod h1:YhPTMdQJDfphcRBdk+9acbbAw1gYY7z5BIHUWzLmGlA=
github.com/signalfx/signalfx-go v1.21.0 h1:zya/s1ieaLtn3g/RzlcA+cop1GP4uHKeQrEPWC1a1bI=
github.com/signalfx/signalfx-go v1.21.0/go.mod h1:YhPTMdQJDfphcRBdk+9acbbAw1gYY7z5BIHUWzLmGlA=
github.com/signalfx/signalfx-go v1.22.0 h1:7b7MwCNOFL2xq+onzOpkDJYBMSk5HTWhEZI7d1QQb/k=
github.com/signalfx/signalfx-go v1.22.0/go.mod h1:YhPTMdQJDfphcRBdk+9acbbAw1gYY7z5BIHUWzLmGlA=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac h1:wbW+Bybf9pXxnCFAOWZTqkRjAc7rAIwo2e1ArUhiHxg=
github.com/smartystreets/assertions v0.0.0-20190215210624-980c5ac6f3ac/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
Expand Down
16 changes: 13 additions & 3 deletions signalfx/resource_signalfx_gcp_integration.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ func integrationGCPResource() *schema.Resource {
},
},
},
"use_metric_source_project_for_quota": &schema.Schema{
Type: schema.TypeBool,
Optional: true,
Default: false,
Description: "When this value is set to true Observability Cloud will force usage of a quota from the project where metrics are stored. For this to work the service account provided for the project needs to be provided with serviceusage.services.use permission or Service Usage Consumer role in this project. When set to false default quota settings are used.",
},
"whitelist": &schema.Schema{
Type: schema.TypeSet,
Optional: true,
Expand Down Expand Up @@ -114,9 +120,10 @@ func integrationGCPRead(d *schema.ResourceData, meta interface{}) error {

func getGCPPayloadIntegration(d *schema.ResourceData) *integration.GCPIntegration {
gcp := &integration.GCPIntegration{
Name: d.Get("name").(string),
Enabled: d.Get("enabled").(bool),
Type: "GCP",
Name: d.Get("name").(string),
Enabled: d.Get("enabled").(bool),
UseMetricSourceProjectForQuota: d.Get("use_metric_source_project_for_quota").(bool),
Type: "GCP",
}

if val, ok := d.GetOk("named_token"); ok {
Expand Down Expand Up @@ -167,6 +174,9 @@ func gcpIntegrationAPIToTF(d *schema.ResourceData, gcp *integration.GCPIntegrati
if err := d.Set("enabled", gcp.Enabled); err != nil {
return err
}
if err := d.Set("use_metric_source_project_for_quota", gcp.UseMetricSourceProjectForQuota); err != nil {
return err
}
if err := d.Set("poll_rate", gcp.PollRateMs/1000); err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions signalfx/resource_signalfx_gcp_integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ resource "signalfx_gcp_integration" "gcp_myteamXX" {
project_id = "gcp_project_id_2"
project_key = "secret_key_project_2"
}

use_metric_source_project_for_quota = true
}
`

Expand All @@ -70,6 +72,7 @@ func TestAccCreateUpdateIntegrationGCP(t *testing.T) {
resource.TestCheckResourceAttr("signalfx_gcp_integration.gcp_myteamXX", "whitelist.#", "1"),
resource.TestCheckResourceAttr("signalfx_gcp_integration.gcp_myteamXX", "whitelist.151844697", "labels"),
resource.TestCheckResourceAttr("signalfx_gcp_integration.gcp_myteamXX", "poll_rate", "600"),
resource.TestCheckResourceAttr("signalfx_gcp_integration.gcp_myteamXX", "use_metric_source_project_for_quota", "false"),
),
},
{
Expand All @@ -88,6 +91,7 @@ func TestAccCreateUpdateIntegrationGCP(t *testing.T) {
testAccCheckIntegrationGCPResourceExists,
resource.TestCheckResourceAttr("signalfx_gcp_integration.gcp_myteamXX", "name", "GCP - My Team NEW"),
resource.TestCheckResourceAttr("signalfx_gcp_integration.gcp_myteamXX", "poll_rate", "60"),
resource.TestCheckResourceAttr("signalfx_gcp_integration.gcp_myteamXX", "use_metric_source_project_for_quota", "true"),
),
},
},
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/gcp_integration.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ resource "signalfx_gcp_integration" "gcp_myteam" {
* `poll_rate` - (Optional) GCP integration poll rate (in seconds). Value between `60` and `600`. Default: `300`.
* `project_service_keys` - (Required) GCP projects to add.
* `services` - (Optional) GCP service metrics to import. Can be an empty list, or not included, to import 'All services'. See the documentation for [Creating Integrations](https://dev.splunk.com/observability/reference/api/integrations/latest#endpoint-create-integration) for valid values.
* `use_metric_source_project_for_quota` - (Optional) When this value is set to true Observability Cloud will force usage of a quota from the project where metrics are stored. For this to work the service account provided for the project needs to be provided with serviceusage.services.use permission or Service Usage Consumer role in this project. When set to false default quota settings are used.
* `whitelist` - (Optional) [Compute Metadata Whitelist](https://docs.splunk.com/Observability/infrastructure/navigators/gcp.html#compute-engine-instance).

## Attributes Reference
Expand Down