Skip to content

Commit 8bd4ab5

Browse files
committed
chore: unify ci workflow
- Use a shared workflow from shared-workflows repo - Create a symbolic link to a default.nix file from shared-workflows repo (using git submodules) `git submodule add https://github.com/meshcloud/shared-workflows.git ./shared-workflows` `ln -s ./shared-workflows/terraform-meshplatform-modules/default.nix default.nix`
1 parent eff262c commit 8bd4ab5

File tree

11 files changed

+44
-161
lines changed

11 files changed

+44
-161
lines changed

.github/workflows/workflow.yaml

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,5 @@ on:
66
types: [checks_requested]
77

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

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "shared-workflows"]
2+
path = shared-workflows
3+
url = https://github.com/meshcloud/shared-workflows.git

README.md

Lines changed: 33 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GCP meshPlatform Module
22

3-
Terraform module to integrate GCP as a meshPlatform into meshStack instance. With this module, service accounts used by meshStack are created with the required permissions. The output of this module is a set of credentials that need to be configured in meshStack as described in [meshcloud public docs](https://docs.meshcloud.io/docs/meshstack.how-to.integrate-meshplatform.html).
3+
Terraform module to integrate GCP as a meshPlatform into meshStack instance. With this module, service accounts used by meshStack are created with the required permissions. The output of this module is a set of credentials that need to be configured in meshStack as described in [meshcloud public docs](https://docs.meshcloud.io/docs/meshstack.how-to.integrate-meshplatform.html).
44

55
<p align="center">
66
<img src="/.github/Icon_GCP_Meshi_Hugs.png" width="250">
@@ -57,25 +57,26 @@ To run this module, you need the following:
5757
5858
You can create [custom roles](./custom-roles/main.tf) and assign them to the identity applying those modules.
5959
60+
Additionally, after the module has run, replicator service account needs to be granted a role in the Admin Console (Workspace). This can only be done by `Super Administrators`.
61+
6062
- [Terraform installed](https://learn.hashicorp.com/tutorials/terraform/install-cli)
6163
- [gcloud installed](https://cloud.google.com/sdk/docs/install)
64+
- A GCP Project
6265
63-
Additionally, after the module has run, one of the Service Accounts needs to be granted a role in the Admin Console (Workspace). This can only be done by Super Administrators.
64-
65-
## How to Use This Module
66+
Before using this module, you need a gcp project. We recommend creating a new project for meshcloud service accounts.
6667
67-
Before using this module, you need a gcp project. We recommend creating a new project for meshcloud service accounts.
68+
You can create a gcp project by adding this terraform block to your terraform file:
6869
69-
You can create a gcp project by adding this terraform block to your terraform file:
70+
```hcl
71+
resource "google_project" "meshstack_root" {
72+
name = <PROJECT_NAME>
73+
project_id = <PROJECT_ID>
74+
folder_id = <FOLDER_ID>
75+
billing_account = <BILLING_ACCOUNT_ID>
76+
}
77+
```
7078

71-
```hcl
72-
resource "google_project" "meshstack_root" {
73-
name = <PROJECT_NAME>
74-
project_id = <PROJECT_ID>
75-
folder_id = <FOLDER_ID>
76-
billing_account = <BILLING_ACCOUNT_ID>
77-
}
78-
```
79+
## How to Use This Module
7980

8081
To provide some of the required variables, you will need to
8182

@@ -90,27 +91,32 @@ To provide some of the required variables, you will need to
9091
gcloud auth application-default login
9192
```
9293

93-
2. Download the example `main.tf` and `outputs.tf` files.
94+
2. Create a terraform file that calls this module and produces outputs. Similar to:
9495

95-
```sh
96-
# Downloads main.tf and outputs.tf files into ~/terraform-gcp-meshplatform
97-
wget https://raw.githubusercontent.com/meshcloud/terraform-gcp-meshplatform/main/examples/basic-gcp-integration/main.tf -P ~/terraform-gcp-meshplatform
98-
wget https://raw.githubusercontent.com/meshcloud/terraform-gcp-meshplatform/main/examples/basic-gcp-integration/outputs.tf -P ~/terraform-gcp-meshplatform
96+
```hcl
97+
module "meshplatform" {
98+
source = "git::https://github.com/meshcloud/terraform-gcp-meshplatform.git"
99+
# FILL INPUTS
100+
}
101+
102+
output "meshplatform" {
103+
sensitive = true
104+
value = module.meshplatform
105+
}
99106
```
100107
108+
> 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.
109+
101110
3. Execute the module.
102111
103112
```sh
104-
# Changes into ~/terraform-gcp-meshplatform and applies terraform
105-
cd ~/terraform-gcp-meshplatform
106113
terraform init
107114
terraform apply
108115
```
109116
110-
4. Access terraform output and pass it securely to meshcloud.
117+
4. Access terraform output to insert it in meshStack platform config.
111118
112119
```sh
113-
# The JSON output contains sensitive values that must not be transmitted to meshcloud in plain text.
114120
terraform output -json
115121
```
116122
@@ -119,20 +125,18 @@ To provide some of the required variables, you will need to
119125
The replicator service account needs the "Groups Admin" role from the Admin Console (Workspace) to manage permissions for managed GCP projects.
120126
To authorize the Service Account **via the Google Admin Console** navigate to `@Account` in the sidebar and then `Admin Roles -> Groups Admin` and click `Assign Service Accounts`. In the prompt that appears, enter the service account email, which looks like `user@project.iam.gserviceaccount.com`.
121127
122-
## Example Usages
123-
124-
Check [examples](./examples/) for different use cases. As a quick start we recommend using [basic-gcp-integration](./examples/basic-gcp-integration) example.
125-
126128
## Contributing Guide
127129
128-
Before opening a Pull Request, we recommend following the below steps to get a faster approval:
130+
Before opening a Pull Request, please do the following:
129131
130132
1. Install [pre-commit](https://pre-commit.com/#install)
131133
132134
We use pre-commit to perform several terraform related tasks such as `terraform validate`, `terraform fmt`, and generating terraform docs with `terraform_docs`
133135
134136
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`.
135137
138+
To update git submodules, execute `git submodule foreach git pull`.
139+
136140
<!-- BEGIN_TF_DOCS -->
137141
## Requirements
138142
@@ -167,6 +171,7 @@ Before opening a Pull Request, we recommend following the below steps to get a f
167171
|------|-------------|------|---------|:--------:|
168172
| <a name="input_billing_account_id"></a> [billing\_account\_id](#input\_billing\_account\_id) | The GCP billing account in your organization. | `string` | n/a | yes |
169173
| <a name="input_billing_org_id"></a> [billing\_org\_id](#input\_billing\_org\_id) | GCP organization ID that holds billing account. | `string` | n/a | yes |
174+
| <a name="input_can_delete_projects_in_landing_zone_folder_ids"></a> [can\_delete\_projects\_in\_landing\_zone\_folder\_ids](#input\_can\_delete\_projects\_in\_landing\_zone\_folder\_ids) | The service account will have projectDeleter role only on the specified landing zone IDs. | `set(string)` | `[]` | no |
170175
| <a name="input_carbon_export_module_enabled"></a> [carbon\_export\_module\_enabled](#input\_carbon\_export\_module\_enabled) | Determines whether or not to include the resources of the carbon footprint export module. | `bool` | `false` | no |
171176
| <a name="input_cloud_billing_export_dataset_id"></a> [cloud\_billing\_export\_dataset\_id](#input\_cloud\_billing\_export\_dataset\_id) | GCP BigQuery dataset containing the Cloud Billing BigQuery export.<br><br> **ATTENTION**<br> You need to manually configure the billing account big query export before exceuting this module.<br> See https://docs.meshcloud.io/docs/meshstack.how-to.integrate-meshplatform-gcp-manually.html#set-up-gcp-billing-data-export for instructions. | `string` | n/a | yes |
172177
| <a name="input_cloud_billing_export_project_id"></a> [cloud\_billing\_export\_project\_id](#input\_cloud\_billing\_export\_project\_id) | GCP Project where the BiqQuery table resides that holds the Cloud Billing export to BigQuery. See https://cloud.google.com/billing/docs/how-to/export-data-bigquery | `string` | n/a | yes |

default.nix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
./shared-workflows/terraform-meshplatform-modules/default.nix

examples/basic-gcp-integration/main.tf

Lines changed: 0 additions & 33 deletions
This file was deleted.

examples/basic-gcp-integration/outputs.tf

Lines changed: 0 additions & 21 deletions
This file was deleted.

examples/gcp-integration-lz-access-gdm-templates/main.tf

Lines changed: 0 additions & 42 deletions
This file was deleted.

examples/gcp-integration-lz-access-gdm-templates/outputs.tf

Lines changed: 0 additions & 21 deletions
This file was deleted.

modules/meshcloud-kraken-service-account/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ No modules.
2626
| [google_project_service.bigquery_api](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/project_service) | resource |
2727
| [google_service_account.meshcloud_kraken_sa](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/service_account) | resource |
2828
| [google_service_account_iam_member.kraken](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/service_account_iam_member) | resource |
29+
| [google_service_account_iam_member.kraken_id_token](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/service_account_iam_member) | resource |
2930
| [google_service_account_key.sa_key](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/service_account_key) | resource |
3031

3132
## Inputs

modules/meshcloud-replicator-service-account/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,15 @@ No modules.
2121
|------|------|
2222
| [google_billing_account_iam_member.replicator_service](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/billing_account_iam_member) | resource |
2323
| [google_folder_iam_member.replicator_service](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/folder_iam_member) | resource |
24+
| [google_folder_iam_member.replicator_service_project_deleter](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/folder_iam_member) | resource |
2425
| [google_organization_iam_custom_role.replicator_billing](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/organization_iam_custom_role) | resource |
2526
| [google_organization_iam_custom_role.replicator_service](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/organization_iam_custom_role) | resource |
2627
| [google_project_service.admin_api](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/project_service) | resource |
2728
| [google_project_service.cloudbilling_api](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/project_service) | resource |
2829
| [google_project_service.cloudresourcemanager_api](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/project_service) | resource |
2930
| [google_service_account.replicator_service](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/service_account) | resource |
3031
| [google_service_account_iam_member.replicator](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/service_account_iam_member) | resource |
32+
| [google_service_account_iam_member.replicator_id_token](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/service_account_iam_member) | resource |
3133
| [google_service_account_key.sa_key](https://registry.terraform.io/providers/hashicorp/google/5.19.0/docs/resources/service_account_key) | resource |
3234

3335
## Inputs
@@ -36,6 +38,7 @@ No modules.
3638
|------|-------------|------|---------|:--------:|
3739
| <a name="input_billing_account_id"></a> [billing\_account\_id](#input\_billing\_account\_id) | The GCP Billing Account in your organization. | `string` | n/a | yes |
3840
| <a name="input_billing_org_id"></a> [billing\_org\_id](#input\_billing\_org\_id) | GCP Organization Id that holds billing account | `string` | n/a | yes |
41+
| <a name="input_can_delete_projects_in_landing_zone_folder_ids"></a> [can\_delete\_projects\_in\_landing\_zone\_folder\_ids](#input\_can\_delete\_projects\_in\_landing\_zone\_folder\_ids) | The service account will have projectDeleter role only on the specified landing zone IDs. | `set(string)` | `[]` | no |
3942
| <a name="input_landing_zone_folder_ids"></a> [landing\_zone\_folder\_ids](#input\_landing\_zone\_folder\_ids) | GCP Folders that make up the Landing Zone. The service account will only receive permissions on these folders. | `set(string)` | n/a | yes |
4043
| <a name="input_org_id"></a> [org\_id](#input\_org\_id) | GCP Organization Id | `string` | n/a | yes |
4144
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | GCP Project ID where to create the resources. This is typically a 'meshstack-root' project | `string` | n/a | yes |

shared-workflows

Submodule shared-workflows added at 442817f

0 commit comments

Comments
 (0)