|
15 | 15 | */ |
16 | 16 |
|
17 | 17 | # [START privateca_create_ca] |
18 | | -resource "google_privateca_certificate_authority" "default" { |
| 18 | +resource "google_privateca_certificate_authority" "root_ca" { |
19 | 19 | // This example assumes this pool already exists. |
20 | 20 | // Pools cannot be deleted in normal test circumstances, so we depend on static pools |
21 | | - pool = "my-pool" |
22 | | - certificate_authority_id = "my-certificate-authority-hashicorp" |
23 | | - location = "us-central1" |
24 | | - deletion_protection = false # set to true to prevent destruction of the resource |
| 21 | + pool = "my-pool" |
| 22 | + certificate_authority_id = "my-certificate-authority-root" |
| 23 | + location = "us-central1" |
| 24 | + deletion_protection = false # set to true to prevent destruction of the resource |
| 25 | + ignore_active_certificates_on_deletion = true |
25 | 26 | config { |
26 | 27 | subject_config { |
27 | 28 | subject { |
28 | 29 | organization = "HashiCorp" |
29 | 30 | common_name = "my-certificate-authority" |
30 | 31 | } |
31 | | - subject_alt_name { |
32 | | - dns_names = ["hashicorp.com"] |
33 | | - } |
34 | 32 | } |
35 | 33 | x509_config { |
36 | 34 | ca_options { |
37 | | - is_ca = true |
38 | | - max_issuer_path_length = 10 |
| 35 | + # is_ca *MUST* be true for certificate authorities |
| 36 | + is_ca = true |
39 | 37 | } |
40 | 38 | key_usage { |
41 | 39 | base_key_usage { |
42 | | - digital_signature = true |
43 | | - content_commitment = true |
44 | | - key_encipherment = false |
45 | | - data_encipherment = true |
46 | | - key_agreement = true |
47 | | - cert_sign = true |
48 | | - crl_sign = true |
49 | | - decipher_only = true |
| 40 | + # cert_sign and crl_sign *MUST* be true for certificate authorities |
| 41 | + cert_sign = true |
| 42 | + crl_sign = true |
50 | 43 | } |
51 | 44 | extended_key_usage { |
52 | | - server_auth = true |
53 | | - client_auth = false |
54 | | - email_protection = true |
55 | | - code_signing = true |
56 | | - time_stamping = true |
| 45 | + server_auth = false |
57 | 46 | } |
58 | 47 | } |
59 | 48 | } |
60 | 49 | } |
61 | | - lifetime = "86400s" |
62 | 50 | key_spec { |
63 | 51 | algorithm = "RSA_PKCS1_4096_SHA256" |
64 | 52 | } |
| 53 | + // Root CA should be valid indefinetly e.g. 99 years |
| 54 | + lifetime = "${99 * 365 * 24 * 3600}s" |
65 | 55 | } |
66 | 56 | # [END privateca_create_ca] |
0 commit comments