Skip to content

Commit eff262c

Browse files
committed
feat: delete project permissions for replicator
1 parent 8082409 commit eff262c

File tree

5 files changed

+29
-0
lines changed

5 files changed

+29
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [Unreleased]
9+
10+
### Added
11+
12+
- Option to provide replicator service account project deletion permission on specified landing zone folders
13+
814
## [v0.2.0]
915

1016
### Added

main.tf

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ module "replicator_sa" {
2626

2727
landing_zone_folder_ids = var.landing_zone_folder_ids
2828

29+
can_delete_projects_in_landing_zone_folder_ids = var.can_delete_projects_in_landing_zone_folder_ids
30+
2931
billing_account_id = var.billing_account_id
3032

3133
service_account_key = var.service_account_keys

modules/meshcloud-replicator-service-account/module.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,14 @@ resource "google_folder_iam_member" "replicator_service" {
7272
member = "serviceAccount:${google_service_account.replicator_service.email}"
7373
}
7474

75+
resource "google_folder_iam_member" "replicator_service_project_deleter" {
76+
for_each = var.can_delete_projects_in_landing_zone_folder_ids
77+
78+
folder = each.value
79+
role = "roles/resourcemanager.projectDeleter"
80+
member = "serviceAccount:${google_service_account.replicator_service.email}"
81+
}
82+
7583
/*
7684
Billing Accounts are associated with an organization and can thus inherit organization level role assignments
7785
see https://cloud.google.com/billing/docs/how-to/billing-access).

modules/meshcloud-replicator-service-account/variables.tf

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ variable "landing_zone_folder_ids" {
1818
description = "GCP Folders that make up the Landing Zone. The service account will only receive permissions on these folders."
1919
}
2020

21+
variable "can_delete_projects_in_landing_zone_folder_ids" {
22+
type = set(string)
23+
description = "The service account will have projectDeleter role only on the specified landing zone IDs."
24+
default = []
25+
}
26+
2127
variable "billing_org_id" {
2228
type = string
2329
description = "GCP Organization Id that holds billing account"

variables.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,13 @@ variable "landing_zone_folder_ids" {
2323
description = "GCP Folders that make up the Landing Zone. The service account will only receive permissions on these folders."
2424
}
2525

26+
variable "can_delete_projects_in_landing_zone_folder_ids" {
27+
type = set(string)
28+
description = "The service account will have projectDeleter role only on the specified landing zone IDs."
29+
default = []
30+
}
31+
32+
2633
variable "cloud_billing_export_project_id" {
2734
type = string
2835
description = "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"

0 commit comments

Comments
 (0)