diff --git a/data_fusion_instance_basic/main.tf b/data_fusion_instance_basic/main.tf index e308d84e..9df31dd8 100644 --- a/data_fusion_instance_basic/main.tf +++ b/data_fusion_instance_basic/main.tf @@ -1,7 +1,7 @@ resource "google_data_fusion_instance" "basic_instance" { - name = "my-instance-${local.name_suffix}" + name = "my-instance-${local.name_suffix}" region = "us-central1" - type = "BASIC" + type = "BASIC" # Mark for testing to avoid service networking connection usage that is not cleaned up options = { prober_test_run = "true" diff --git a/data_fusion_instance_cmek/main.tf b/data_fusion_instance_cmek/main.tf index adfbda7a..1e9504b8 100644 --- a/data_fusion_instance_cmek/main.tf +++ b/data_fusion_instance_cmek/main.tf @@ -1,4 +1,4 @@ -resource "google_data_fusion_instance" "basic_cmek" { +resource "google_data_fusion_instance" "cmek" { name = "my-instance-${local.name_suffix}" region = "us-central1" type = "BASIC" diff --git a/data_fusion_instance_event/backing_file.tf b/data_fusion_instance_event/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/data_fusion_instance_event/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/data_fusion_instance_event/main.tf b/data_fusion_instance_event/main.tf new file mode 100644 index 00000000..5f2512ba --- /dev/null +++ b/data_fusion_instance_event/main.tf @@ -0,0 +1,15 @@ +resource "google_data_fusion_instance" "event" { + name = "my-instance-${local.name_suffix}" + region = "us-central1" + type = "BASIC" + version = "6.7.0" + + event_publish_config { + enabled = true + topic = google_pubsub_topic.event.id + } +} + +resource "google_pubsub_topic" "event" { + name = "my-instance-${local.name_suffix}" +} diff --git a/data_fusion_instance_event/motd b/data_fusion_instance_event/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/data_fusion_instance_event/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/data_fusion_instance_event/tutorial.md b/data_fusion_instance_event/tutorial.md new file mode 100644 index 00000000..eb8ba4c0 --- /dev/null +++ b/data_fusion_instance_event/tutorial.md @@ -0,0 +1,79 @@ +# Data Fusion Instance Event - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +``` diff --git a/data_fusion_instance_full/main.tf b/data_fusion_instance_full/main.tf index 41f00ddb..c48a4f57 100644 --- a/data_fusion_instance_full/main.tf +++ b/data_fusion_instance_full/main.tf @@ -1,20 +1,24 @@ resource "google_data_fusion_instance" "extended_instance" { - name = "my-instance-${local.name_suffix}" - description = "My Data Fusion instance" - region = "us-central1" - type = "BASIC" - enable_stackdriver_logging = true + name = "my-instance-${local.name_suffix}" + description = "My Data Fusion instance" + display_name = "My Data Fusion instance" + region = "us-central1" + type = "BASIC" + enable_stackdriver_logging = true enable_stackdriver_monitoring = true + private_instance = true + version = "6.6.0" + dataproc_service_account = data.google_app_engine_default_service_account.default.email + labels = { example_key = "example_value" } - private_instance = true + network_config { - network = "default" - ip_allocation = "10.89.48.0/22" + network = "default" + ip_allocation = "${google_compute_global_address.private_ip_alloc.address}/${google_compute_global_address.private_ip_alloc.prefix_length}" } - version = "6.3.0" - dataproc_service_account = data.google_app_engine_default_service_account.default.email + # Mark for testing to avoid service networking connection usage that is not cleaned up options = { prober_test_run = "true" @@ -23,3 +27,15 @@ resource "google_data_fusion_instance" "extended_instance" { data "google_app_engine_default_service_account" "default" { } + +resource "google_compute_network" "network" { + name = "datafusion-full-network-${local.name_suffix}" +} + +resource "google_compute_global_address" "private_ip_alloc" { + name = "datafusion-ip-alloc-${local.name_suffix}" + address_type = "INTERNAL" + purpose = "VPC_PEERING" + prefix_length = 22 + network = google_compute_network.network.id +} diff --git a/data_fusion_instance_zone/backing_file.tf b/data_fusion_instance_zone/backing_file.tf new file mode 100644 index 00000000..c60b1199 --- /dev/null +++ b/data_fusion_instance_zone/backing_file.tf @@ -0,0 +1,15 @@ +# This file has some scaffolding to make sure that names are unique and that +# a region and zone are selected when you try to create your Terraform resources. + +locals { + name_suffix = "${random_pet.suffix.id}" +} + +resource "random_pet" "suffix" { + length = 2 +} + +provider "google" { + region = "us-central1" + zone = "us-central1-c" +} diff --git a/data_fusion_instance_zone/main.tf b/data_fusion_instance_zone/main.tf new file mode 100644 index 00000000..bf11022f --- /dev/null +++ b/data_fusion_instance_zone/main.tf @@ -0,0 +1,6 @@ +resource "google_data_fusion_instance" "zone" { + name = "my-instance-${local.name_suffix}" + region = "us-central1" + zone = "us-central1-a" + type = "DEVELOPER" +} diff --git a/data_fusion_instance_zone/motd b/data_fusion_instance_zone/motd new file mode 100644 index 00000000..45a906e8 --- /dev/null +++ b/data_fusion_instance_zone/motd @@ -0,0 +1,7 @@ +=== + +These examples use real resources that will be billed to the +Google Cloud Platform project you use - so make sure that you +run "terraform destroy" before quitting! + +=== diff --git a/data_fusion_instance_zone/tutorial.md b/data_fusion_instance_zone/tutorial.md new file mode 100644 index 00000000..a596a62b --- /dev/null +++ b/data_fusion_instance_zone/tutorial.md @@ -0,0 +1,79 @@ +# Data Fusion Instance Zone - Terraform + +## Setup + + + +Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform. + + + +Terraform provisions real GCP resources, so anything you create in this session will be billed against this project. + +## Terraforming! + +Let's use {{project-id}} with Terraform! Click the Cloud Shell icon below to copy the command +to your shell, and then run it from the shell by pressing Enter/Return. Terraform will pick up +the project name from the environment variable. + +```bash +export GOOGLE_CLOUD_PROJECT={{project-id}} +``` + +After that, let's get Terraform started. Run the following to pull in the providers. + +```bash +terraform init +``` + +With the providers downloaded and a project set, you're ready to use Terraform. Go ahead! + +```bash +terraform apply +``` + +Terraform will show you what it plans to do, and prompt you to accept. Type "yes" to accept the plan. + +```bash +yes +``` + + +## Post-Apply + +### Editing your config + +Now you've provisioned your resources in GCP! If you run a "plan", you should see no changes needed. + +```bash +terraform plan +``` + +So let's make a change! Try editing a number, or appending a value to the name in the editor. Then, +run a 'plan' again. + +```bash +terraform plan +``` + +Afterwards you can run an apply, which implicitly does a plan and shows you the intended changes +at the 'yes' prompt. + +```bash +terraform apply +``` + +```bash +yes +``` + +## Cleanup + +Run the following to remove the resources Terraform provisioned: + +```bash +terraform destroy +``` +```bash +yes +```