-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CES-598] Added GitHub Runner in azure_core_infra module (#189)
- Loading branch information
Showing
33 changed files
with
512 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"azure_core_infra": patch | ||
--- | ||
|
||
Added GitHub Runner and Log Analytics configuration |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,39 @@ | ||
# dev | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | <= 3.117.0 | | ||
|
||
## Providers | ||
|
||
| Name | Version | | ||
|------|---------| | ||
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.117.0 | | ||
|
||
## Modules | ||
|
||
| Name | Source | Version | | ||
|------|--------|---------| | ||
| <a name="module_container_app_job_selfhosted_runner"></a> [container\_app\_job\_selfhosted\_runner](#module\_container\_app\_job\_selfhosted\_runner) | ../../modules/github_selfhosted_runner_on_container_app_jobs | n/a | | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [azurerm_container_app_environment.gh_runner](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/container_app_environment) | data source | | ||
| [azurerm_key_vault.key_vault](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/key_vault) | data source | | ||
| [azurerm_resource_group.gh_runner](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/data-sources/resource_group) | data source | | ||
|
||
## Inputs | ||
|
||
No inputs. | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_container_app_job"></a> [container\_app\_job](#output\_container\_app\_job) | n/a | | ||
<!-- END_TF_DOCS --> |
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,13 @@ | ||
data "azurerm_resource_group" "gh_runner" { | ||
name = "${local.prefix}-${local.env_short}-${local.location_short}-github-runner-rg-${local.suffix}" | ||
} | ||
|
||
data "azurerm_container_app_environment" "gh_runner" { | ||
name = "${local.prefix}-${local.env_short}-${local.location_short}-github-runner-cae-${local.suffix}" | ||
resource_group_name = data.azurerm_resource_group.gh_runner.name | ||
} | ||
|
||
data "azurerm_key_vault" "key_vault" { | ||
name = "${local.prefix}-${local.env_short}-${local.location_short}-common-kv-${local.suffix}" | ||
resource_group_name = "${local.prefix}-${local.env_short}-${local.location_short}-common-rg-${local.suffix}" | ||
} |
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,16 @@ | ||
locals { | ||
prefix = "dx" | ||
suffix = "01" | ||
env_short = "d" | ||
location = "italynorth" | ||
location_short = "itn" | ||
repo_name = "dx" | ||
|
||
tags = { | ||
CostCenter = "TS700 - ENGINEERING" | ||
CreatedBy = "Terraform" | ||
Environment = "Dev" | ||
Owner = "DevEx" | ||
Source = "https://github.com/pagopa/dx/blob/main/infra/resources/dev" | ||
} | ||
} |
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,50 @@ | ||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "<= 3.117.0" | ||
} | ||
} | ||
|
||
backend "azurerm" { | ||
resource_group_name = "terraform-state-rg" | ||
storage_account_name = "tfdevdx" | ||
container_name = "terraform-state" | ||
key = "dx.github-runner.dev.tfstate" | ||
} | ||
} | ||
|
||
provider "azurerm" { | ||
features { | ||
} | ||
} | ||
|
||
module "container_app_job_selfhosted_runner" { | ||
source = "../../modules/github_selfhosted_runner_on_container_app_jobs" | ||
|
||
environment = { | ||
prefix = local.prefix | ||
env_short = local.env_short | ||
location = local.location | ||
instance_number = local.suffix | ||
} | ||
|
||
resource_group_name = data.azurerm_resource_group.gh_runner.name | ||
|
||
repository = { | ||
name = local.repo_name | ||
} | ||
|
||
container_app_environment = { | ||
id = data.azurerm_container_app_environment.gh_runner.id | ||
location = local.location | ||
} | ||
|
||
key_vault = { | ||
name = data.azurerm_key_vault.key_vault.name | ||
resource_group_name = data.azurerm_key_vault.key_vault.resource_group_name | ||
use_rbac = true | ||
} | ||
|
||
tags = local.tags | ||
} |
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,7 @@ | ||
output "container_app_job" { | ||
value = { | ||
id = module.container_app_job_selfhosted_runner.container_app_job.id | ||
name = module.container_app_job_selfhosted_runner.container_app_job.name | ||
resource_group_name = module.container_app_job_selfhosted_runner.container_app_job.resource_group_name | ||
} | ||
} |
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
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
41 changes: 41 additions & 0 deletions
41
infra/modules/azure_core_infra/_modules/github_runner/README.md
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,41 @@ | ||
# github_runner | ||
|
||
<!-- BEGIN_TF_DOCS --> | ||
## Requirements | ||
|
||
No requirements. | ||
|
||
## Modules | ||
|
||
No modules. | ||
|
||
## Resources | ||
|
||
| Name | Type | | ||
|------|------| | ||
| [azurerm_container_app_environment.cae](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_app_environment) | resource | | ||
| [azurerm_management_lock.lock_cae](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/management_lock) | resource | | ||
| [azurerm_subnet.runner_snet](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/subnet) | resource | | ||
|
||
## Inputs | ||
|
||
| Name | Description | Type | Default | Required | | ||
|------|-------------|------|---------|:--------:| | ||
| <a name="input_location"></a> [location](#input\_location) | Location | `string` | n/a | yes | | ||
| <a name="input_log_analytics_workspace_id"></a> [log\_analytics\_workspace\_id](#input\_log\_analytics\_workspace\_id) | n/a | `string` | n/a | yes | | ||
| <a name="input_prefix"></a> [prefix](#input\_prefix) | Prefix for resource names | `string` | n/a | yes | | ||
| <a name="input_resource_group_name"></a> [resource\_group\_name](#input\_resource\_group\_name) | Resource group name | `string` | n/a | yes | | ||
| <a name="input_subnet_cidr"></a> [subnet\_cidr](#input\_subnet\_cidr) | n/a | `string` | `"10.0.242.0/23"` | no | | ||
| <a name="input_suffix"></a> [suffix](#input\_suffix) | Suffix for resource names | `string` | `"01"` | no | | ||
| <a name="input_tags"></a> [tags](#input\_tags) | Resources tags | `map(any)` | n/a | yes | | ||
| <a name="input_virtual_network"></a> [virtual\_network](#input\_virtual\_network) | Virtual network where to attach private dns zones | <pre>object({<br/> id = string<br/> name = string<br/> resource_group_name = string<br/> })</pre> | n/a | yes | | ||
|
||
## Outputs | ||
|
||
| Name | Description | | ||
|------|-------------| | ||
| <a name="output_cae_id"></a> [cae\_id](#output\_cae\_id) | Container App Environment id | | ||
| <a name="output_cae_name"></a> [cae\_name](#output\_cae\_name) | Container App Environment name | | ||
| <a name="output_subnet_id"></a> [subnet\_id](#output\_subnet\_id) | Subnet id | | ||
| <a name="output_subnet_name"></a> [subnet\_name](#output\_subnet\_name) | Subnet name | | ||
<!-- END_TF_DOCS --> |
20 changes: 20 additions & 0 deletions
20
infra/modules/azure_core_infra/_modules/github_runner/container_app_environment.tf
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 @@ | ||
resource "azurerm_container_app_environment" "cae" { | ||
name = "${var.prefix}-cae-${var.suffix}" | ||
location = var.location | ||
resource_group_name = var.resource_group_name | ||
|
||
log_analytics_workspace_id = var.log_analytics_workspace_id | ||
|
||
infrastructure_subnet_id = azurerm_subnet.runner_snet.id | ||
zone_redundancy_enabled = false | ||
internal_load_balancer_enabled = false | ||
|
||
tags = var.tags | ||
} | ||
|
||
resource "azurerm_management_lock" "lock_cae" { | ||
lock_level = "CanNotDelete" | ||
name = "${var.prefix}-cae-${var.suffix}" | ||
notes = "This Container App Environment cannot be deleted" | ||
scope = azurerm_container_app_environment.cae.id | ||
} |
19 changes: 19 additions & 0 deletions
19
infra/modules/azure_core_infra/_modules/github_runner/outputs.tf
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,19 @@ | ||
output "subnet_name" { | ||
value = azurerm_subnet.runner_snet.name | ||
description = "Subnet name" | ||
} | ||
|
||
output "subnet_id" { | ||
value = azurerm_subnet.runner_snet.id | ||
description = "Subnet id" | ||
} | ||
|
||
output "cae_id" { | ||
value = azurerm_container_app_environment.cae.id | ||
description = "Container App Environment id" | ||
} | ||
|
||
output "cae_name" { | ||
value = azurerm_container_app_environment.cae.name | ||
description = "Container App Environment name" | ||
} |
6 changes: 6 additions & 0 deletions
6
infra/modules/azure_core_infra/_modules/github_runner/subnet.tf
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,6 @@ | ||
resource "azurerm_subnet" "runner_snet" { | ||
name = "${var.prefix}-snet-${var.suffix}" | ||
virtual_network_name = var.virtual_network.name | ||
resource_group_name = var.virtual_network.resource_group_name | ||
address_prefixes = [var.subnet_cidr] | ||
} |
Oops, something went wrong.