Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Net vpc firewall factory schema #2497

Merged
merged 2 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-default-deny:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# skip boilerplate check
---
# Terraform will be unable to decode this file if it does not contain valid YAML
# You can retain `---` (start of the document) to indicate an empty document.
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-allow-composer-nodes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-default-landing-deny:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# skip boilerplate check
---
# Terraform will be unable to decode this file if it does not contain valid YAML
# You can retain `---` (start of the document) to indicate an empty document.
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
allow-onprem-probes-landing-example:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-default-deny:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-default-deny:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# skip boilerplate check
---
# Terraform will be unable to decode this file if it does not contain valid YAML
# You can retain `---` (start of the document) to indicate an empty document.
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-allow-composer-nodes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

# This is only relevant when using NCC-RA, and can be safely removed otherwise
ingress:
allow-ncc-nva-bgp-dmz:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
dmz-ingress-default-deny:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# skip boilerplate check
---
# Terraform will be unable to decode this file if it does not contain valid YAML
# You can retain `---` (start of the document) to indicate an empty document.
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
allow-hc-nva-ssh-dmz:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

# This is only relevant when using NCC-RA, and can be safely removed otherwise
ingress:
allow-ncc-nva-bgp-landing:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-default-landing-deny:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# skip boilerplate check
---
# Terraform will be unable to decode this file if it does not contain valid YAML
# You can retain `---` (start of the document) to indicate an empty document.
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
allow-hc-nva-ssh-landing:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-default-deny:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-default-deny:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# skip boilerplate check
---
# Terraform will be unable to decode this file if it does not contain valid YAML
# You can retain `---` (start of the document) to indicate an empty document.
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-allow-composer-nodes:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# skip boilerplate check
---
# start of document (---) avoids errors if the file only contains comments

# yaml-language-server: $schema=../../../schemas/firewall-rules.schema.json

ingress:
ingress-default-deny:
Expand Down
16 changes: 4 additions & 12 deletions modules/net-vpc-firewall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -198,12 +198,6 @@ module "firewall" {
```

```yaml
# tftest-file id=lbs path=configs/firewall/rules/load_balancers.yaml

---
# Terraform will be unable to decode this file if it does not contain valid YAML
# You can retain `---` (start of the document) to indicate an empty document.

ingress:
allow-healthchecks:
description: Allow ingress from healthchecks.
Expand Down Expand Up @@ -234,20 +228,18 @@ egress:
- protocol: tcp
ports:
- 23

# tftest-file id=lbs path=configs/firewall/rules/load_balancers.yaml
```

```yaml
# tftest-file id=cidrs path=configs/firewall/cidrs.yaml

---
# Terraform will be unable to decode this file if it does not contain valid YAML
# You can retain `---` (start of the document) to indicate an empty document.

healthchecks:
- 35.191.0.0/16
- 130.211.0.0/22
- 209.85.152.0/22
- 209.85.204.0/22

# tftest-file id=cidrs path=configs/firewall/cidrs.yaml
```

Instead of using `factories_config.cidr_tpl_file` file, you can pass CIDR blocks directly in the `named_ranges` variable. This approach could be useful for dynamically generated CIDR blocks from outputs of other resources.
Expand Down
91 changes: 91 additions & 0 deletions modules/net-vpc-firewall/schemas/firewall-rules.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"title": "Firewall Rules",
"type": "object",
"additionalProperties": false,
"properties": {
"ingress": {
"type": "object",
"additionalProperties": false,
"patternProperties": {
"^[a-z0-9_-]+$": {
"$ref": "#/$defs/rule"
}
}
}
},
"$defs": {
"rule": {
"type": "object",
"additionalProperties": false,
"properties": {
"deny": {
"type": "boolean"
},
"description": {
"type": "string"
},
"destination_ranges": {
"type": "array",
"items": {
"type": "string"
}
},
"disabled": {
"type": "boolean"
},
"enable_logging": {
"type": "object",
"additionalProperties": false,
"properties": {
"include_metadata": {
"type": "boolean"
}
}
},
"priority": {
"type": "number"
},
"source_ranges": {
"type": "array",
"items": {
"type": "string"
}
},
"sources": {
"type": "array",
"items": {
"type": "string"
}
},
"targets": {
"type": "array",
"items": {
"type": "string"
}
},
"use_service_accounts": {
"type": "boolean"
},
"rules": {
"type": "array",
"items": {
"type": "object",
"additionalProperties": false,
"properties": {
"protocol": {
"type": "string"
},
"ports": {
"type": "array",
"items": {
"type": "number"
}
}
}
}
}
}
}
}
}