|
|
|
|
@@ -253,19 +253,76 @@ issue-1995:
|
|
|
|
|
- 1-65535
|
|
|
|
|
- protocol: icmp
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
You might need to reference external security profile groups in your firewall rules, using their Terraform ids. For example, `//networksecurity.googleapis.com/${google_network_security_security_profile_group.security_profile_group.id}`. To do so, list your security profile groups in the `security_profile_group_ids` map variable. Then reference them by key from your factories.
|
|
|
|
|
|
|
|
|
|
```hcl
|
|
|
|
|
module "vpc" {
|
|
|
|
|
source = "./fabric/modules/net-vpc"
|
|
|
|
|
project_id = "my-project"
|
|
|
|
|
name = "my-network"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "google_network_security_security_profile" "security_profile" {
|
|
|
|
|
name = "security-profile"
|
|
|
|
|
type = "THREAT_PREVENTION"
|
|
|
|
|
parent = "organizations/0123456789"
|
|
|
|
|
location = "global"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resource "google_network_security_security_profile_group" "security_profile_group" {
|
|
|
|
|
name = "security-profile-group"
|
|
|
|
|
parent = "organizations/0123456789"
|
|
|
|
|
location = "global"
|
|
|
|
|
description = "Sample security profile group."
|
|
|
|
|
threat_prevention_profile = google_network_security_security_profile.security_profile.id
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
module "firewall-policy" {
|
|
|
|
|
source = "./fabric/modules/net-firewall-policy"
|
|
|
|
|
name = "fw-policy"
|
|
|
|
|
parent_id = "my-project"
|
|
|
|
|
security_profile_group_ids = {
|
|
|
|
|
http-sg = "//networksecurity.googleapis.com/${google_network_security_security_profile_group.security_profile_group.id}"
|
|
|
|
|
}
|
|
|
|
|
attachments = {
|
|
|
|
|
my-vpc = module.vpc.self_link
|
|
|
|
|
}
|
|
|
|
|
factories_config = {
|
|
|
|
|
ingress_rules_file_path = "configs/ingress-spg.yaml"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
# tftest modules=2 resources=8 files=ingress-spg inventory=factory-spg.yaml
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
# tftest-file id=ingress-spg path=configs/ingress-spg.yaml
|
|
|
|
|
http:
|
|
|
|
|
priority: 1000
|
|
|
|
|
action: apply_security_profile_group
|
|
|
|
|
security_profile_group: http-sg
|
|
|
|
|
match:
|
|
|
|
|
source_ranges:
|
|
|
|
|
- 10.0.0.0/8
|
|
|
|
|
layer4_configs:
|
|
|
|
|
- protocol: tcp
|
|
|
|
|
ports:
|
|
|
|
|
- 80
|
|
|
|
|
```
|
|
|
|
|
<!-- BEGIN TFDOC -->
|
|
|
|
|
## Variables
|
|
|
|
|
|
|
|
|
|
| name | description | type | required | default |
|
|
|
|
|
|---|---|:---:|:---:|:---:|
|
|
|
|
|
| [name](variables.tf#L115) | Policy name. | <code>string</code> | ✓ | |
|
|
|
|
|
| [parent_id](variables.tf#L121) | Parent node where the policy will be created, `folders/nnn` or `organizations/nnn` for hierarchical policy, project id for a network policy. | <code>string</code> | ✓ | |
|
|
|
|
|
| [name](variables.tf#L117) | Policy name. | <code>string</code> | ✓ | |
|
|
|
|
|
| [parent_id](variables.tf#L123) | Parent node where the policy will be created, `folders/nnn` or `organizations/nnn` for hierarchical policy, project id for a network policy. | <code>string</code> | ✓ | |
|
|
|
|
|
| [attachments](variables.tf#L17) | Ids of the resources to which this policy will be attached, in descriptive name => self link format. Specify folders or organization for hierarchical policy, VPCs for network policy. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
| [description](variables.tf#L24) | Policy description. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [egress_rules](variables.tf#L30) | List of egress rule definitions, action can be 'allow', 'deny', 'goto_next' or 'apply_security_profile_group'. The match.layer4configs map is in protocol => optional [ports] format. | <code title="map(object({ priority = number action = optional(string, "deny") description = optional(string) disabled = optional(bool, false) enable_logging = optional(bool) security_profile_group = optional(string) target_resources = optional(list(string)) target_service_accounts = optional(list(string)) target_tags = optional(list(string)) match = object({ address_groups = optional(list(string)) fqdns = optional(list(string)) region_codes = optional(list(string)) threat_intelligences = optional(list(string)) destination_ranges = optional(list(string)) source_ranges = optional(list(string)) source_tags = optional(list(string)) layer4_configs = optional(list(object({ protocol = optional(string, "all") ports = optional(list(string)) })), [{}]) }) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [factories_config](variables.tf#L67) | Paths to folders for the optional factories. | <code title="object({ cidr_file_path = optional(string) egress_rules_file_path = optional(string) ingress_rules_file_path = optional(string) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
| [ingress_rules](variables.tf#L78) | List of ingress rule definitions, action can be 'allow', 'deny', 'goto_next' or 'apply_security_profile_group'. | <code title="map(object({ priority = number action = optional(string, "allow") description = optional(string) disabled = optional(bool, false) enable_logging = optional(bool) security_profile_group = optional(string) target_resources = optional(list(string)) target_service_accounts = optional(list(string)) target_tags = optional(list(string)) match = object({ address_groups = optional(list(string)) fqdns = optional(list(string)) region_codes = optional(list(string)) threat_intelligences = optional(list(string)) destination_ranges = optional(list(string)) source_ranges = optional(list(string)) source_tags = optional(list(string)) layer4_configs = optional(list(object({ protocol = optional(string, "all") ports = optional(list(string)) })), [{}]) }) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [region](variables.tf#L127) | Policy region. Leave null for hierarchical policy, set to 'global' for a global network policy. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [egress_rules](variables.tf#L30) | List of egress rule definitions, action can be 'allow', 'deny', 'goto_next' or 'apply_security_profile_group'. The match.layer4configs map is in protocol => optional [ports] format. | <code title="map(object({ priority = number action = optional(string, "deny") description = optional(string) disabled = optional(bool, false) enable_logging = optional(bool) security_profile_group = optional(string) target_resources = optional(list(string)) target_service_accounts = optional(list(string)) target_tags = optional(list(string)) tls_inspect = optional(bool, null) match = object({ address_groups = optional(list(string)) fqdns = optional(list(string)) region_codes = optional(list(string)) threat_intelligences = optional(list(string)) destination_ranges = optional(list(string)) source_ranges = optional(list(string)) source_tags = optional(list(string)) layer4_configs = optional(list(object({ protocol = optional(string, "all") ports = optional(list(string)) })), [{}]) }) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [factories_config](variables.tf#L68) | Paths to folders for the optional factories. | <code title="object({ cidr_file_path = optional(string) egress_rules_file_path = optional(string) ingress_rules_file_path = optional(string) })">object({…})</code> | | <code>{}</code> |
|
|
|
|
|
| [ingress_rules](variables.tf#L79) | List of ingress rule definitions, action can be 'allow', 'deny', 'goto_next' or 'apply_security_profile_group'. | <code title="map(object({ priority = number action = optional(string, "allow") description = optional(string) disabled = optional(bool, false) enable_logging = optional(bool) security_profile_group = optional(string) target_resources = optional(list(string)) target_service_accounts = optional(list(string)) target_tags = optional(list(string)) tls_inspect = optional(bool, null) match = object({ address_groups = optional(list(string)) fqdns = optional(list(string)) region_codes = optional(list(string)) threat_intelligences = optional(list(string)) destination_ranges = optional(list(string)) source_ranges = optional(list(string)) source_tags = optional(list(string)) layer4_configs = optional(list(object({ protocol = optional(string, "all") ports = optional(list(string)) })), [{}]) }) }))">map(object({…}))</code> | | <code>{}</code> |
|
|
|
|
|
| [region](variables.tf#L129) | Policy region. Leave null for hierarchical policy, set to 'global' for a global network policy. | <code>string</code> | | <code>null</code> |
|
|
|
|
|
| [security_profile_group_ids](variables.tf#L135) | The optional security groups ids to be referenced in factories. | <code>map(string)</code> | | <code>{}</code> |
|
|
|
|
|
|
|
|
|
|
## Outputs
|
|
|
|
|
|
|
|
|
|
|