Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
eshagoel06 committed Mar 5, 2024
1 parent b4520dc commit bf6a98f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
20 changes: 9 additions & 11 deletions mmv1/templates/terraform/examples/apphub_service_basic.tf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,9 @@ resource "google_apphub_application" "application" {
# org_id = "<%= ctx[:test_env_vars]['org_id'] %>"
# }

# resource "google_apphub_service_project_attachment" "service_project_attachment" {
# service_project_attachment_id = "serviceproject-demo-2"
# depends_on = [google_project_service.apphub]
# }

# create service
resource "google_apphub_service_project_attachment" "service_project_attachment" {
service_project_attachment_id = "serviceproject-demo-3"
}

# discovered service block
data "google_apphub_discovered_service" "catalog-service" {
Expand All @@ -26,6 +23,7 @@ data "google_apphub_discovered_service" "catalog-service" {
# ServiceReference | Application Hub | Google Cloud
# Using this reference means that this resource will not be provisioned until the forwarding rule is fully created
service_uri = "//compute.googleapis.com/${google_compute_forwarding_rule.forwarding_rule.id}"
depends_on = [google_apphub_service_project_attachment.service_project_attachment]
}

resource "google_apphub_service" "<%= ctx[:primary_resource_id] %>" {
Expand All @@ -41,15 +39,15 @@ resource "google_apphub_service" "<%= ctx[:primary_resource_id] %>" {
# VPC network
resource "google_compute_network" "ilb_network" {
name = "<%= ctx[:vars]['ilb_network'] %>"
project = "serviceproject-demo-2"
project = "serviceproject-demo-3"
auto_create_subnetworks = false
}


# backend subnet
resource "google_compute_subnetwork" "ilb_subnet" {
name = "<%= ctx[:vars]['ilb_subnet'] %>"
project = "serviceproject-demo-2"
project = "serviceproject-demo-3"
ip_cidr_range = "10.0.1.0/24"
region = "us-east1"
network = google_compute_network.ilb_network.id
Expand All @@ -58,7 +56,7 @@ resource "google_compute_subnetwork" "ilb_subnet" {
# forwarding rule
resource "google_compute_forwarding_rule" "forwarding_rule" {
name ="<%= ctx[:vars]['forwarding_rule'] %>"
project = "serviceproject-demo-2"
project = "serviceproject-demo-3"
region = "us-east1"
ip_version = "IPV4"
load_balancing_scheme = "INTERNAL"
Expand All @@ -73,15 +71,15 @@ resource "google_compute_forwarding_rule" "forwarding_rule" {
# backend service
resource "google_compute_region_backend_service" "backend" {
name = "<%= ctx[:vars]['backend_service'] %>"
project = "serviceproject-demo-2"
project = "serviceproject-demo-3"
region = "us-east1"
health_checks = [google_compute_health_check.default.id]
}

# health check
resource "google_compute_health_check" "default" {
name = "<%= ctx[:vars]['health_check'] %>"
project = "serviceproject-demo-2"
project = "serviceproject-demo-3"
check_interval_sec = 1
timeout_sec = 1

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package apphub

import (
"fmt"
"time"

"github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema"
"github.com/hashicorp/terraform-provider-google/google/tpgresource"
Expand Down Expand Up @@ -107,7 +108,10 @@ func dataSourceApphubDiscoveredServiceRead(d *schema.ResourceData, meta interfac
return fmt.Errorf("Error setting discovered service: %s", err)
}

d.SetId(d["discovered_service"][0]["name"])
// ds := d.Get("discovered_service").([]map[string]interface{})
// d.SetId(ds[0]["name"].(string))
d.SetId(time.Now().UTC().String())

return nil

}
Expand Down

0 comments on commit bf6a98f

Please sign in to comment.