forked from GoogleCloudPlatform/magic-modules
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add certificate template field to privateca Certificate (GoogleCloudP…
…latform#5135) * Add certificate authority field to Certificate, now that certificate authority is present in TF. Also adds test - which will only successfully run in CI since it depends on a static CA pool. * compare resource names instead, because we have a project number.
- Loading branch information
1 parent
63c7d06
commit 58caa82
Showing
3 changed files
with
145 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 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
121 changes: 121 additions & 0 deletions
121
mmv1/templates/terraform/examples/privateca_certificate_with_template.tf.erb
This file contains 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,121 @@ | ||
resource "google_privateca_certificate_template" "template" { | ||
location = "us-central1" | ||
name = "<%= ctx[:vars]["certificate_template_name"] %>" | ||
description = "An updated sample certificate template" | ||
|
||
identity_constraints { | ||
allow_subject_alt_names_passthrough = true | ||
allow_subject_passthrough = true | ||
|
||
cel_expression { | ||
description = "Always true" | ||
expression = "true" | ||
location = "any.file.anywhere" | ||
title = "Sample expression" | ||
} | ||
} | ||
|
||
passthrough_extensions { | ||
additional_extensions { | ||
object_id_path = [1, 6] | ||
} | ||
|
||
known_extensions = ["EXTENDED_KEY_USAGE"] | ||
} | ||
|
||
predefined_values { | ||
additional_extensions { | ||
object_id { | ||
object_id_path = [1, 6] | ||
} | ||
|
||
value = "c3RyaW5nCg==" | ||
critical = true | ||
} | ||
|
||
aia_ocsp_servers = ["string"] | ||
|
||
ca_options { | ||
is_ca = false | ||
max_issuer_path_length = 6 | ||
} | ||
|
||
key_usage { | ||
base_key_usage { | ||
cert_sign = false | ||
content_commitment = true | ||
crl_sign = false | ||
data_encipherment = true | ||
decipher_only = true | ||
digital_signature = true | ||
encipher_only = true | ||
key_agreement = true | ||
key_encipherment = true | ||
} | ||
|
||
extended_key_usage { | ||
client_auth = true | ||
code_signing = true | ||
email_protection = true | ||
ocsp_signing = true | ||
server_auth = true | ||
time_stamping = true | ||
} | ||
|
||
unknown_extended_key_usages { | ||
object_id_path = [1, 6] | ||
} | ||
} | ||
|
||
policy_ids { | ||
object_id_path = [1, 6] | ||
} | ||
} | ||
} | ||
|
||
resource "google_privateca_certificate_authority" "test-ca" { | ||
pool = "<%= ctx[:vars]["pool"] %>" | ||
certificate_authority_id = "<%= ctx[:vars]["certificate_authority_id"] %>" | ||
location = "us-central1" | ||
config { | ||
subject_config { | ||
subject { | ||
organization = "HashiCorp" | ||
common_name = "my-certificate-authority" | ||
} | ||
subject_alt_name { | ||
dns_names = ["hashicorp.com"] | ||
} | ||
} | ||
x509_config { | ||
ca_options { | ||
# is_ca *MUST* be true for certificate authorities | ||
is_ca = true | ||
} | ||
key_usage { | ||
base_key_usage { | ||
# cert_sign and crl_sign *MUST* be true for certificate authorities | ||
cert_sign = true | ||
crl_sign = true | ||
} | ||
extended_key_usage { | ||
server_auth = false | ||
} | ||
} | ||
} | ||
} | ||
key_spec { | ||
algorithm = "RSA_PKCS1_4096_SHA256" | ||
} | ||
} | ||
|
||
|
||
resource "google_privateca_certificate" "<%= ctx[:primary_resource_id] %>" { | ||
pool = "<%= ctx[:vars]["pool"] %>" | ||
location = "us-central1" | ||
certificate_authority = google_privateca_certificate_authority.test-ca.certificate_authority_id | ||
lifetime = "860s" | ||
name = "<%= ctx[:vars]["certificate_name"] %>" | ||
pem_csr = file("test-fixtures/rsa_csr.pem") | ||
certificate_template = google_privateca_certificate_template.template.id | ||
} |