website/docs: Run terraform fmt on code examples (#12075)

* docs/vsphere: Fix code block

* docs: Convert `...` to `# ...` to allow `terraform fmt`ing

* docs: Trim trailing whitespace

* docs: First-pass run of `terraform fmt` on code examples
This commit is contained in:
George Christou 2017-02-18 22:48:50 +00:00 committed by Paul Stack
parent fc78bd934d
commit 06fa75423e
24 changed files with 75 additions and 63 deletions

View File

@ -16,12 +16,15 @@ other Google Cloud Platform resources, such as the `google_project` resource.
data "google_iam_policy" "admin" { data "google_iam_policy" "admin" {
binding { binding {
role = "roles/compute.instanceAdmin" role = "roles/compute.instanceAdmin"
members = [ members = [
"serviceAccount:your-custom-sa@your-project.iam.gserviceaccount.com", "serviceAccount:your-custom-sa@your-project.iam.gserviceaccount.com",
] ]
} }
binding { binding {
role = "roles/storage.objectViewer" role = "roles/storage.objectViewer"
members = [ members = [
"user:evanbrown@google.com", "user:evanbrown@google.com",
] ]

View File

@ -41,6 +41,7 @@ resource "google_compute_url_map" "default" {
path_matcher { path_matcher {
name = "allpaths" name = "allpaths"
default_service = "${google_compute_backend_service.default.self_link}" default_service = "${google_compute_backend_service.default.self_link}"
path_rule { path_rule {
paths = ["/*"] paths = ["/*"]
service = "${google_compute_backend_service.default.self_link}" service = "${google_compute_backend_service.default.self_link}"

View File

@ -23,6 +23,7 @@ resource "google_compute_health_check" "default" {
timeout_sec = 1 timeout_sec = 1
check_interval_sec = 1 check_interval_sec = 1
tcp_health_check { tcp_health_check {
port = "80" port = "80"
} }

View File

@ -17,7 +17,8 @@ tarball. For more information see [the official documentation](https://cloud.goo
```js ```js
resource "google_compute_image" "bootable-image" { resource "google_compute_image" "bootable-image" {
name = "my-custom-image" name = "my-custom-image"
raw_disk { raw_disk {
source = "https://storage.googleapis.com/my-bucket/my-disk-image-tarball.tar.gz" source = "https://storage.googleapis.com/my-bucket/my-disk-image-tarball.tar.gz"
} }
@ -33,7 +34,7 @@ resource "google_compute_instance" "vm" {
} }
network_interface { network_interface {
network = "default" network = "default"
} }
} }
``` ```

View File

@ -36,6 +36,7 @@ resource "google_compute_instance" "default" {
network_interface { network_interface {
network = "default" network = "default"
access_config { access_config {
// Ephemeral IP // Ephemeral IP
} }
@ -72,7 +73,7 @@ The following arguments are supported:
* `network_interface` - (Required) Networks to attach to the instance. This can * `network_interface` - (Required) Networks to attach to the instance. This can
be specified multiple times for multiple networks, but GCE is currently be specified multiple times for multiple networks, but GCE is currently
limited to just 1. Structure is documented below. limited to just 1. Structure is documented below.
- - - - - -
* `can_ip_forward` - (Optional) Whether to allow sending and receiving of * `can_ip_forward` - (Optional) Whether to allow sending and receiving of
@ -103,7 +104,7 @@ The following arguments are supported:
* `create_timeout` - (Optional) Configurable timeout in minutes for creating instances. Default is 4 minutes. * `create_timeout` - (Optional) Configurable timeout in minutes for creating instances. Default is 4 minutes.
Changing this forces a new resource to be created. Changing this forces a new resource to be created.
--- ---
* `network` - (DEPRECATED, Required) Networks to attach to the instance. This * `network` - (DEPRECATED, Required) Networks to attach to the instance. This

View File

@ -32,7 +32,7 @@ resource "google_compute_instance_group" "webservers" {
instances = [ instances = [
"${google_compute_instance.test.self_link}", "${google_compute_instance.test.self_link}",
"${google_compute_instance.test2.self_link}" "${google_compute_instance.test2.self_link}",
] ]
named_port { named_port {

View File

@ -36,8 +36,8 @@ resource "google_compute_instance_template" "foobar" {
// Create a new boot disk from an image // Create a new boot disk from an image
disk { disk {
source_image = "debian-cloud/debian-8" source_image = "debian-cloud/debian-8"
auto_delete = true auto_delete = true
boot = true boot = true
} }
// Use an existing disk resource // Use an existing disk resource
@ -73,31 +73,31 @@ with `name_prefix`. Example:
``` ```
resource "google_compute_instance_template" "instance_template" { resource "google_compute_instance_template" "instance_template" {
name_prefix = "instance-template-" name_prefix = "instance-template-"
machine_type = "n1-standard-1" machine_type = "n1-standard-1"
region = "us-central1" region = "us-central1"
// boot disk // boot disk
disk { disk {
... # ...
} }
// networking // networking
network_interface { network_interface {
... # ...
} }
lifecycle { lifecycle {
create_before_destroy = true create_before_destroy = true
} }
} }
resource "google_compute_instance_group_manager" "instance_group_manager" { resource "google_compute_instance_group_manager" "instance_group_manager" {
name = "instance-group-manager" name = "instance-group-manager"
instance_template = "${google_compute_instance_template.instance_template.self_link}" instance_template = "${google_compute_instance_template.instance_template.self_link}"
base_instance_name = "instance-group-manager" base_instance_name = "instance-group-manager"
zone = "us-central1-f" zone = "us-central1-f"
target_size = "1" target_size = "1"
} }
``` ```

View File

@ -39,7 +39,7 @@ The following arguments are supported:
* `ipv4_range` - (DEPRECATED, Optional) The IPv4 address range that machines in this network * `ipv4_range` - (DEPRECATED, Optional) The IPv4 address range that machines in this network
are assigned to, represented as a CIDR block. If not set, an auto or custom are assigned to, represented as a CIDR block. If not set, an auto or custom
subnetted network will be created, depending on the value of subnetted network will be created, depending on the value of
`auto_create_subnetworks` attribute. This attribute may not be used if `auto_create_subnetworks` attribute. This attribute may not be used if
`auto_create_subnetworks` is specified. This attribute is deprecated. `auto_create_subnetworks` is specified. This attribute is deprecated.

View File

@ -12,12 +12,12 @@ Manages metadata common to all instances for a project in GCE.
## Example Usage ## Example Usage
```js ```
resource "google_compute_project_metadata" "default" { resource "google_compute_project_metadata" "default" {
metadata { metadata {
foo = "bar" foo = "bar"
fizz = "buzz" fizz = "buzz"
13 = "42" "13" = "42"
} }
} }
``` ```

View File

@ -16,11 +16,11 @@ See [backendServices](https://cloud.google.com/compute/docs/reference/latest/bac
```tf ```tf
resource "google_compute_region_backend_service" "foobar" { resource "google_compute_region_backend_service" "foobar" {
name = "blablah" name = "blablah"
description = "Hello World 1234" description = "Hello World 1234"
protocol = "TCP" protocol = "TCP"
timeout_sec = 10 timeout_sec = 10
session_affinity = "CLIENT_IP" session_affinity = "CLIENT_IP"
backend { backend {
group = "${google_compute_instance_group_manager.foo.instance_group}" group = "${google_compute_instance_group_manager.foo.instance_group}"
@ -57,6 +57,7 @@ resource "google_compute_health_check" "default" {
check_interval_sec = 1 check_interval_sec = 1
timeout_sec = 1 timeout_sec = 1
type = "TCP" type = "TCP"
tcp_health_check { tcp_health_check {
port = "80" port = "80"
} }

View File

@ -31,7 +31,7 @@ The following arguments are supported:
* `name` - (Required) A unique name for the resource, required by GCE. * `name` - (Required) A unique name for the resource, required by GCE.
Changing this forces a new resource to be created. Changing this forces a new resource to be created.
* `network` - (Required) The network name or resource link to the parent * `network` - (Required) The network name or resource link to the parent
network of this subnetwork. The parent network must have been created network of this subnetwork. The parent network must have been created
in custom subnet mode. in custom subnet mode.

View File

@ -39,7 +39,7 @@ resource "google_compute_url_map" "default" {
default_service = "${google_compute_backend_service.default.self_link}" default_service = "${google_compute_backend_service.default.self_link}"
path_rule { path_rule {
paths = ["/*"] paths = ["/*"]
service = "${google_compute_backend_service.default.self_link}" service = "${google_compute_backend_service.default.self_link}"
} }
} }

View File

@ -47,7 +47,7 @@ resource "google_compute_url_map" "default" {
default_service = "${google_compute_backend_service.default.self_link}" default_service = "${google_compute_backend_service.default.self_link}"
path_rule { path_rule {
paths = ["/*"] paths = ["/*"]
service = "${google_compute_backend_service.default.self_link}" service = "${google_compute_backend_service.default.self_link}"
} }
} }

View File

@ -89,7 +89,7 @@ The following arguments are supported:
* `name` - (Required) A unique name for the resource, required by GCE. Changing * `name` - (Required) A unique name for the resource, required by GCE. Changing
this forces a new resource to be created. this forces a new resource to be created.
* `network` - (Required) The name or resource link to the network this VPN gateway * `network` - (Required) The name or resource link to the network this VPN gateway
is accepting traffic for. Changing this forces a new resource to be created. is accepting traffic for. Changing this forces a new resource to be created.
- - - - - -

View File

@ -66,7 +66,7 @@ resource "google_compute_vpn_tunnel" "tunnel1" {
target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}" target_vpn_gateway = "${google_compute_vpn_gateway.target_gateway.self_link}"
local_traffic_selector = ["${google_compute_subnetwork.subnet1.ip_cidr_range}"] local_traffic_selector = ["${google_compute_subnetwork.subnet1.ip_cidr_range}"]
remote_traffic_selector = ["172.16.0.0/12"] remote_traffic_selector = ["172.16.0.0/12"]
depends_on = [ depends_on = [

View File

@ -16,13 +16,13 @@ whole cluster!
```js ```js
resource "google_container_cluster" "primary" { resource "google_container_cluster" "primary" {
name = "marcellus-wallace" name = "marcellus-wallace"
zone = "us-central1-a" zone = "us-central1-a"
initial_node_count = 3 initial_node_count = 3
additional_zones = [ additional_zones = [
"us-central1-b", "us-central1-b",
"us-central1-c" "us-central1-c",
] ]
master_auth { master_auth {
@ -35,7 +35,7 @@ resource "google_container_cluster" "primary" {
"https://www.googleapis.com/auth/compute", "https://www.googleapis.com/auth/compute",
"https://www.googleapis.com/auth/devstorage.read_only", "https://www.googleapis.com/auth/devstorage.read_only",
"https://www.googleapis.com/auth/logging.write", "https://www.googleapis.com/auth/logging.write",
"https://www.googleapis.com/auth/monitoring" "https://www.googleapis.com/auth/monitoring",
] ]
} }
} }
@ -83,8 +83,8 @@ resource "google_container_cluster" "primary" {
this cluster this cluster
* `node_version` - (Optional) The Kubernetes version on the nodes. Also affects * `node_version` - (Optional) The Kubernetes version on the nodes. Also affects
the initial master version on cluster creation. Updates affect nodes only. the initial master version on cluster creation. Updates affect nodes only.
Defaults to the default version set by GKE which is not necessarily the latest Defaults to the default version set by GKE which is not necessarily the latest
version. version.
* `project` - (Optional) The project in which the resource belongs. If it * `project` - (Optional) The project in which the resource belongs. If it

View File

@ -25,10 +25,11 @@ resource "google_compute_instance" "frontend" {
} }
network_interface { network_interface {
network = "default" network = "default"
access_config {} access_config = {}
} }
} }
resource "google_dns_managed_zone" "prod" { resource "google_dns_managed_zone" "prod" {
name = "prod-zone" name = "prod-zone"
dns_name = "prod.mydomain.com." dns_name = "prod.mydomain.com."

View File

@ -3,7 +3,7 @@ layout: "google"
page_title: "Google: google_project" page_title: "Google: google_project"
sidebar_current: "docs-google-project" sidebar_current: "docs-google-project"
description: |- description: |-
Allows management of a Google Cloud Platform project. Allows management of a Google Cloud Platform project.
--- ---
# google\_project # google\_project
@ -23,9 +23,9 @@ doc for more information.
```js ```js
resource "google_project" "my_project" { resource "google_project" "my_project" {
project_id = "your-project-id" project_id = "your-project-id"
org_id = "1234567" org_id = "1234567"
services = ["compute_component", "storage-component-json.googleapis.com", "iam.googleapis.com"] services = ["compute_component", "storage-component-json.googleapis.com", "iam.googleapis.com"]
} }
``` ```

View File

@ -3,7 +3,7 @@ layout: "google"
page_title: "Google: google_project_iam_policy" page_title: "Google: google_project_iam_policy"
sidebar_current: "docs-google-project-iam-policy" sidebar_current: "docs-google-project-iam-policy"
description: |- description: |-
Allows management of an IAM policy for a Google Cloud Platform project. Allows management of an IAM policy for a Google Cloud Platform project.
--- ---
# google\_project\_iam\_policy # google\_project\_iam\_policy
@ -15,13 +15,14 @@ Platform project.
```js ```js
resource "google_project_iam_policy" "project" { resource "google_project_iam_policy" "project" {
project = "your-project-id" project = "your-project-id"
policy_data = "${data.google_iam_policy.admin.policy_data}" policy_data = "${data.google_iam_policy.admin.policy_data}"
} }
data "google_iam_policy" "admin" { data "google_iam_policy" "admin" {
binding { binding {
role = "roles/editor" role = "roles/editor"
members = [ members = [
"user:jane@example.com", "user:jane@example.com",
] ]

View File

@ -3,7 +3,7 @@ layout: "google"
page_title: "Google: google_project_services" page_title: "Google: google_project_services"
sidebar_current: "docs-google-project-services" sidebar_current: "docs-google-project-services"
description: |- description: |-
Allows management of API services for a Google Cloud Platform project. Allows management of API services for a Google Cloud Platform project.
--- ---
# google\_project\_services # google\_project\_services
@ -17,7 +17,7 @@ in the config will be removed.
```js ```js
resource "google_project_services" "project" { resource "google_project_services" "project" {
project_id = "your-project-id" project_id = "your-project-id"
services = ["iam.googleapis.com", "cloudresourcemanager.googleapis.com"] services = ["iam.googleapis.com", "cloudresourcemanager.googleapis.com"]
} }
``` ```

View File

@ -3,7 +3,7 @@ layout: "google"
page_title: "Google: google_service_account" page_title: "Google: google_service_account"
sidebar_current: "docs-google-service-account" sidebar_current: "docs-google-service-account"
description: |- description: |-
Allows management of a Google Cloud Platform service account. Allows management of a Google Cloud Platform service account.
--- ---
# google\_service\_account # google\_service\_account
@ -17,18 +17,19 @@ permission in a project.
```js ```js
resource "google_service_account" "object_viewer" { resource "google_service_account" "object_viewer" {
account_id = "object-viewer" account_id = "object-viewer"
display_name = "Object viewer" display_name = "Object viewer"
} }
resource "google_project" "my_project" { resource "google_project" "my_project" {
id = "your-project-id" id = "your-project-id"
policy_data = "${data.google_iam_policy.admin.policy_data}" policy_data = "${data.google_iam_policy.admin.policy_data}"
} }
data "google_iam_policy" "admin" { data "google_iam_policy" "admin" {
binding { binding {
role = "roles/storage.objectViewer" role = "roles/storage.objectViewer"
members = [ members = [
"serviceAccount:${google_service_account.object_viewer.email}", "serviceAccount:${google_service_account.object_viewer.email}",
] ]

View File

@ -24,6 +24,7 @@ resource "google_pubsub_subscription" "default" {
push_config { push_config {
endpoint = "https://example.com/push" endpoint = "https://example.com/push"
attributes { attributes {
x-goog-version = "v1" x-goog-version = "v1"
} }

View File

@ -22,7 +22,7 @@ resource "google_storage_bucket" "image-store" {
website { website {
main_page_suffix = "index.html" main_page_suffix = "index.html"
not_found_page = "404.html" not_found_page = "404.html"
} }
} }
``` ```

View File

@ -21,7 +21,7 @@ resource "google_storage_bucket" "image-store" {
} }
resource "google_storage_bucket_object" "image" { resource "google_storage_bucket_object" "image" {
name = "image1" name = "image1"
bucket = "${google_storage_bucket.name}" bucket = "${google_storage_bucket.name}"
source = "image1.jpg" source = "image1.jpg"
} }