Skip to content

Commit

Permalink
Add samples, remove beta fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rileykarson committed Aug 27, 2019
1 parent a556ff4 commit 6e3f780
Show file tree
Hide file tree
Showing 75 changed files with 1,440 additions and 27 deletions.
3 changes: 3 additions & 0 deletions build/kcc/samples/address_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "google_compute_address" "ip_address" {
name = "my-address-${local.name_suffix}"
}
18 changes: 18 additions & 0 deletions build/kcc/samples/address_with_subnetwork/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
resource "google_compute_network" "default" {
name = "my-network-${local.name_suffix}"
}

resource "google_compute_subnetwork" "default" {
name = "my-subnet-${local.name_suffix}"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
network = "${google_compute_network.default.self_link}"
}

resource "google_compute_address" "internal_with_subnet_and_address" {
name = "my-internal-address-${local.name_suffix}"
subnetwork = "${google_compute_subnetwork.default.self_link}"
address_type = "INTERNAL"
address = "10.0.42.42"
region = "us-central1"
}
58 changes: 58 additions & 0 deletions build/kcc/samples/autoscaler_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
resource "google_compute_autoscaler" "foobar" {
name = "my-autoscaler-${local.name_suffix}"
zone = "us-central1-f"
target = "${google_compute_instance_group_manager.foobar.self_link}"

autoscaling_policy {
max_replicas = 5
min_replicas = 1
cooldown_period = 60

cpu_utilization {
target = 0.5
}
}
}

resource "google_compute_instance_template" "foobar" {
name = "my-instance-template-${local.name_suffix}"
machine_type = "n1-standard-1"
can_ip_forward = false

tags = ["foo", "bar"]

disk {
source_image = "${data.google_compute_image.debian_9.self_link}"
}

network_interface {
network = "default"
}

metadata = {
foo = "bar"
}

service_account {
scopes = ["userinfo-email", "compute-ro", "storage-ro"]
}
}

resource "google_compute_target_pool" "foobar" {
name = "my-target-pool-${local.name_suffix}"
}

resource "google_compute_instance_group_manager" "foobar" {
name = "my-igm-${local.name_suffix}"
zone = "us-central1-f"

instance_template = "${google_compute_instance_template.foobar.self_link}"

target_pools = ["${google_compute_target_pool.foobar.self_link}"]
base_instance_name = "foobar"
}

data "google_compute_image" "debian_9" {
family = "debian-9"
project = "debian-cloud"
}
11 changes: 11 additions & 0 deletions build/kcc/samples/backend_bucket_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "google_compute_backend_bucket" "image_backend" {
name = "image-backend-bucket-${local.name_suffix}"
description = "Contains beautiful images"
bucket_name = "${google_storage_bucket.image_bucket.name}"
enable_cdn = true
}

resource "google_storage_bucket" "image_bucket" {
name = "image-store-bucket-${local.name_suffix}"
location = "EU"
}
11 changes: 11 additions & 0 deletions build/kcc/samples/backend_service_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
resource "google_compute_backend_service" "default" {
name = "backend-service-${local.name_suffix}"
health_checks = ["${google_compute_http_health_check.default.self_link}"]
}

