Skip to content

Commit

Permalink
datafusion - add args + iam support (#6270)
Browse files Browse the repository at this point in the history
Closes hashicorp/terraform-provider-google#10536
Closes hashicorp/terraform-provider-google#9065
Closes hashicorp/terraform-provider-google#9068

Signed-off-by: Modular Magician <magic-modules@google.com>
  • Loading branch information
modular-magician committed Nov 29, 2022
1 parent e3ccc46 commit e7bca24
Show file tree
Hide file tree
Showing 11 changed files with 252 additions and 13 deletions.
4 changes: 2 additions & 2 deletions data_fusion_instance_basic/main.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
2 changes: 1 addition & 1 deletion data_fusion_instance_cmek/main.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
15 changes: 15 additions & 0 deletions data_fusion_instance_event/backing_file.tf
Original file line number Diff line number Diff line change
@@ -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"
}
15 changes: 15 additions & 0 deletions data_fusion_instance_event/main.tf
Original file line number Diff line number Diff line change
@@ -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}"
}
7 changes: 7 additions & 0 deletions data_fusion_instance_event/motd
Original file line number Diff line number Diff line change
@@ -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!

===
79 changes: 79 additions & 0 deletions data_fusion_instance_event/tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Data Fusion Instance Event - Terraform

## Setup

<walkthrough-author name="rileykarson@google.com" analyticsId="UA-125550242-1" tutorialName="data_fusion_instance_event" repositoryUrl="https://github.com/terraform-google-modules/docs-examples"></walkthrough-author>

Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform.

<walkthrough-project-billing-setup></walkthrough-project-billing-setup>

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
```
36 changes: 26 additions & 10 deletions data_fusion_instance_full/main.tf
Original file line number Diff line number Diff line change
@@ -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"
Expand All @@ -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
}
15 changes: 15 additions & 0 deletions data_fusion_instance_zone/backing_file.tf
Original file line number Diff line number Diff line change
@@ -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"
}
6 changes: 6 additions & 0 deletions data_fusion_instance_zone/main.tf
Original file line number Diff line number Diff line change
@@ -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"
}
7 changes: 7 additions & 0 deletions data_fusion_instance_zone/motd
Original file line number Diff line number Diff line change
@@ -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!

===
79 changes: 79 additions & 0 deletions data_fusion_instance_zone/tutorial.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Data Fusion Instance Zone - Terraform

## Setup

<walkthrough-author name="rileykarson@google.com" analyticsId="UA-125550242-1" tutorialName="data_fusion_instance_zone" repositoryUrl="https://github.com/terraform-google-modules/docs-examples"></walkthrough-author>

Welcome to Terraform in Google Cloud Shell! We need you to let us know what project you'd like to use with Terraform.

<walkthrough-project-billing-setup></walkthrough-project-billing-setup>

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
```

0 comments on commit e7bca24

Please sign in to comment.