File tree Expand file tree Collapse file tree 5 files changed +139
-0
lines changed
examples/firewall_logging Expand file tree Collapse file tree 5 files changed +139
-0
lines changed Original file line number Diff line number Diff line change 1+ # Firewall Rule
2+
3+ This example configures a single firewall rule with firewall logging enabled.
4+
5+ <!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
6+ ## Inputs
7+
8+ | Name | Description | Type | Default | Required |
9+ | ------| -------------| ------| ---------| :--------:|
10+ | project\_ id | The project ID to host the network in | ` any ` | n/a | yes |
11+
12+ ## Outputs
13+
14+ | Name | Description |
15+ | ------| -------------|
16+ | name | The name of the firewall rule being created |
17+ | network\_ name | The name of the VPC network where the firewall rule will be applied |
18+ | project\_ id | Google Cloud project ID |
19+ | rule\_ self\_ link | The URI of the firewall rule being created |
20+
21+ <!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
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+ provider "null" {
19+ version = " ~> 2.1"
20+ }
21+
22+ provider "google" {
23+ version = " ~> 3.45.0"
24+ }
25+
26+ # [START vpc_firewall_create]
27+ resource "google_compute_firewall" "rules" {
28+ project = var. project_id # Replace this with your project ID in quotes
29+ name = " my-firewall-rule"
30+ network = " default"
31+ description = " Creates firewall rule targeting tagged instances"
32+
33+ log_config {
34+ metadata = " INCLUDE_ALL_METADATA"
35+ }
36+
37+ allow {
38+ protocol = " tcp"
39+ ports = [" 80" , " 8080" , " 1000-2000" ]
40+ }
41+ target_tags = [" web" ]
42+ }
43+ # [END vpc_firewall_create]
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+ output "name" {
18+ value = google_compute_firewall. rules . name
19+ description = " The name of the firewall rule being created"
20+ }
21+
22+ output "network_name" {
23+ value = google_compute_firewall. rules . network
24+ description = " The name of the VPC network where the firewall rule will be applied"
25+ }
26+
27+ output "rule_self_link" {
28+ value = google_compute_firewall. rules . self_link
29+ description = " The URI of the firewall rule being created"
30+ }
31+
32+ output "project_id" {
33+ value = google_compute_firewall. rules . project
34+ description = " Google Cloud project ID"
35+ }
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+ variable "project_id" {
18+ description = " The project ID to host the network in"
19+ }
20+
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+ terraform {
18+ required_version = " >=0.12.6"
19+ }
20+
You can’t perform that action at this time.
0 commit comments