resource "google_compute_http_health_check" "default" {
name = "health-check-${local.name_suffix}"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
20 changes: 20 additions & 0 deletions build/kcc/samples/bigquery_dataset_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
resource "google_bigquery_dataset" "dataset" {
dataset_id = "example_dataset-${local.name_suffix}"
friendly_name = "test"
description = "This is a test description"
location = "EU"
default_table_expiration_ms = 3600000

labels = {
env = "default"
}

access {
role = "OWNER"
user_by_email = "[email protected]"
}
access {
role = "READER"
domain = "example.com"
}
}
17 changes: 17 additions & 0 deletions build/kcc/samples/bigtable_app_profile_multicluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
resource "google_bigtable_instance" "instance" {
name = "tf-test-instance--${local.name_suffix}"
cluster {
cluster_id = "tf-test-instance--${local.name_suffix}"
zone = "us-central1-b"
num_nodes = 3
storage_type = "HDD"
}
}

resource "google_bigtable_app_profile" "ap" {
instance = google_bigtable_instance.instance.name
app_profile_id = "tf-test-profile--${local.name_suffix}"

multi_cluster_routing_use_any = true
ignore_warnings = true
}
21 changes: 21 additions & 0 deletions build/kcc/samples/bigtable_app_profile_singlecluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
resource "google_bigtable_instance" "instance" {
name = "tf-test-instance--${local.name_suffix}"
cluster {
cluster_id = "tf-test-instance--${local.name_suffix}"
zone = "us-central1-b"
num_nodes = 3
storage_type = "HDD"
}
}

resource "google_bigtable_app_profile" "ap" {
instance = google_bigtable_instance.instance.name
app_profile_id = "tf-test-profile--${local.name_suffix}"

single_cluster_routing {
cluster_id = "tf-test-instance--${local.name_suffix}"
allow_transactional_writes = true
}

ignore_warnings = true
}
13 changes: 13 additions & 0 deletions build/kcc/samples/cloudbuild_trigger_filename/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
resource "google_cloudbuild_trigger" "filename-trigger" {
trigger_template {
branch_name = "master"
repo_name = "my-repo"
}

substitutions = {
_FOO = "bar"
_BAZ = "qux"
}

filename = "cloudbuild.yaml"
}
10 changes: 10 additions & 0 deletions build/kcc/samples/disk_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "google_compute_disk" "default" {
name = "test-disk-${local.name_suffix}"
type = "pd-ssd"
zone = "us-central1-a"
image = "debian-8-jessie-v20170523"
labels = {
environment = "dev"
}
physical_block_size_bytes = 4096
}
12 changes: 12 additions & 0 deletions build/kcc/samples/dns_managed_zone_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
resource "google_dns_managed_zone" "example-zone" {
name = "example-zone"
dns_name = "example-${random_id.rnd.hex}.com."
description = "Example DNS zone"
labels = {
foo = "bar"
}
}

resource "random_id" "rnd" {
byte_length = 4
}
29 changes: 29 additions & 0 deletions build/kcc/samples/dns_managed_zone_private/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
resource "google_dns_managed_zone" "private-zone" {
name = "private-zone-${local.name_suffix}"
dns_name = "private.example.com."
description = "Example private DNS zone"
labels = {
foo = "bar"
}

visibility = "private"

private_visibility_config {
networks {
network_url = "${google_compute_network.network-1.self_link}"
}
networks {
network_url = "${google_compute_network.network-2.self_link}"
}
}
}

resource "google_compute_network" "network-1" {
name = "network-1-${local.name_suffix}"
auto_create_subnetworks = false
}

resource "google_compute_network" "network-2" {
name = "network-2-${local.name_suffix}"
auto_create_subnetworks = false
}
15 changes: 15 additions & 0 deletions build/kcc/samples/filestore_instance_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
resource "google_filestore_instance" "instance" {
name = "test-instance-${local.name_suffix}"
zone = "us-central1-b"
tier = "PREMIUM"

file_shares {
capacity_gb = 2660
name = "share1"
}

networks {
network = "default"
modes = ["MODE_IPV4"]
}
}
19 changes: 19 additions & 0 deletions build/kcc/samples/firewall_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
resource "google_compute_firewall" "default" {
name = "test-firewall-${local.name_suffix}"
network = "${google_compute_network.default.name}"

allow {
protocol = "icmp"
}

allow {
protocol = "tcp"
ports = ["80", "8080", "1000-2000"]
}

source_tags = ["web"]
}

resource "google_compute_network" "default" {
name = "test-network-${local.name_suffix}"
}
9 changes: 9 additions & 0 deletions build/kcc/samples/forwarding_rule_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
resource "google_compute_forwarding_rule" "default" {
name = "website-forwarding-rule-${local.name_suffix}"
target = "${google_compute_target_pool.default.self_link}"
port_range = "80"
}

resource "google_compute_target_pool" "default" {
name = "website-target-pool-${local.name_suffix}"
}
39 changes: 39 additions & 0 deletions build/kcc/samples/forwarding_rule_internallb/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Forwarding rule for Internal Load Balancing
resource "google_compute_forwarding_rule" "default" {
name = "website-forwarding-rule-${local.name_suffix}"
region = "us-central1"

load_balancing_scheme = "INTERNAL"
backend_service = "${google_compute_region_backend_service.backend.self_link}"
all_ports = true
network = "${google_compute_network.default.name}"
subnetwork = "${google_compute_subnetwork.default.name}"
}

resource "google_compute_region_backend_service" "backend" {
name = "website-backend-${local.name_suffix}"
region = "us-central1"
health_checks = ["${google_compute_health_check.hc.self_link}"]
}

resource "google_compute_health_check" "hc" {
name = "check-website-backend-${local.name_suffix}"
check_interval_sec = 1
timeout_sec = 1

tcp_health_check {
port = "80"
}
}

resource "google_compute_network" "default" {
name = "website-net-${local.name_suffix}"
auto_create_subnetworks = false
}

resource "google_compute_subnetwork" "default" {
name = "website-net-${local.name_suffix}"
ip_cidr_range = "10.0.0.0/16"
region = "us-central1"
network = "${google_compute_network.default.self_link}"
}
3 changes: 3 additions & 0 deletions build/kcc/samples/global_address_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resource "google_compute_global_address" "default" {
name = "global-appserver-ip-${local.name_suffix}"
}
48 changes: 48 additions & 0 deletions build/kcc/samples/global_forwarding_rule_http/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
resource "google_compute_global_forwarding_rule" "default" {
name = "global-rule-${local.name_suffix}"
target = "${google_compute_target_http_proxy.default.self_link}"
port_range = "80"
}

resource "google_compute_target_http_proxy" "default" {
name = "target-proxy-${local.name_suffix}"
description = "a description"
url_map = "${google_compute_url_map.default.self_link}"
}

resource "google_compute_url_map" "default" {
name = "url-map-target-proxy-${local.name_suffix}"
description = "a description"
default_service = "${google_compute_backend_service.default.self_link}"

host_rule {
hosts = ["mysite.com"]
path_matcher = "allpaths"
}

path_matcher {
name = "allpaths"
default_service = "${google_compute_backend_service.default.self_link}"

path_rule {
paths = ["/*"]
service = "${google_compute_backend_service.default.self_link}"
}
}
}

resource "google_compute_backend_service" "default" {
name = "backend-${local.name_suffix}"
port_name = "http"
protocol = "HTTP"
timeout_sec = 10

health_checks = ["${google_compute_http_health_check.default.self_link}"]
}

resource "google_compute_http_health_check" "default" {
name = "check-backend-${local.name_suffix}"
request_path = "/"
check_interval_sec = 1
timeout_sec = 1
}
10 changes: 10 additions & 0 deletions build/kcc/samples/health_check_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
resource "google_compute_health_check" "internal-health-check" {
name = "internal-service-health-check-${local.name_suffix}"

timeout_sec = 1
check_interval_sec = 1

tcp_health_check {
port = "80"
}
}
7 changes: 7 additions & 0 deletions build/kcc/samples/http_health_check_basic/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
resource "google_compute_http_health_check" "default" {
name = "authentication-health-check-${local.name_suffix}"
request_path = "/health_check"

timeout_sec = 1
check_interval_sec = 1
}
Loading

0 comments on commit 6e3f780

Please sign in to comment.