Skip to content
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

Configure propagation time (time sleep) for inclusion of the created project in a VPC-SC perimeter #766

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ determining that location is as follows:
| usage\_bucket\_prefix | Prefix in the GCS bucket to store GCE usage reports in (optional) | `string` | `""` | no |
| vpc\_service\_control\_attach\_enabled | Whether the project will be attached to a VPC Service Control Perimeter | `bool` | `false` | no |
| vpc\_service\_control\_perimeter\_name | The name of a VPC Service Control Perimeter to add the created project to | `string` | `null` | no |
| vpc\_service\_control\_sleep\_duration | The duration to sleep in seconds before adding the project to a shared VPC after the project is added to the VPC Service Control Perimeter | `string` | `"5s"` | no |

## Outputs

Expand Down
1 change: 1 addition & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ module "project-factory" {
disable_dependent_services = var.disable_dependent_services
vpc_service_control_attach_enabled = var.vpc_service_control_attach_enabled
vpc_service_control_perimeter_name = var.vpc_service_control_perimeter_name
vpc_service_control_sleep_duration = var.vpc_service_control_sleep_duration
default_network_tier = var.default_network_tier
}

Expand Down
6 changes: 3 additions & 3 deletions modules/core_project_factory/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ module "project_services" {
/******************************************
Shared VPC configuration
*****************************************/
resource "time_sleep" "wait_5_seconds" {
resource "time_sleep" "wait_vpc_sc_propagation" {
daniel-cit marked this conversation as resolved.
Show resolved Hide resolved
count = var.vpc_service_control_attach_enabled ? 1 : 0
depends_on = [google_access_context_manager_service_perimeter_resource.service_perimeter_attachment[0], google_project_service.enable_access_context_manager[0]]
create_duration = "5s"
create_duration = var.vpc_service_control_sleep_duration
}

resource "google_compute_shared_vpc_service_project" "shared_vpc_attachment" {
Expand All @@ -120,7 +120,7 @@ resource "google_compute_shared_vpc_service_project" "shared_vpc_attachment" {
count = var.enable_shared_vpc_service_project ? 1 : 0
host_project = var.shared_vpc
service_project = google_project.main.project_id
depends_on = [time_sleep.wait_5_seconds[0], module.project_services]
depends_on = [time_sleep.wait_vpc_sc_propagation[0], module.project_services]
}

resource "google_compute_shared_vpc_host_project" "shared_vpc_host" {
Expand Down
6 changes: 6 additions & 0 deletions modules/core_project_factory/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,12 @@ variable "vpc_service_control_perimeter_name" {
default = null
}

variable "vpc_service_control_sleep_duration" {
description = "The duration to sleep in seconds before adding the project to a shared VPC after the project is added to the VPC Service Control Perimeter"
type = string
default = "5s"
}

variable "default_network_tier" {
description = "Default Network Service Tier for resources created in this project. If unset, the value will not be modified. See https://cloud.google.com/network-tiers/docs/using-network-service-tiers and https://cloud.google.com/network-tiers."
type = string
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,12 @@ variable "vpc_service_control_perimeter_name" {
default = null
}

variable "vpc_service_control_sleep_duration" {
description = "The duration to sleep in seconds before adding the project to a shared VPC after the project is added to the VPC Service Control Perimeter"
daniel-cit marked this conversation as resolved.
Show resolved Hide resolved
type = string
default = "5s"
}

variable "grant_services_security_admin_role" {
description = "Whether or not to grant Kubernetes Engine Service Agent the Security Admin role on the host project so it can manage firewall rules"
type = bool
Expand Down