Skip to content

Commit c9faec9

Browse files
committed
feat: restructure module GitHub Actions Terraform Setup
feat: restructure module GitHub Actions Terraform Setup feat: restructure module GitHub Actions Terraform Setup feat: restructure module GitHub Actions Terraform Setup feat: restructure module GitHub Actions Terraform Setup feat: restructure module GitHub Actions Terraform Setup feat: restructure module GitHub Actions Terraform Setup feat: restructure module GitHub Actions Terraform Setup
1 parent 84cb228 commit c9faec9

File tree

7 files changed

+78
-56
lines changed

7 files changed

+78
-56
lines changed

modules/azure/github-actions-terraform-setup/backplane/documentation.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ on the cloud quickly.
1818
The easiest way to get started with a Starter Kit is to search for "Starter Kit" in the Likvid Bank Cloud Portal
1919
Marketplace and let the portal help you add it to a Sandbox Subscription (or create a new one if you don't have one yet).
2020
21-
Starter Kits will create a (private) GitHub repository for you in our [GitHub Organization](https://github.com/${var.github_org}).
21+
Starter Kits will create a (private) GitHub repository for you in our [GitHub Organization](https://github.com/your_github_org).
2222
You will find the URL for your repository in the Starter Kit building block output tab. Please review the `README.md`
2323
of that repository for further instructions and inspiration for working with the starter kit.
2424
Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,44 +1,25 @@
1-
output "config_tf" {
1+
output "provider_config" {
22
description = "Generates a config.tf that can be dropped into meshStack's BuildingBlockDefinition as an encrypted file input to configure this building block."
33
sensitive = true
44
value = <<EOF
5-
provider "github" {
6-
owner = "${var.github_org}"
75
8-
app_auth {
9-
id = "${var.github_app_id}"
10-
installation_id = "${var.github_app_installation_id}"
6+
use following Environment variables to configure your Terraform AZURERM Provider:
117
12-
# TODO: ensure the pem file exists on disk in the BB execution environment (with meshStack: secret file input)
13-
pem_file = file("./github-app.private-key.pem")
14-
}
8+
ARM_TENANT_ID = "${data.azurerm_subscription.current.tenant_id}"
9+
ARM_SUBSCRIPTION_ID = "USE THE PLATFORM TENANT ID"
10+
ARM_CLIENT_ID = "${azuread_service_principal.starterkit.client_id}"
11+
ARM_CLIENT_SECRET = "${azuread_service_principal_password.starterkit.value}"
1512
}
1613
17-
provider "azurerm" {
18-
features {
19-
resource_group {
20-
prevent_deletion_if_contains_resources = false # This allows the deletion of the building block without having to separately delete the app resources
21-
}
22-
}
14+
use following Environment variables to configure your Terraform AZUREAD Provider:
2315
24-
resource_provider_registrations = "core"
25-
26-
storage_use_azuread = true
27-
28-
tenant_id = "${data.azurerm_subscription.current.tenant_id}"
29-
subscription_id = var.subscription_id
30-
client_id = "${azuread_service_principal.starterkit.client_id}"
31-
client_secret = "${azuread_service_principal_password.starterkit.value}"
16+
ARM_TENANT_ID = "${data.azurerm_subscription.current.tenant_id}"
17+
ARM_CLIENT_ID = "${azuread_service_principal.starterkit.client_id}"
18+
ARM_CLIENT_SECRET = "${azuread_service_principal_password.starterkit.value}"
3219
}
33-
34-
locals {
35-
deploy_role_definition_id = "${azurerm_role_definition.starterkit_deploy.role_definition_id}"
20+
EOF
3621
}
3722

38-
provider "azuread" {
39-
tenant_id = "${data.azurerm_subscription.current.tenant_id}"
40-
client_id = "${azuread_service_principal.starterkit.client_id}"
41-
client_secret = "${azuread_service_principal_password.starterkit.value}"
42-
}
43-
EOF
23+
output "deploy_role_definition_id" {
24+
value = azurerm_role_definition.starterkit_deploy.role_definition_id
4425
}

modules/azure/github-actions-terraform-setup/backplane/variables.tf

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,3 @@ variable "scope" {
1414
nullable = false
1515
description = "Scope where the building block should be deployable, typically a Sandbox Landing Zone Management Group"
1616
}
17-
18-
# unfortunately we can't set up the app via terraform right now, so we need to manually set this up
19-
# outside of terraform an inject result as vars
20-
21-
variable "github_app_id" {
22-
type = number
23-
description = "id of your GitHub App"
24-
}
25-
26-
variable "github_app_installation_id" {
27-
type = number
28-
description = "id of your GitHub App installation as it appears in URLs on GitHub.com"
29-
}
30-
31-
variable "github_org" {
32-
type = string
33-
description = "id of your GitHub organization as it appears in URLs on GitHub.com"
34-
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
---
2+
name: Azure GitHub Actions Terraform Setup
3+
supportedPlatforms:
4+
- azure
5+
description: |
6+
Deploy directly to Azure using GitHub Actions and Terraform brought to you by meshStack
7+
---
8+
9+
# Azure Key Vault
10+
11+
This Terraform module provisions an Azure Key Vault along with necessary role assignments.
12+
13+
14+
## Requirements
15+
- Terraform `>= 1.0`
16+
- AzureRM Provider `>= 4.18.0`
17+
18+
## Providers
19+
20+
```hcl
21+
terraform {
22+
required_providers {
23+
azurerm = {
24+
source = "hashicorp/azurerm"
25+
version = "4.18.0"
26+
}
27+
}
28+
}
29+
30+
provider "azurerm" {
31+
features {}
32+
}
33+
```
34+
35+
<!-- BEGIN_TF_DOCS -->
36+
37+
<!-- END_TF_DOCS -->

modules/azure/github-actions-terraform-setup/buildingblock/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ data "azuread_client_config" "current" {}
66
resource "azurerm_role_assignment" "starterkit_deploy" {
77
# since the role is defined on MG level, we need to prefix the subscription id here to make terraform happy and not plan replacements
88
# see https://github.com/hashicorp/terraform-provider-azurerm/issues/19847#issuecomment-1407262429
9-
role_definition_id = "${data.azurerm_subscription.current.id}/providers/Microsoft.Authorization/roleDefinitions/${local.deploy_role_definition_id}"
9+
role_definition_id = "${data.azurerm_subscription.current.id}/providers/Microsoft.Authorization/roleDefinitions/${var.deploy_role_definition_id}"
1010

1111
description = "Grant permissions to deploy a starterkit building block."
1212
principal_id = data.azuread_client_config.current.object_id
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
provider "github" {
2+
app_auth {}
3+
# using `GITHUB_APP_XXX` environment variables
4+
}
5+
6+
provider "azurerm" {
7+
features {
8+
resource_group {
9+
prevent_deletion_if_contains_resources = false # This allows the deletion of the building block without having to separately delete the app resources
10+
}
11+
}
12+
13+
resource_provider_registrations = "core"
14+
15+
storage_use_azuread = true
16+
}
17+
18+
provider "azuread" {}

modules/azure/github-actions-terraform-setup/buildingblock/variables.tf

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,17 @@ variable "project_identifier" {
1313

1414
# this variable is supposed to be used by an injected config.tf file for configuring the azurerm provider
1515
# tflint-ignore: terraform_unused_declarations
16-
variable "subscription_id" {
17-
type = string
18-
description = "The subscription id to which this building will be deployed."
19-
}
16+
# variable "subscription_id" {
17+
# type = string
18+
# description = "The subscription id to which this building will be deployed."
19+
# }
2020

2121
variable "location" {
2222
type = string
2323
default = "westeurope"
2424
}
2525

26+
variable "deploy_role_definition_id" {
27+
type = string
28+
description = "Role definition ID to assign to the GitHub Actions App Service Managed Identity. This is used to deploy resources via Terraform."
29+
}

0 commit comments

Comments
 (0)