File tree Expand file tree Collapse file tree 5 files changed +138
-0
lines changed
examples/compute_instance/tags Expand file tree Collapse file tree 5 files changed +138
-0
lines changed Original file line number Diff line number Diff line change 1+ # Instance with tags
2+
3+ This example creates a VM instance with network tags.
4+ Tags enable you to make firewall rules and routes applicable to
5+ specific VM instances.
6+
7+ <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
8+ ## Inputs
9+
10+ | Name | Description | Type | Default | Required |
11+ | ------| -------------| ------| ---------| :--------:|
12+ | project\_ id | The Google Cloud project ID | ` string ` | n/a | yes |
13+
14+ ## Outputs
15+
16+ | Name | Description |
17+ | ------| -------------|
18+ | instance\_ self\_ link | The URI of the instance rule being created |
19+ | network\_ name | The name of the VPC network where the VM instance is created |
20+ | project\_ id | Google Cloud project ID |
21+ | tags | Tags added to VM instance |
22+
23+ <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
Original file line number Diff line number Diff line change 1+ /* *
2+ * Copyright 2018 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ provider "google" {
18+
19+ version = " ~> 3.0"
20+ }
21+
22+ # [START compute_vm_with_tags_create]
23+ resource "google_compute_instance" "default" {
24+ project = var. project_id # Replace this with your project ID in quotes
25+ zone = " southamerica-east1-b"
26+ name = " backend-instance"
27+ machine_type = " e2-medium"
28+ boot_disk {
29+ initialize_params {
30+ image = " debian-cloud/debian-9"
31+ }
32+ }
33+ network_interface {
34+ network = " default"
35+ }
36+ tags = [" health-check" , " ssh" ]
37+ }
38+ # [END compute_vm_with_tags_create]
Original file line number Diff line number Diff line change 1+ /* *
2+ * Copyright 2018 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+
18+ output "network_name" {
19+ value = google_compute_instance. default . network_interface [0 ]. network
20+ description = " The name of the VPC network where the VM instance is created"
21+ }
22+
23+ output "instance_self_link" {
24+ value = google_compute_instance. default . self_link
25+ description = " The URI of the instance rule being created"
26+ }
27+
28+ output "tags" {
29+ value = google_compute_instance. default . tags
30+ description = " Tags added to VM instance"
31+ }
32+
33+ output "project_id" {
34+ value = google_compute_instance. default . project
35+ description = " Google Cloud project ID"
36+ }
Original file line number Diff line number Diff line change 1+ /* *
2+ * Copyright 2019 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+
18+
19+ variable "project_id" {
20+ description = " The Google Cloud project ID"
21+ type = string
22+ }
Original file line number Diff line number Diff line change 1+ /* *
2+ * Copyright 2018 Google LLC
3+ *
4+ * Licensed under the Apache License, Version 2.0 (the "License");
5+ * you may not use this file except in compliance with the License.
6+ * You may obtain a copy of the License at
7+ *
8+ * http://www.apache.org/licenses/LICENSE-2.0
9+ *
10+ * Unless required by applicable law or agreed to in writing, software
11+ * distributed under the License is distributed on an "AS IS" BASIS,
12+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+ * See the License for the specific language governing permissions and
14+ * limitations under the License.
15+ */
16+
17+ terraform {
18+ required_version = " >=0.12.6"
19+ }
You can’t perform that action at this time.
0 commit comments