-
Notifications
You must be signed in to change notification settings - Fork 286
docs: Custom SAN examples #850
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
Merged
Merged
Changes from 3 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
abef8c5
Custom SAN examples
pandirigoog 931f135
docs: Custom SAN examples
pandirigoog abe5789
Merge branch 'main' of github.com:pandirigoog/pandiri-custom-san-samples
pandirigoog 00a94c8
Fix fmt issues
pandirigoog ba39da4
Add DB engine specific tests
pandirigoog 6a136ea
Use unique tags and add comments
pandirigoog 73c0f74
Merge branch 'main' into main
pandirigoog fd32a2a
Make tags unique
pandirigoog efe387b
Merge branch 'main' of github.com:pandirigoog/pandiri-custom-san-samples
pandirigoog 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
107 changes: 107 additions & 0 deletions
107
cloud_sql/mysql_instance_custom_subject_alternative_names/main.tf
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,107 @@ | ||
| /** | ||
| * Copyright 2025 Google LLC | ||
| * | ||
| * Licensed under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
| # [START cloud_sql_instance_service_identity] | ||
| resource "google_project_service_identity" "default" { | ||
| provider = google-beta | ||
| service = "sqladmin.googleapis.com" | ||
| } | ||
| # [END cloud_sql_instance_service_identity] | ||
|
|
||
| # [START privateca_ca_pool_suffix] | ||
pandirigoog marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| resource "random_string" "default" { | ||
| length = 10 | ||
| special = false | ||
| upper = false | ||
| } | ||
| # [END privateca_ca_pool_suffix] | ||
|
|
||
| # [START cloud_sql_mysql_instance_ca_pool] | ||
| resource "google_privateca_ca_pool" "default" { | ||
| name = "customer-ca-pool-${random_string.default.result}" | ||
| location = "asia-northeast1" | ||
| tier = "DEVOPS" | ||
| publishing_options { | ||
| publish_ca_cert = false | ||
| publish_crl = false | ||
| } | ||
| } | ||
| # [END cloud_sql_mysql_instance_ca_pool] | ||
|
|
||
| # [START cloud_sql_mysql_instance_ca] | ||
| resource "google_privateca_certificate_authority" "default" { | ||
pandirigoog marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| pool = google_privateca_ca_pool.default.name | ||
| certificate_authority_id = "my-certificate-authority" | ||
| location = "asia-northeast1" | ||
| lifetime = "86400s" | ||
| type = "SELF_SIGNED" | ||
| deletion_protection = false # set to "true" in production | ||
| skip_grace_period = true | ||
| ignore_active_certificates_on_deletion = true | ||
| config { | ||
| subject_config { | ||
| subject { | ||
| organization = "my organization" | ||
| common_name = "my certificate authority name" | ||
| } | ||
| } | ||
| x509_config { | ||
| ca_options { | ||
| is_ca = true | ||
| } | ||
| key_usage { | ||
| base_key_usage { | ||
| cert_sign = true | ||
| crl_sign = true | ||
| } | ||
| extended_key_usage { | ||
| server_auth = false | ||
| } | ||
| } | ||
| } | ||
| } | ||
| key_spec { | ||
| algorithm = "RSA_PKCS1_4096_SHA256" | ||
| } | ||
| } | ||
| # [END cloud_sql_mysql_instance_ca] | ||
|
|
||
| # [START cloud_sql_mysql_instance_iam_granting] | ||
| resource "google_privateca_ca_pool_iam_member" "default" { | ||
| ca_pool = google_privateca_ca_pool.default.id | ||
| role = "roles/privateca.certificateRequester" | ||
|
|
||
| member = "serviceAccount:${google_project_service_identity.default.email}" | ||
| } | ||
| # [END cloud_sql_mysql_instance_iam_granting] | ||
|
|
||
| # [START cloud_sql_mysql_instance_custom_subject_alternative_names] | ||
| resource "google_sql_database_instance" "default" { | ||
| name = "mysql-instance" | ||
| region = "asia-northeast1" | ||
| database_version = "MYSQL_8_4" | ||
| settings { | ||
| edition = "ENTERPRISE" | ||
| tier = "db-f1-micro" | ||
| ip_configuration { | ||
| # The following server CA mode lets the instance use customer-managed CAS CA to issue server certificates. | ||
| # https://cloud.google.com/sql/docs/mysql/admin-api/rest/v1beta4/instances#ipconfiguration | ||
| server_ca_mode = "CUSTOMER_MANAGED_CAS_CA" | ||
| server_ca_pool = google_privateca_ca_pool.default.id | ||
pandirigoog marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| custom_subject_alternative_names = ["customSan.test.com"] | ||
| } | ||
| } | ||
| } | ||
| # [END cloud_sql_mysql_instance_custom_subject_alternative_names] | ||
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.
Uh oh!
There was an error while loading. Please reload this page.