-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added network edge security policy sub-module
- Loading branch information
1 parent
19ae047
commit 2853214
Showing
13 changed files
with
564 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Enable Cloud Armor Network Edge Security Policy | ||
|
||
This example creates network edge security policy with policy rules. Feature is only availalable to projects enrolled in [Cloud Armor Enterprise](https://cloud.google.com/armor/docs/armor-enterprise-overview) with [Advanced network DDoS protection](https://cloud.google.com/armor/docs/advanced-network-ddos#activate-advanced-ddos-protection) enabled. You can use [example](../advanced-network-ddos-protection/) to deploy advanced newtork ddos protection. | ||
|
||
## Usage | ||
|
||
To run this example you need to execute: | ||
|
||
```bash | ||
export TF_VAR_project_id="your_project_id" | ||
``` | ||
|
||
```bash | ||
terraform init | ||
terraform plan | ||
terraform apply | ||
``` | ||
|
||
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK --> | ||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| project\_id | The project in which the resource belongs | `string` | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| policy\_rules | Security policy rules created | | ||
| security\_policy | Regional Network Security policy created | | ||
|
||
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
resource "random_id" "suffix" { | ||
byte_length = 4 | ||
} | ||
|
||
module "network_edge_security_policy" { | ||
source = "GoogleCloudPlatform/cloud-armor/google//modules/network-edge-security-policy" | ||
version = "~> 2.0" | ||
|
||
project_id = var.project_id | ||
region = "us-central1" | ||
policy_name = "test-nw-edge-security-policy-${random_id.suffix.hex}" | ||
|
||
policy_user_defined_fields = [ | ||
{ | ||
name = "SIG1_AT_0" | ||
base = "UDP" | ||
offset = 8 | ||
size = 2 | ||
mask = "0x8F00" | ||
}, | ||
{ | ||
name = "SIG2_AT_8" | ||
base = "TCP" | ||
offset = 16 | ||
size = 4 | ||
mask = "0xFFFFFFFF" | ||
}, | ||
{ | ||
name = "IPv4-TTL" | ||
base = "IPV4" | ||
offset = 8 | ||
size = 1 | ||
mask = "0xFF" | ||
}, | ||
|
||
] | ||
|
||
policy_rules = [ | ||
{ | ||
priority = 100 | ||
action = "deny" | ||
preview = true | ||
description = "custom rule 100" | ||
src_ip_ranges = ["10.10.0.0/16"] | ||
src_asns = [15169] | ||
src_region_codes = ["AU"] | ||
ip_protocols = ["TCP"] | ||
src_ports = [80] | ||
dest_ports = ["8080"] | ||
dest_ip_ranges = ["10.100.0.0/16"] | ||
user_defined_fields = [ | ||
{ | ||
name = "SIG1_AT_0" | ||
values = ["0x8F00"] | ||
}, | ||
] | ||
}, | ||
{ | ||
priority = 200 | ||
action = "deny" | ||
preview = false | ||
priority = 200 | ||
src_asns = [15269] | ||
dest_ports = ["80"] | ||
dest_ip_ranges = ["10.100.0.0/16"] | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
output "security_policy" { | ||
value = module.network_edge_security_policy.security_policy | ||
description = "Regional Network Security policy created" | ||
} | ||
|
||
output "policy_rules" { | ||
value = module.network_edge_security_policy.policy_rules | ||
description = "Security policy rules created" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Copyright 2023 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
variable "project_id" { | ||
description = "The project in which the resource belongs" | ||
type = string | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.