Skip to content

Commit 7d9c0b4

Browse files
committed
chore: unify ci workflow
- Use a shared workflow from shared-workflows repo
1 parent 90397c4 commit 7d9c0b4

File tree

6 files changed

+97
-59
lines changed

6 files changed

+97
-59
lines changed

.github/workflows/workflow.yaml

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,9 @@
11
name: Terraform CI
2-
32
on:
43
push:
54
merge_group:
65
types: [checks_requested]
76

8-
97
jobs:
10-
validate:
11-
name: Validate
12-
runs-on: ubuntu-latest
13-
steps:
14-
- name: Check out code
15-
uses: actions/checkout@v2
16-
17-
- uses: hashicorp/setup-terraform@v3
18-
with:
19-
terraform_version: ^1.1
20-
21-
- run: terraform init
22-
23-
- run: terraform validate
24-
25-
- run: terraform fmt -recursive -check
8+
build:
9+
uses: meshcloud/shared-workflows/.github/workflows/terraform-meshplatform-modules-build-workflow.yml@main

README.md

Lines changed: 28 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,22 @@ To run this module, you need the following:
2929

3030
2. Open a cloud shell.
3131

32-
3. Download the example `main.tf` and `outputs.tf` files.
33-
34-
```powershell
35-
# Downloads main.tf and outputs.tf files into ~/terraform-azure-meshplatform
36-
wget https://raw.githubusercontent.com/meshcloud/terraform-azure-meshplatform/main/examples/basic-azure-integration/main.tf -P ~/terraform-azure-meshplatform
37-
wget https://raw.githubusercontent.com/meshcloud/terraform-azure-meshplatform/main/examples/basic-azure-integration/outputs.tf -P ~/terraform-azure-meshplatform
32+
3. Create a terraform file that calls this module and produces outputs. Similar to:
33+
34+
```hcl
35+
module "meshplatform" {
36+
source = "git::https://github.com/meshcloud/terraform-azure-meshplatform.git"
37+
# FILL INPUTS
38+
}
39+
output "meshplatform" {
40+
sensitive = true
41+
value = module.meshplatform
42+
}
3843
```
3944
40-
4. Open `~/terraform-azure-meshplatform/main.tf` with a text editor. Modify the module variables and Terraform state backend settings in the file.
45+
> It is highly recommended to configure a [terraform backend](https://developer.hashicorp.com/terraform/language/settings/backends/configuration), otherwise you risk losing track of your applied resources.
4146
42-
5. Execute the module.
47+
4. Execute the module.
4348
4449
```powershell
4550
# Changes into ~/terraform-azure-meshplatform and applies terraform
@@ -48,7 +53,7 @@ To run this module, you need the following:
4853
terraform apply
4954
```
5055
51-
6. Use the information from terraform output to configure the platform in meshStack.
56+
5. Use the information from terraform output to configure the platform in meshStack.
5257
5358
```sh
5459
# The JSON output contains sensitive values that must not be transmitted anywhere other then the platform config screen in meshStack.
@@ -79,12 +84,12 @@ To run this module, you need the following:
7984
> Until <https://github.com/hashicorp/terraform-provider-azurerm/issues/15211> is resolved, MCA service principal setup can only be done manually outside of terraform.
8085
8186
1. Ensure you have permissions in the source AAD Tenant for granting access to the billing account used for subscription creation using the `Account Administrator` role
82-
1. Switch to the Tenant Directory that contains your Billing Account and follow the steps to [Register an Application](https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app#register-an-application) and [Add Credentials](https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app#add-credentials). Make sure to copy down the **Directory (tenant) ID**, **Application (client) ID**, **Object ID** and the **App Secret** value that was generated. The App Secret is only visible during the creation process.
83-
2. You must grant the Enterprise Application permissions on the Billing Account, Billing Profile, or Invoice Section so that it can generate new subscriptions. Follow the steps in [this guide](https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/understand-mca-roles#manage-billing-roles-in-the-azure-portal) to grant the necessary permissions. You must grant one of the following permissions
87+
2. Switch to the Tenant Directory that contains your Billing Account and follow the steps to [Register an Application](https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app#register-an-application) and [Add Credentials](https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app#add-credentials). Make sure to copy down the **Directory (tenant) ID**, **Application (client) ID**, **Object ID** and the **App Secret** value that was generated. The App Secret is only visible during the creation process.
88+
3. You must grant the Enterprise Application permissions on the Billing Account, Billing Profile, or Invoice Section so that it can generate new subscriptions. Follow the steps in [this guide](https://learn.microsoft.com/en-us/azure/cost-management-billing/manage/understand-mca-roles#manage-billing-roles-in-the-azure-portal) to grant the necessary permissions. You must grant one of the following permissions
8489
- Billing Account or Billing Profile: Owner, Contributor
8590
- Invoice Section: Owner, Contributor, Azure Subscription Creator
86-
3. Write down the Billing Scope ID that looks something like this <samp>/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/AW4F-xxxx-xxx-xxx/invoiceSections/SH3V-xxxx-xxx-xxx</samp>
87-
4. Use the following information to configure the platform in meshStack
91+
4. Write down the Billing Scope ID that looks something like this <samp>/providers/Microsoft.Billing/billingAccounts/5e98e158-xxxx-xxxx-xxxx-xxxxxxxxxxxx:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx_xxxx-xx-xx/billingProfiles/AW4F-xxxx-xxx-xxx/invoiceSections/SH3V-xxxx-xxx-xxx</samp>
92+
5. Use the following information to configure the platform in meshStack
8893
- Billing Scope
8994
- Destination Tenant ID
9095
- Source Tenant ID
@@ -126,6 +131,16 @@ provide the SPN with access to the function.
126131
]
127132
```
128133

134+
## Contributing Guide
135+
136+
Before opening a Pull Request, please do the following:
137+
138+
1. Install [pre-commit](https://pre-commit.com/#install)
139+
140+
We use pre-commit to perform several terraform related tasks such as `terraform validate`, `terraform fmt`, and generating terraform docs with `terraform_docs`
141+
142+
2. Execute `pre-commit install`: Hooks configured in `.pre-commit-config.yaml` will be executed automatically on commit. For manual execution, you can use `pre-commit run -a`.
143+
129144
<!-- BEGIN_TF_DOCS -->
130145
## Requirements
131146

default.nix

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{ pkgs ? import <nixpkgs> { }, system ? builtins.currentSystem }:
2+
3+
let
4+
# fake opentofu as terraform so that tools like terraform-docs pre-commit hook (which doesn't have tofu support)
5+
# fall back to tofu
6+
tofu_terraform =
7+
pkgs.stdenv.mkDerivation {
8+
name = "tofu-terraform";
9+
phases = [ "installPhase" ];
10+
installPhase = ''
11+
mkdir -p $out/bin
12+
echo '#!/usr/bin/env sh' > $out/bin/terraform
13+
echo 'tofu $@' > $out/bin/terraform
14+
chmod +x $out/bin/terraform
15+
'';
16+
};
17+
18+
in
19+
20+
pkgs.mkShell {
21+
NIX_SHELL = "terraform-meshplatform-modules";
22+
shellHook = ''
23+
echo starting terraform-meshplatform-modules shell
24+
'';
25+
26+
buildInputs = [
27+
pkgs.pre-commit
28+
pkgs.opentofu
29+
pkgs.tflint
30+
pkgs.terraform-docs
31+
32+
# fake tofu as terraform
33+
tofu_terraform
34+
];
35+
}

modules/meshcloud-metering-service-principal/README.md

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,17 @@
33

44
| Name | Version |
55
|------|---------|
6-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
7-
| <a name="requirement_azuread"></a> [azuread](#requirement\_azuread) | 2.18.0 |
8-
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | 3.3.0 |
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | > 1.0 |
7+
| <a name="requirement_azuread"></a> [azuread](#requirement\_azuread) | 2.46.0 |
8+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | 3.81.0 |
99

1010
## Providers
1111

1212
| Name | Version |
1313
|------|---------|
14-
| <a name="provider_azuread"></a> [azuread](#provider\_azuread) | 2.18.0 |
15-
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.3.0 |
14+
| <a name="provider_azuread"></a> [azuread](#provider\_azuread) | 2.46.0 |
15+
| <a name="provider_azurerm"></a> [azurerm](#provider\_azurerm) | 3.81.0 |
16+
| <a name="provider_time"></a> [time](#provider\_time) | 0.11.1 |
1617

1718
## Modules
1819

@@ -22,25 +23,26 @@ No modules.
2223

2324
| Name | Type |
2425
|------|------|
25-
| [azuread_application.meshcloud_metering](https://registry.terraform.io/providers/hashicorp/azuread/2.18.0/docs/resources/application) | resource |
26-
| [azuread_service_principal.meshcloud_metering](https://registry.terraform.io/providers/hashicorp/azuread/2.18.0/docs/resources/service_principal) | resource |
27-
| [azuread_application_password.application_pw](https://registry.terraform.io/providers/hashicorp/azuread/2.43.0/docs/resources/application_password) | resource |
28-
| [time_rotating.replicator_secret_rotation](https://registry.terraform.io/providers/hashicorp/time/0.9.1/docs/resources/rotating) | resource |
29-
| [azurerm_role_assignment.meshcloud_metering](https://registry.terraform.io/providers/hashicorp/azurerm/3.3.0/docs/resources/role_assignment) | resource |
30-
| [azurerm_role_assignment.meshcloud_metering_cloud_inventory](https://registry.terraform.io/providers/hashicorp/azurerm/3.3.0/docs/resources/role_assignment) | resource |
31-
| [azurerm_role_definition.meshcloud_metering_cloud_inventory_role](https://registry.terraform.io/providers/hashicorp/azurerm/3.3.0/docs/resources/role_definition) | resource |
26+
| [azuread_application.meshcloud_metering](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/resources/application) | resource |
27+
| [azuread_application_federated_identity_credential.meshcloud_metering](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/resources/application_federated_identity_credential) | resource |
28+
| [azuread_application_password.application_pw](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/resources/application_password) | resource |
29+
| [azuread_service_principal.meshcloud_metering](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/resources/service_principal) | resource |
30+
| [azurerm_role_assignment.meshcloud_metering](https://registry.terraform.io/providers/hashicorp/azurerm/3.81.0/docs/resources/role_assignment) | resource |
31+
| [time_rotating.replicator_secret_rotation](https://registry.terraform.io/providers/hashicorp/time/latest/docs/resources/rotating) | resource |
3232

3333
## Inputs
3434

3535
| Name | Description | Type | Default | Required |
3636
|------|-------------|------|---------|:--------:|
37-
| <a name="input_scope"></a> [scope](#input\_scope) | The scope to which Service Principal permissions should be assigned to. Usually this is the management group id of form `/providers/Microsoft.Management/managementGroups/<tenantId>` that sits atop the subscriptions. | `string` | n/a | yes |
38-
| <a name="input_service_principal_name_suffix"></a> [service\_principal\_name\_suffix](#input\_service\_principal\_name\_suffix) | Service principal name suffix. | `string` | n/a | yes |
37+
| <a name="input_assignment_scopes"></a> [assignment\_scopes](#input\_assignment\_scopes) | The scopes to which Service Principal permissions should be assigned to. Usually this is the management group id of form `/providers/Microsoft.Management/managementGroups/<tenantId>` that sits atop the subscriptions. | `list(string)` | n/a | yes |
38+
| <a name="input_create_password"></a> [create\_password](#input\_create\_password) | Create a password for the enterprise application. | `bool` | n/a | yes |
39+
| <a name="input_service_principal_name"></a> [service\_principal\_name](#input\_service\_principal\_name) | Service principal name. Must be unique per Entra ID. | `string` | n/a | yes |
40+
| <a name="input_workload_identity_federation"></a> [workload\_identity\_federation](#input\_workload\_identity\_federation) | Enable workload identity federation instead of using a password by providing these additional settings. Usually you should receive the required settings when attempting to configure a platform with workload identity federation in meshStack. | `object({ issuer = string, subject = string })` | `null` | no |
3941

4042
## Outputs
4143

4244
| Name | Description |
4345
|------|-------------|
46+
| <a name="output_application_client_secret"></a> [application\_client\_secret](#output\_application\_client\_secret) | Client Secret Of the Application. |
4447
| <a name="output_credentials"></a> [credentials](#output\_credentials) | Service Principal application id and object id |
45-
| <a name="output_application_client_secret"></a> [application\_client\_secret](#output\_application\_client\_secret) | Password for the Service Principal. |
4648
<!-- END_TF_DOCS -->

modules/meshcloud-sso/README.md

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33

44
| Name | Version |
55
|------|---------|
6-
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
7-
| <a name="requirement_azuread"></a> [azuread](#requirement\_azuread) | 2.18.0 |
8-
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | 3.3.0 |
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | > 1.0 |
7+
| <a name="requirement_azuread"></a> [azuread](#requirement\_azuread) | 2.46.0 |
8+
| <a name="requirement_azurerm"></a> [azurerm](#requirement\_azurerm) | 3.81.0 |
99

1010
## Providers
1111

1212
| Name | Version |
1313
|------|---------|
14-
| <a name="provider_azuread"></a> [azuread](#provider\_azuread) | 2.18.0 |
14+
| <a name="provider_azuread"></a> [azuread](#provider\_azuread) | 2.46.0 |
1515

1616
## Modules
1717

@@ -21,22 +21,24 @@ No modules.
2121

2222
| Name | Type |
2323
|------|------|
24-
| [azuread_application.meshcloud_sso](https://registry.terraform.io/providers/hashicorp/azuread/2.18.0/docs/resources/application) | resource |
25-
| [azuread_application_password.meshcloud_sso](https://registry.terraform.io/providers/hashicorp/azuread/2.18.0/docs/resources/application_password) | resource |
26-
| [azuread_application_published_app_ids.well_known](https://registry.terraform.io/providers/hashicorp/azuread/2.18.0/docs/data-sources/application_published_app_ids) | data source |
27-
| [azuread_service_principal.msgraph](https://registry.terraform.io/providers/hashicorp/azuread/2.18.0/docs/data-sources/service_principal) | data source |
24+
| [azuread_app_role_assignment.meshcloud_sso_user_read](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/resources/app_role_assignment) | resource |
25+
| [azuread_application.meshcloud_sso](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/resources/application) | resource |
26+
| [azuread_application_password.meshcloud_sso](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/resources/application_password) | resource |
27+
| [azuread_application_published_app_ids.well_known](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/data-sources/application_published_app_ids) | data source |
28+
| [azuread_application_template.enterprise_app](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/data-sources/application_template) | data source |
29+
| [azuread_service_principal.msgraph](https://registry.terraform.io/providers/hashicorp/azuread/2.46.0/docs/data-sources/service_principal) | data source |
2830

2931
## Inputs
3032

3133
| Name | Description | Type | Default | Required |
3234
|------|-------------|------|---------|:--------:|
33-
| <a name="input_meshstack_redirect_uri"></a> [meshstack\_redirect\_uri](#input\_meshstack\_redirect\_uri) | Redirect URI that will be provided by meshcloud. It is individual per meshStack. | `string` | n/a | yes |
34-
| <a name="input_service_principal_name_suffix"></a> [service\_principal\_name\_suffix](#input\_service\_principal\_name\_suffix) | Service principal name suffix. | `string` | n/a | yes |
35+
| <a name="input_meshstack_redirect_uri"></a> [meshstack\_redirect\_uri](#input\_meshstack\_redirect\_uri) | Redirect URI that was provided by meshcloud. It is individual per meshStack. | `string` | n/a | yes |
36+
| <a name="input_service_principal_name"></a> [service\_principal\_name](#input\_service\_principal\_name) | Service principal name. | `string` | n/a | yes |
3537

3638
## Outputs
3739

3840
| Name | Description |
3941
|------|-------------|
40-
| <a name="output_app_registration"></a> [app\_registration](#output\_app\_registration) | Application registration application id and object id |
41-
| <a name="output_app_registration_client_secret"></a> [app\_registration\_client\_secret](#output\_app\_registration\_client\_secret) | Password for the application registration. |
42+
| <a name="output_application_client_secret"></a> [application\_client\_secret](#output\_application\_client\_secret) | Password for the application registration. |
43+
| <a name="output_credentials"></a> [credentials](#output\_credentials) | Service Principal application id and object id |
4244
<!-- END_TF_DOCS -->

modules/meshcloud-sso/module.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ terraform {
1313
}
1414
//---------------------------------------------------------------------------
1515
// Queries Entra ID for information about well-known application IDs.
16-
// Retrieve details about the service principal
16+
// Retrieve details about the service principal
1717
//---------------------------------------------------------------------------
1818

1919
data "azuread_application_published_app_ids" "well_known" {}

0 commit comments

Comments
 (0)