-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support ability to create "non-custom" services (#6604)
* Support ability to create "non-custom" services Allow users to create various Service Monitoring services: App Engine, Cloud Run, etc. hashicorp/terraform-provider-google#11935 * Specify BasicService is immutable * Responding to review comments. * Add test; make service_id required * labels still need input: true; remove encoder * Correct typo * Ignore service fields in SLO import test * Correct test * Make id_format and import_format the same * Remove custom code * Correct test typo * service is actually input-only * Add resource test
- Loading branch information
Showing
5 changed files
with
212 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
mmv1/templates/terraform/examples/monitoring_service_example.tf.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
resource "google_monitoring_service" "<%= ctx[:primary_resource_id] -%>" { | ||
service_id = "<%= ctx[:vars]['service_id'] -%>" | ||
display_name = "My Service <%= ctx[:vars]['service_id'] -%>" | ||
|
||
user_labels = { | ||
my_key = "my_value" | ||
my_other_key = "my_other_value" | ||
} | ||
|
||
basic_service { | ||
service_type = "APP_ENGINE" | ||
service_labels = { | ||
module_id = "another-module-id" | ||
} | ||
} | ||
} |
52 changes: 52 additions & 0 deletions
52
mmv1/third_party/terraform/tests/resource_monitoring_service_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package google | ||
|
||
import ( | ||
"fmt" | ||
"testing" | ||
|
||
"github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" | ||
) | ||
|
||
func TestAccMonitoringService_basic(t *testing.T) { | ||
t.Parallel() | ||
|
||
randomSuffix := randString(t, 10) | ||
vcrTest(t, resource.TestCase{ | ||
PreCheck: func() { testAccPreCheck(t) }, | ||
Providers: testAccProviders, | ||
CheckDestroy: testAccCheckMonitoringServiceDestroyProducer(t), | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccMonitoringSlo_cloudEndpoints(randomSuffix, "an-endpoint"), | ||
}, | ||
{ | ||
ResourceName: "google_monitoring_service.srv", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
{ | ||
Config: testAccMonitoringSlo_cloudEndpoints(randomSuffix, "another-endpoint"), | ||
}, | ||
{ | ||
ResourceName: "google_monitoring_service.srv", | ||
ImportState: true, | ||
ImportStateVerify: true, | ||
}, | ||
}, | ||
}) | ||
} | ||
|
||
func testAccMonitoringSlo_cloudEndpoints(randSuffix, endpoint string) string { | ||
return fmt.Sprintf(` | ||
resource "google_monitoring_service" "srv" { | ||
service_id = "tf-test-srv-%s" | ||
display_name = "My Basic CloudEnpoints Service" | ||
basic_service { | ||
service_type = "CLOUD_ENDPOINTS" | ||
service_labels = { | ||
service = "%s" | ||
} | ||
} | ||
} | ||
`, randSuffix, endpoint) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters