Skip to content

Commit ea82976

Browse files
modular-magicianEdward Sun
andauthored
Created game server rollout data source (#3727) (#2258)
* Created game server rollout data source * Update data_google_game_services_game_server_deployment_rollout_test.go.erb Replace the custom check * Update provider.go.erb fix the indentation * Update game_services_game_server_deployment_rollout.html.markdown Misc updates * Update data_google_game_services_game_server_deployment_rollout_test.go.erb Update the test * Update data_google_game_services_game_server_deployment_rollout_test.go.erb Fix a typo Co-authored-by: Edward Sun <[email protected]> Signed-off-by: Modular Magician <[email protected]> Co-authored-by: Edward Sun <[email protected]>
1 parent 5d53c39 commit ea82976

File tree

6 files changed

+254
-69
lines changed

6 files changed

+254
-69
lines changed

.changelog/3727.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:new-datasource
2+
google_game_services_game_server_deployment_rollout (beta only)
3+
```
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package google
2+
3+
import (
4+
"fmt"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
7+
)
8+
9+
func dataSourceGameServicesGameServerDeploymentRollout() *schema.Resource {
10+
11+
dsSchema := datasourceSchemaFromResourceSchema(resourceGameServicesGameServerDeploymentRollout().Schema)
12+
addRequiredFieldsToSchema(dsSchema, "deployment_id")
13+
14+
return &schema.Resource{
15+
Read: dataSourceGameServicesGameServerDeploymentRolloutRead,
16+
Schema: dsSchema,
17+
}
18+
}
19+
20+
func dataSourceGameServicesGameServerDeploymentRolloutRead(d *schema.ResourceData, meta interface{}) error {
21+
config := meta.(*Config)
22+
23+
id, err := replaceVars(d, config, "projects/{{project}}/locations/global/gameServerDeployments/{{deployment_id}}/rollout")
24+
if err != nil {
25+
return fmt.Errorf("Error constructing id: %s", err)
26+
}
27+
d.SetId(id)
28+
29+
return resourceGameServicesGameServerDeploymentRolloutRead(d, meta)
30+
31+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package google
2+
3+
import (
4+
"testing"
5+
6+
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
7+
)
8+
9+
func TestAccDataSourceGameServicesGameServerDeploymentRollout_basic(t *testing.T) {
10+
t.Parallel()
11+
12+
context := map[string]interface{}{
13+
"random_suffix": randString(t, 10),
14+
}
15+
16+
vcrTest(t, resource.TestCase{
17+
PreCheck: func() { testAccPreCheck(t) },
18+
Providers: testAccProvidersOiCS,
19+
CheckDestroy: testAccCheckGameServicesGameServerDeploymentRolloutDestroyProducer(t),
20+
Steps: []resource.TestStep{
21+
{
22+
Config: testAccDataSourceGameServicesGameServerDeploymentRollout_basic(context),
23+
Check: resource.ComposeTestCheckFunc(
24+
checkDataSourceStateMatchesResourceState("data.google_game_services_game_server_deployment_rollout.qa", "google_game_services_game_server_deployment_rollout.foo"),
25+
),
26+
},
27+
},
28+
})
29+
}
30+
31+
func testAccDataSourceGameServicesGameServerDeploymentRollout_basic(context map[string]interface{}) string {
32+
return Nprintf(`
33+
resource "google_game_services_game_server_deployment" "default" {
34+
provider = google-beta
35+
36+
deployment_id = "tf-test-deployment-%{random_suffix}"
37+
description = "a deployment description"
38+
}
39+
40+
resource "google_game_services_game_server_config" "default" {
41+
provider = google-beta
42+
43+
config_id = "tf-test-config-%{random_suffix}"
44+
deployment_id = google_game_services_game_server_deployment.default.deployment_id
45+
description = "a config description"
46+
47+
fleet_configs {
48+
name = "some-non-guid"
49+
fleet_spec = jsonencode({ "replicas" : 1, "scheduling" : "Packed", "template" : { "metadata" : { "name" : "tf-test-game-server-template" }, "spec" : { "template" : { "spec" : { "containers" : [{ "name" : "simple-udp-server", "image" : "gcr.io/agones-images/udp-server:0.14" }] } } } } })
50+
51+
// Alternate usage:
52+
// fleet_spec = file(fleet_configs.json)
53+
}
54+
}
55+
56+
resource "google_game_services_game_server_deployment_rollout" "foo" {
57+
provider = google-beta
58+
59+
deployment_id = google_game_services_game_server_deployment.default.deployment_id
60+
default_game_server_config = google_game_services_game_server_config.default.name
61+
}
62+
63+
data "google_game_services_game_server_deployment_rollout" "qa" {
64+
provider = google-beta
65+
deployment_id = google_game_services_game_server_deployment_rollout.foo.deployment_id
66+
}
67+
`, context)
68+
}

google-beta/provider.go

Lines changed: 70 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -594,75 +594,76 @@ func Provider() terraform.ResourceProvider {
594594
},
595595

596596
DataSourcesMap: map[string]*schema.Resource{
597-
"google_active_folder": dataSourceGoogleActiveFolder(),
598-
"google_billing_account": dataSourceGoogleBillingAccount(),
599-
"google_bigquery_default_service_account": dataSourceGoogleBigqueryDefaultServiceAccount(),
600-
"google_client_config": dataSourceGoogleClientConfig(),
601-
"google_client_openid_userinfo": dataSourceGoogleClientOpenIDUserinfo(),
602-
"google_cloudfunctions_function": dataSourceGoogleCloudFunctionsFunction(),
603-
"google_cloud_identity_groups": dataSourceGoogleCloudIdentityGroups(),
604-
"google_cloud_identity_group_memberships": dataSourceGoogleCloudIdentityGroupMemberships(),
605-
"google_composer_image_versions": dataSourceGoogleComposerImageVersions(),
606-
"google_compute_address": dataSourceGoogleComputeAddress(),
607-
"google_compute_backend_service": dataSourceGoogleComputeBackendService(),
608-
"google_compute_backend_bucket": dataSourceGoogleComputeBackendBucket(),
609-
"google_compute_default_service_account": dataSourceGoogleComputeDefaultServiceAccount(),
610-
"google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(),
611-
"google_compute_global_address": dataSourceGoogleComputeGlobalAddress(),
612-
"google_compute_image": dataSourceGoogleComputeImage(),
613-
"google_compute_instance": dataSourceGoogleComputeInstance(),
614-
"google_compute_instance_serial_port": dataSourceGoogleComputeInstanceSerialPort(),
615-
"google_compute_instance_group": dataSourceGoogleComputeInstanceGroup(),
616-
"google_compute_lb_ip_ranges": dataSourceGoogleComputeLbIpRanges(),
617-
"google_compute_network": dataSourceGoogleComputeNetwork(),
618-
"google_compute_network_endpoint_group": dataSourceGoogleComputeNetworkEndpointGroup(),
619-
"google_compute_node_types": dataSourceGoogleComputeNodeTypes(),
620-
"google_compute_regions": dataSourceGoogleComputeRegions(),
621-
"google_compute_region_instance_group": dataSourceGoogleComputeRegionInstanceGroup(),
622-
"google_compute_resource_policy": dataSourceGoogleComputeResourcePolicy(),
623-
"google_compute_router": dataSourceGoogleComputeRouter(),
624-
"google_compute_ssl_certificate": dataSourceGoogleComputeSslCertificate(),
625-
"google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(),
626-
"google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(),
627-
"google_compute_vpn_gateway": dataSourceGoogleComputeVpnGateway(),
628-
"google_compute_zones": dataSourceGoogleComputeZones(),
629-
"google_container_cluster": dataSourceGoogleContainerCluster(),
630-
"google_container_engine_versions": dataSourceGoogleContainerEngineVersions(),
631-
"google_container_registry_image": dataSourceGoogleContainerImage(),
632-
"google_container_registry_repository": dataSourceGoogleContainerRepo(),
633-
"google_dns_keys": dataSourceDNSKeys(),
634-
"google_dns_managed_zone": dataSourceDnsManagedZone(),
635-
"google_iam_policy": dataSourceGoogleIamPolicy(),
636-
"google_iam_role": dataSourceGoogleIamRole(),
637-
"google_iam_testable_permissions": dataSourceGoogleIamTestablePermissions(),
638-
"google_kms_crypto_key": dataSourceGoogleKmsCryptoKey(),
639-
"google_kms_crypto_key_version": dataSourceGoogleKmsCryptoKeyVersion(),
640-
"google_kms_key_ring": dataSourceGoogleKmsKeyRing(),
641-
"google_kms_secret": dataSourceGoogleKmsSecret(),
642-
"google_kms_secret_ciphertext": dataSourceGoogleKmsSecretCiphertext(),
643-
"google_firebase_web_app": dataSourceGoogleFirebaseWebApp(),
644-
"google_firebase_web_app_config": dataSourceGoogleFirebaseWebappConfig(),
645-
"google_folder": dataSourceGoogleFolder(),
646-
"google_folder_organization_policy": dataSourceGoogleFolderOrganizationPolicy(),
647-
"google_monitoring_notification_channel": dataSourceMonitoringNotificationChannel(),
648-
"google_monitoring_app_engine_service": dataSourceMonitoringServiceAppEngine(),
649-
"google_monitoring_uptime_check_ips": dataSourceGoogleMonitoringUptimeCheckIps(),
650-
"google_netblock_ip_ranges": dataSourceGoogleNetblockIpRanges(),
651-
"google_organization": dataSourceGoogleOrganization(),
652-
"google_project": dataSourceGoogleProject(),
653-
"google_projects": dataSourceGoogleProjects(),
654-
"google_project_organization_policy": dataSourceGoogleProjectOrganizationPolicy(),
655-
"google_secret_manager_secret_version": dataSourceSecretManagerSecretVersion(),
656-
"google_service_account": dataSourceGoogleServiceAccount(),
657-
"google_service_account_access_token": dataSourceGoogleServiceAccountAccessToken(),
658-
"google_service_account_key": dataSourceGoogleServiceAccountKey(),
659-
"google_sql_ca_certs": dataSourceGoogleSQLCaCerts(),
660-
"google_storage_bucket_object": dataSourceGoogleStorageBucketObject(),
661-
"google_storage_object_signed_url": dataSourceGoogleSignedUrl(),
662-
"google_storage_project_service_account": dataSourceGoogleStorageProjectServiceAccount(),
663-
"google_storage_transfer_project_service_account": dataSourceGoogleStorageTransferProjectServiceAccount(),
664-
"google_tpu_tensorflow_versions": dataSourceTpuTensorflowVersions(),
665-
"google_redis_instance": dataSourceGoogleRedisInstance(),
597+
"google_active_folder": dataSourceGoogleActiveFolder(),
598+
"google_billing_account": dataSourceGoogleBillingAccount(),
599+
"google_bigquery_default_service_account": dataSourceGoogleBigqueryDefaultServiceAccount(),
600+
"google_client_config": dataSourceGoogleClientConfig(),
601+
"google_client_openid_userinfo": dataSourceGoogleClientOpenIDUserinfo(),
602+
"google_cloudfunctions_function": dataSourceGoogleCloudFunctionsFunction(),
603+
"google_cloud_identity_groups": dataSourceGoogleCloudIdentityGroups(),
604+
"google_cloud_identity_group_memberships": dataSourceGoogleCloudIdentityGroupMemberships(),
605+
"google_composer_image_versions": dataSourceGoogleComposerImageVersions(),
606+
"google_compute_address": dataSourceGoogleComputeAddress(),
607+
"google_compute_backend_service": dataSourceGoogleComputeBackendService(),
608+
"google_compute_backend_bucket": dataSourceGoogleComputeBackendBucket(),
609+
"google_compute_default_service_account": dataSourceGoogleComputeDefaultServiceAccount(),
610+
"google_compute_forwarding_rule": dataSourceGoogleComputeForwardingRule(),
611+
"google_compute_global_address": dataSourceGoogleComputeGlobalAddress(),
612+
"google_compute_image": dataSourceGoogleComputeImage(),
613+
"google_compute_instance": dataSourceGoogleComputeInstance(),
614+
"google_compute_instance_serial_port": dataSourceGoogleComputeInstanceSerialPort(),
615+
"google_compute_instance_group": dataSourceGoogleComputeInstanceGroup(),
616+
"google_compute_lb_ip_ranges": dataSourceGoogleComputeLbIpRanges(),
617+
"google_compute_network": dataSourceGoogleComputeNetwork(),
618+
"google_compute_network_endpoint_group": dataSourceGoogleComputeNetworkEndpointGroup(),
619+
"google_compute_node_types": dataSourceGoogleComputeNodeTypes(),
620+
"google_compute_regions": dataSourceGoogleComputeRegions(),
621+
"google_compute_region_instance_group": dataSourceGoogleComputeRegionInstanceGroup(),
622+
"google_compute_resource_policy": dataSourceGoogleComputeResourcePolicy(),
623+
"google_compute_router": dataSourceGoogleComputeRouter(),
624+
"google_compute_ssl_certificate": dataSourceGoogleComputeSslCertificate(),
625+
"google_compute_ssl_policy": dataSourceGoogleComputeSslPolicy(),
626+
"google_compute_subnetwork": dataSourceGoogleComputeSubnetwork(),
627+
"google_compute_vpn_gateway": dataSourceGoogleComputeVpnGateway(),
628+
"google_compute_zones": dataSourceGoogleComputeZones(),
629+
"google_container_cluster": dataSourceGoogleContainerCluster(),
630+
"google_container_engine_versions": dataSourceGoogleContainerEngineVersions(),
631+
"google_container_registry_image": dataSourceGoogleContainerImage(),
632+
"google_container_registry_repository": dataSourceGoogleContainerRepo(),
633+
"google_dns_keys": dataSourceDNSKeys(),
634+
"google_dns_managed_zone": dataSourceDnsManagedZone(),
635+
"google_game_services_game_server_deployment_rollout": dataSourceGameServicesGameServerDeploymentRollout(),
636+
"google_iam_policy": dataSourceGoogleIamPolicy(),
637+
"google_iam_role": dataSourceGoogleIamRole(),
638+
"google_iam_testable_permissions": dataSourceGoogleIamTestablePermissions(),
639+
"google_kms_crypto_key": dataSourceGoogleKmsCryptoKey(),
640+
"google_kms_crypto_key_version": dataSourceGoogleKmsCryptoKeyVersion(),
641+
"google_kms_key_ring": dataSourceGoogleKmsKeyRing(),
642+
"google_kms_secret": dataSourceGoogleKmsSecret(),
643+
"google_kms_secret_ciphertext": dataSourceGoogleKmsSecretCiphertext(),
644+
"google_firebase_web_app": dataSourceGoogleFirebaseWebApp(),
645+
"google_firebase_web_app_config": dataSourceGoogleFirebaseWebappConfig(),
646+
"google_folder": dataSourceGoogleFolder(),
647+
"google_folder_organization_policy": dataSourceGoogleFolderOrganizationPolicy(),
648+
"google_monitoring_notification_channel": dataSourceMonitoringNotificationChannel(),
649+
"google_monitoring_app_engine_service": dataSourceMonitoringServiceAppEngine(),
650+
"google_monitoring_uptime_check_ips": dataSourceGoogleMonitoringUptimeCheckIps(),
651+
"google_netblock_ip_ranges": dataSourceGoogleNetblockIpRanges(),
652+
"google_organization": dataSourceGoogleOrganization(),
653+
"google_project": dataSourceGoogleProject(),
654+
"google_projects": dataSourceGoogleProjects(),
655+
"google_project_organization_policy": dataSourceGoogleProjectOrganizationPolicy(),
656+
"google_secret_manager_secret_version": dataSourceSecretManagerSecretVersion(),
657+
"google_service_account": dataSourceGoogleServiceAccount(),
658+
"google_service_account_access_token": dataSourceGoogleServiceAccountAccessToken(),
659+
"google_service_account_key": dataSourceGoogleServiceAccountKey(),
660+
"google_sql_ca_certs": dataSourceGoogleSQLCaCerts(),
661+
"google_storage_bucket_object": dataSourceGoogleStorageBucketObject(),
662+
"google_storage_object_signed_url": dataSourceGoogleSignedUrl(),
663+
"google_storage_project_service_account": dataSourceGoogleStorageProjectServiceAccount(),
664+
"google_storage_transfer_project_service_account": dataSourceGoogleStorageTransferProjectServiceAccount(),
665+
"google_tpu_tensorflow_versions": dataSourceTpuTensorflowVersions(),
666+
"google_redis_instance": dataSourceGoogleRedisInstance(),
666667
},
667668

668669
ResourcesMap: ResourceMap(),
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
---
2+
subcategory: "Game Servers"
3+
layout: "google"
4+
page_title: "Google: google_game_services_game_server_deployment_rollout"
5+
sidebar_current: "docs-google-datasource-game-services-game-server-deployment-rollout"
6+
description: |-
7+
Get the rollout state.
8+
---
9+
10+
# google\_game\_services\_game\_server\_deployment\_rollout
11+
12+
Use this data source to get the rollout state.
13+
14+
https://cloud.google.com/game-servers/docs/reference/rest/v1beta/GameServerDeploymentRollout
15+
16+
## Example Usage
17+
18+
19+
```hcl
20+
data "google_game_services_game_server_deployment_rollout" "qa" {
21+
provider = google-beta
22+
deployment_id = "tf-test-deployment-s8sn12jt2c"
23+
}
24+
```
25+
26+
## Argument Reference
27+
28+
The following arguments are supported:
29+
30+
31+
* `deployment_id` - (Required)
32+
The deployment to get the rollout state from. Only 1 rollout must be associated with each deployment.
33+
34+
35+
## Attributes Reference
36+
37+
In addition to the arguments listed above, the following attributes are exported:
38+
39+
* `default_game_server_config` -
40+
This field points to the game server config that is
41+
applied by default to all realms and clusters. For example,
42+
`projects/my-project/locations/global/gameServerDeployments/my-game/configs/my-config`.
43+
44+
45+
* `game_server_config_overrides` -
46+
The game_server_config_overrides contains the per game server config
47+
overrides. The overrides are processed in the order they are listed. As
48+
soon as a match is found for a cluster, the rest of the list is not
49+
processed. Structure is documented below.
50+
51+
* `project` - The ID of the project in which the resource belongs.
52+
If it is not provided, the provider project is used.
53+
54+
55+
The `game_server_config_overrides` block contains:
56+
57+
* `realms_selector` -
58+
Selection by realms. Structure is documented below.
59+
60+
* `config_version` -
61+
Version of the configuration.
62+
63+
The `realms_selector` block contains:
64+
65+
* `realms` -
66+
List of realms to match against.
67+
68+
* `id` - an identifier for the resource with format `projects/{{project}}/locations/global/gameServerDeployments/{{deployment_id}}/rollout`
69+
70+
* `name` -
71+
The resource id of the game server deployment
72+
eg: `projects/my-project/locations/global/gameServerDeployments/my-deployment/rollout`.

website/google.erb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1879,6 +1879,16 @@
18791879
<li>
18801880
<a href="#">Game Servers</a>
18811881
<ul class="nav">
1882+
<li>
1883+
<a href="#">Data Sources</a>
1884+
<ul class="nav nav-auto-expand">
1885+
1886+
<li>
1887+
<a href="/docs/providers/google/d/game_services_game_server_deployment_rollout.html">google_game_services_game_server_deployment_rollout</a>
1888+
</li>
1889+
1890+
</ul>
1891+
</li>
18821892
<li>
18831893
<a href="#">Resources</a>
18841894
<ul class="nav nav-auto-expand">

0 commit comments

Comments
 (0)