Skip to content

Commit 7aff11e

Browse files
authored
Merge pull request #2 from github/tf-check
ci: add basic validations/formatting check
2 parents 7d91f1d + b60da8b commit 7aff11e

11 files changed

Lines changed: 192 additions & 155 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Terraform Checks
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
push:
7+
paths:
8+
- '**.tf'
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
validate-and-format:
15+
name: Validate and Format Terraform Files
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
id: checkout
21+
uses: actions/checkout@v4
22+
23+
- name: Setup Terraform
24+
id: terraform
25+
uses: hashicorp/[email protected]
26+
27+
- name: Initialize Terraform
28+
id: init
29+
run: terraform init -backend=false
30+
31+
- name: Validate Terraform
32+
id: validate
33+
run: terraform validate
34+
35+
- name: Format Terraform
36+
id: format
37+
run: terraform fmt -check -recursive

examples/example-firewall/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Create a VNET using an Azure Firewall to control the VNET network access
22
module "vnet" {
3-
source = "github.com/garnertb/github-runner-vnet//modules/firewall"
3+
source = "github.com/garnertb/github-runner-vnet//modules/firewall"
44

5-
base_name = var.base_name
6-
github_business_id = var.github_business_id
5+
base_name = var.base_name
6+
github_business_id = var.github_business_id
77
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
output "gh_network_settings_resource_id" {
2-
description = "ID of the GitHub.Network/networkSettings resource"
3-
value = module.vnet.network_settings_id
2+
description = "ID of the GitHub.Network/networkSettings resource"
3+
value = module.vnet.network_settings_id
44
}

examples/example-nsg/main.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Create a VNET using an Azure Network Security Group to control the VNET network access
22
module "vnet" {
3-
source = "github.com/garnertb/github-runner-vnet//modules/nsg"
3+
source = "github.com/garnertb/github-runner-vnet//modules/nsg"
44

5-
base_name = var.base_name
6-
github_business_id = var.github_business_id
5+
base_name = var.base_name
6+
github_business_id = var.github_business_id
77
}

examples/example-nsg/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
output "gh_network_settings_resource_id" {
2-
description = "ID of the GitHub.Network/networkSettings resource"
3-
value = module.vnet.network_settings_id
2+
description = "ID of the GitHub.Network/networkSettings resource"
3+
value = module.vnet.network_settings_id
44
}

main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# Create a VNET using an Azure Network Security Group to control the VNET network access
22
module "vnet" {
3-
source = "./modules/nsg"
3+
source = "./modules/nsg"
44

5-
base_name = var.base_name
6-
github_business_id = var.github_business_id
7-
location = var.location
8-
vnet_address_space = var.vnet_address_space
9-
runner_subnet_address_prefixes = var.runner_subnet_address_prefixes
5+
base_name = var.base_name
6+
github_business_id = var.github_business_id
7+
location = var.location
8+
vnet_address_space = var.vnet_address_space
9+
runner_subnet_address_prefixes = var.runner_subnet_address_prefixes
1010
}

modules/firewall/main.tf

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ resource "azurerm_virtual_network" "vnet" {
4444
}
4545

4646
resource "azurerm_subnet" "firewall_subnet" {
47-
address_prefixes = var.firewall_subnet_address_prefixes
47+
address_prefixes = var.firewall_subnet_address_prefixes
4848
# The subnet name has to be exactly this, in order for the subnet to be used for a firewall
4949
name = "AzureFirewallSubnet"
5050
resource_group_name = azurerm_resource_group.resource_group.name
@@ -55,7 +55,7 @@ resource "azurerm_subnet" "firewall_subnet" {
5555
}
5656

5757
resource "azurerm_subnet" "management_subnet" {
58-
address_prefixes = var.firewall_management_subnet_address_prefixes
58+
address_prefixes = var.firewall_management_subnet_address_prefixes
5959
# The subnet name has to be exactly this in order for the subnet to be used for the firewall management
6060
name = "AzureFirewallManagementSubnet"
6161
resource_group_name = azurerm_resource_group.resource_group.name
@@ -132,11 +132,11 @@ resource "azurerm_firewall_policy_rule_collection_group" "firewall_policy_rule_c
132132
}
133133

134134
application_rule_collection {
135-
action = "Allow"
136-
name = "AllowApplicationRules"
135+
action = "Allow"
136+
name = "AllowApplicationRules"
137137
priority = 1000
138138
rule {
139-
name = "GitHub"
139+
name = "GitHub"
140140
source_addresses = ["*"]
141141
destination_fqdns = [
142142
# These FQDNs have been taken from the GitHub documentation for self-hosted runner networking
@@ -180,7 +180,7 @@ resource "azurerm_firewall" "firewall" {
180180
location = var.location
181181
name = "${var.base_name}-firewall"
182182
resource_group_name = azurerm_resource_group.resource_group.name
183-
firewall_policy_id = azurerm_firewall_policy.firewall_policy.id
183+
firewall_policy_id = azurerm_firewall_policy.firewall_policy.id
184184
sku_name = "AZFW_VNet"
185185
sku_tier = "Standard"
186186
ip_configuration {

modules/firewall/outputs.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
output "network_settings_id" {
2-
description = "ID of the GitHub.Network/networkSettings resource"
3-
value = jsondecode(azapi_resource.github_network_settings.output).tags.GitHubId
2+
description = "ID of the GitHub.Network/networkSettings resource"
3+
value = jsondecode(azapi_resource.github_network_settings.output).tags.GitHubId
44
}

0 commit comments

Comments
 (0)