-
Notifications
You must be signed in to change notification settings - Fork 428
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
feat: adding support for automatic creation of psc consumer #613
Changes from all commits
a35c13c
5ec918b
395e83a
da80ca1
361bce8
9eba9fd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,12 @@ locals { | |
// Force the usage of connector_enforcement | ||
connector_enforcement = var.connector_enforcement ? "REQUIRED" : "NOT_REQUIRED" | ||
|
||
|
||
psc_consumers = var.psc_consumer.enabled ? { for instance in concat([google_sql_database_instance.default], values(google_sql_database_instance.replicas)) : instance.name => instance } : {} | ||
|
||
|
||
database_name = var.enable_default_db ? google_sql_database.default[0].name : (length(local.databases) > 0 ? google_sql_database.additional_databases[0].name : "") | ||
|
||
} | ||
|
||
resource "random_id" "suffix" { | ||
|
@@ -320,15 +325,62 @@ resource "google_sql_user" "iam_account" { | |
deletion_policy = var.user_deletion_policy | ||
} | ||
|
||
|
||
resource "google_compute_address" "psc_ilb_consumer_address" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For each resource that supports project argument let's explicitly provide it and not depend on inheriting from provider. |
||
for_each = local.psc_consumers | ||
region = var.region | ||
name = each.value.name | ||
subnetwork = var.psc_consumer.subnet_id | ||
address_type = "INTERNAL" | ||
} | ||
|
||
resource "google_compute_forwarding_rule" "psc_ilb_consumer" { | ||
for_each = local.psc_consumers | ||
region = var.region | ||
name = each.value.name | ||
target = each.value.psc_service_attachment_link | ||
load_balancing_scheme = "" | ||
network = var.psc_consumer.network_id | ||
subnetwork = var.psc_consumer.subnet_id | ||
allow_psc_global_access = var.psc_consumer.allow_psc_global_access | ||
ip_address = google_compute_address.psc_ilb_consumer_address[each.value.name].id | ||
} | ||
|
||
resource "google_dns_managed_zone" "psc_dns_zone" { | ||
for_each = local.psc_consumers | ||
name = each.value.name | ||
dns_name = each.value.dns_name | ||
visibility = "private" | ||
private_visibility_config { | ||
networks { | ||
network_url = var.psc_consumer.network_id | ||
} | ||
} | ||
} | ||
|
||
resource "google_dns_record_set" "a" { | ||
for_each = local.psc_consumers | ||
name = each.value.dns_name | ||
managed_zone = google_dns_managed_zone.psc_dns_zone[each.value.name].name | ||
type = "A" | ||
ttl = 300 | ||
rrdatas = [google_compute_address.psc_ilb_consumer_address[each.value.name].address] | ||
} | ||
|
||
|
||
|
||
Comment on lines
+349
to
+371
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @srinandan suggested we make this optional with default false |
||
resource "google_project_iam_member" "database_integration" { | ||
for_each = toset(var.database_integration_roles) | ||
project = var.project_id | ||
role = each.value | ||
member = "serviceAccount:${google_sql_database_instance.default.service_account_email_address}" | ||
} | ||
|
||
|
||
resource "null_resource" "module_depends_on" { | ||
triggers = { | ||
value = length(var.module_depends_on) | ||
} | ||
} | ||
|
||
|
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.
Looks like test failure was due to name constraints
Returning due to fatal error: FatalError{Underlying: error while running command: exit status 1; Error: "name" ("your_network_name") doesn't match regexp "^(?:[a-z](?:[-a-z0-9]{0,61}[a-z0-9])?)$"