-
Notifications
You must be signed in to change notification settings - Fork 1
Add role for the GCP VM Scanner. Refresh docs. #42
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
grzr
wants to merge
2
commits into
main
Choose a base branch
from
GBICSGO-3200
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,111 @@ | ||
| ## Pantheon gcp-org terraform module | ||
|
|
||
| Provides IAM bindings on folder or organization level. | ||
|
|
||
| This module is optional. | ||
|
|
||
| Example usage | ||
| ```hcl | ||
|
|
||
| # needed to prepare Pantheon VM Scanner role | ||
|
|
||
| module "gcp-org" { | ||
| source = "github.com/ottogroup/pantheon//terraform/modules/gcp-org?ref=VERSION" | ||
| org_id = "1234567890", # Organization1 | ||
| } | ||
|
|
||
| module "gcp-machine-scanning" { | ||
| source = "github.com/ottogroup/pantheon//terraform/modules/gcp-machine-scanning?ref=VERSION" | ||
|
|
||
| # either org_id or folder_ids MUST be set | ||
| org_id = "1234567890", # Organization1 | ||
| folder_ids = [ | ||
| "folders/112233445566" # Department2 | ||
| ] | ||
|
|
||
| pantheon_machine_scanning_role_id = module.gcp-org.pantheon_machine_scanning_role_id | ||
| pantheon_service_account = "engine@<project_id>.iam.gserviceaccount.com" | ||
| } | ||
|
|
||
|
|
||
| ``` | ||
|
|
||
| ## Requirements | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1 | | ||
| | <a name="requirement_google"></a> [google](#requirement\_google) | >= 4 | | ||
|
|
||
| ## Providers | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="provider_google"></a> [google](#provider\_google) | >= 4 | | ||
|
|
||
| ## Modules | ||
|
|
||
| | Name | Source | Version | | ||
| |------|--------|---------| | ||
| | <a name="module_gcp-roles"></a> [gcp-roles](#module\_gcp-roles) | ./../gcp-roles | n/a | | ||
|
|
||
| ## Resources | ||
|
|
||
| | Name | Type | | ||
| |------|------| | ||
| | [google_folder_iam_member.folder_level_permissions](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/folder_iam_member) | resource | | ||
| | [google_organization_iam_member.org_level_permissions](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/organization_iam_member) | resource | | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Name | Description | Type | Default | Required | | ||
| |------|-------------|------|---------|:--------:| | ||
| | <a name="input_folder_ids"></a> [folder\_ids](#input\_folder\_ids) | Optional: The ID of a folder you want to attach the permissions to. Per default, the permissions will be granted on the org level. The format for each element is folders/{folder\_id}. Needs to be set by user. | `list(string)` | `[]` | no | | ||
| | <a name="input_org_id"></a> [org\_id](#input\_org\_id) | The ID of the organization that owns the resources that you want to scan. Needs to be set by user. | `string` | `null` | no | | ||
| | <a name="input_pantheon_engine_role_id"></a> [pantheon\_engine\_role\_id](#input\_pantheon\_engine\_role\_id) | The ID of org level custom role of Pantheon Engine. Will be provided by output of gcp-org module. | `string` | n/a | yes | | ||
| | <a name="input_pantheon_gcp_roles"></a> [pantheon\_gcp\_roles](#input\_pantheon\_gcp\_roles) | The roles that will be applied to all folders or the organization. The default are the recommended roles. | `list(string)` | `null` | no | | ||
| | <a name="input_pantheon_service_account"></a> [pantheon\_service\_account](#input\_pantheon\_service\_account) | The service account used to scan resources. Will be provided by the team. | `string` | n/a | yes | | ||
|
|
||
| ## Outputs | ||
|
|
||
| No outputs. | ||
| <!-- BEGIN_TF_DOCS --> | ||
| ## Requirements | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="requirement_google"></a> [google](#requirement\_google) | ~> 7.0 | | ||
| | <a name="requirement_null"></a> [null](#requirement\_null) | 3.2.4 | | ||
|
|
||
| ## Providers | ||
|
|
||
| | Name | Version | | ||
| |------|---------| | ||
| | <a name="provider_google"></a> [google](#provider\_google) | ~> 7.0 | | ||
| | <a name="provider_null"></a> [null](#provider\_null) | 3.2.4 | | ||
|
|
||
| ## Modules | ||
|
|
||
| No modules. | ||
|
|
||
| ## Resources | ||
|
|
||
| | Name | Type | | ||
| |------|------| | ||
| | [google_folder_iam_member.folder_level_permissions](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/folder_iam_member) | resource | | ||
| | [google_organization_iam_member.org_level_permissions](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/organization_iam_member) | resource | | ||
| | [null_resource.assert_org_or_folder_ids_are_set](https://registry.terraform.io/providers/hashicorp/null/3.2.4/docs/resources/resource) | resource | | ||
|
|
||
| ## Inputs | ||
|
|
||
| | Name | Description | Type | Default | Required | | ||
| |------|-------------|------|---------|:--------:| | ||
| | <a name="input_folder_ids"></a> [folder\_ids](#input\_folder\_ids) | The ID of a folder you want to attach the permissions to. Per default, the permissions will be granted on the org level. The format for each element is folders/{folder\_id}. Needs to be set by user. Either org\_id or folder\_ids must be set. | `list(string)` | `[]` | no | | ||
| | <a name="input_org_id"></a> [org\_id](#input\_org\_id) | The ID of the organization that owns the resources that you want to scan. Needs to be set by user. Either org\_id or folder\_ids must be set. | `string` | `null` | no | | ||
| | <a name="input_pantheon_machine_scanning_role_id"></a> [pantheon\_machine\_scanning\_role\_id](#input\_pantheon\_machine\_scanning\_role\_id) | The ID of org level custom role of Pantheon VM Scanner. Will be provided by output of gcp-org module. | `string` | n/a | yes | | ||
| | <a name="input_pantheon_service_account"></a> [pantheon\_service\_account](#input\_pantheon\_service\_account) | The service account used to scan resources. Will be provided by the team. | `string` | n/a | yes | | ||
|
|
||
| ## Outputs | ||
|
|
||
| No outputs. | ||
| <!-- END_TF_DOCS --> |
This file contains hidden or 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,11 @@ | ||
| # | ||
| # This file contains role bindings required for Pantheon on the folder level. | ||
| # | ||
|
|
||
| # Iterate over the permutation of all roles and folderIds | ||
| resource "google_folder_iam_member" "folder_level_permissions" { | ||
| for_each = { for entry in local.folder_roles : "${entry.role}.${entry.folderId}" => entry } | ||
| folder = each.value.folderId | ||
| member = "serviceAccount:${var.pantheon_service_account}" | ||
| role = each.value.role | ||
| } |
This file contains hidden or 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,11 @@ | ||
| locals { | ||
| folder_roles = flatten( | ||
| [ | ||
| for folderId in var.folder_ids : { | ||
| role = var.pantheon_machine_scanning_role_id | ||
| folderId = folderId | ||
| } | ||
| ] | ||
| ) | ||
| is_org_level = length(var.folder_ids) == 0 | ||
| } |
This file contains hidden or 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,9 @@ | ||
|
|
||
| resource "null_resource" "assert_org_or_folder_ids_are_set" { | ||
| lifecycle { | ||
| precondition { | ||
| condition = (var.org_id == null && length(var.folder_ids) > 0) || (var.org_id != null && length(var.folder_ids) > 0) | ||
| error_message = "Either org_id or folder_ids must be set. Please provide either an org_id or at least one folder_id." | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,11 @@ | ||
| # | ||
| # This file contains role bindings required for Pantheon on the org level. | ||
| # | ||
|
|
||
| # Only iterate over roles, if the configuration is on org level, else iterate over empty list (create not resources) | ||
| resource "google_organization_iam_member" "org_level_permissions" { | ||
| for_each = local.is_org_level ? toset(var.pantheon_machine_scanning_role_id) : [] | ||
| org_id = var.org_id | ||
| member = "serviceAccount:${var.pantheon_service_account}" | ||
| role = each.key | ||
| } |
This file contains hidden or 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,12 @@ | ||
| terraform { | ||
| required_providers { | ||
| google = { | ||
| source = "hashicorp/google" | ||
| version = "~> 7.0" | ||
| } | ||
| null = { | ||
| source = "hashicorp/null" | ||
| version = "3.2.4" | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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,21 @@ | ||
| variable "org_id" { | ||
| type = string | ||
| default = null | ||
| description = "The ID of the organization that owns the resources that you want to scan. Needs to be set by user. Either org_id or folder_ids must be set." | ||
| } | ||
|
|
||
| variable "folder_ids" { | ||
| type = list(string) | ||
| default = [] | ||
| description = "The ID of a folder you want to attach the permissions to. Per default, the permissions will be granted on the org level. The format for each element is folders/{folder_id}. Needs to be set by user. Either org_id or folder_ids must be set." | ||
| } | ||
|
|
||
| variable "pantheon_machine_scanning_role_id" { | ||
| type = string | ||
| description = "The ID of org level custom role of Pantheon VM Scanner. Will be provided by output of gcp-org module." | ||
| } | ||
|
|
||
| variable "pantheon_service_account" { | ||
| type = string | ||
| description = "The service account used to scan resources. Will be provided by the team." | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lately single project onboarding was added for GCP. should this be supported here as well?