|
| 1 | +--- |
| 2 | +# generated by https://github.com/hashicorp/terraform-plugin-docs |
| 3 | +page_title: "smallstep_credential Resource - terraform-provider-smallstep" |
| 4 | +subcategory: "" |
| 5 | +description: |- |
| 6 | + A certificate key pair. |
| 7 | +--- |
| 8 | + |
| 9 | +# smallstep_credential (Resource) |
| 10 | + |
| 11 | +A certificate key pair. |
| 12 | + |
| 13 | +## Example Usage |
| 14 | + |
| 15 | +```terraform |
| 16 | +resource "smallstep_credential" "test" { |
| 17 | + slug = "slug" |
| 18 | +
|
| 19 | + certificate = { |
| 20 | + authority_id = smallstep_authory.staging.id |
| 21 | + duration = "168h" |
| 22 | + x509 = { |
| 23 | + common_name = { |
| 24 | + device_metadata = "smallstep:identity" |
| 25 | + } |
| 26 | + sans = { |
| 27 | + device_metadata = ["smallstep:identity"] |
| 28 | + } |
| 29 | + } |
| 30 | + } |
| 31 | +
|
| 32 | + key = { |
| 33 | + type = "ECDSA_P384" |
| 34 | + protection = "HARDWARE_ATTESTED" |
| 35 | + } |
| 36 | +
|
| 37 | + policy = { |
| 38 | + os = ["Linux"] |
| 39 | + ownership = ["company"] |
| 40 | + } |
| 41 | +
|
| 42 | + files = { |
| 43 | + root_file = "/var/ssl/ca.pem" |
| 44 | + } |
| 45 | +} |
| 46 | +``` |
| 47 | + |
| 48 | +<!-- schema generated by tfplugindocs --> |
| 49 | +## Schema |
| 50 | + |
| 51 | +### Required |
| 52 | + |
| 53 | +- `certificate` (Attributes) Configuration for the certificate of a managed credential. (see [below for nested schema](#nestedatt--certificate)) |
| 54 | +- `key` (Attributes) The attributes of the cryptographic key. Key `type` and `protection` are required unless the `pubFile` is set. (see [below for nested schema](#nestedatt--key)) |
| 55 | +- `slug` (String) |
| 56 | + |
| 57 | +### Optional |
| 58 | + |
| 59 | +- `files` (Attributes) Configuration for files that will be written when a managed credential is issued. (see [below for nested schema](#nestedatt--files)) |
| 60 | +- `policy` (Attributes) Policy to select the devices an account is assigned to. An empty policy indicates an account will be provisioned for all devices. (see [below for nested schema](#nestedatt--policy)) |
| 61 | + |
| 62 | +### Read-Only |
| 63 | + |
| 64 | +- `id` (String) A UUID identifying this credential. Read only. |
| 65 | + |
| 66 | +<a id="nestedatt--certificate"></a> |
| 67 | +### Nested Schema for `certificate` |
| 68 | + |
| 69 | +Required: |
| 70 | + |
| 71 | +- `x509` (Attributes) Populate certificate fields using using static names or device metadata. (see [below for nested schema](#nestedatt--certificate--x509)) |
| 72 | + |
| 73 | +Optional: |
| 74 | + |
| 75 | +- `authority_id` (String) A UUID identifying the authority that issues certificates for the credential. |
| 76 | +- `duration` (String) The certificate lifetime. Parsed as a [Golang duration](https://pkg.go.dev/time#ParseDuration). |
| 77 | + |
| 78 | +<a id="nestedatt--certificate--x509"></a> |
| 79 | +### Nested Schema for `certificate.x509` |
| 80 | + |
| 81 | +Required: |
| 82 | + |
| 83 | +- `common_name` (Attributes) (see [below for nested schema](#nestedatt--certificate--x509--common_name)) |
| 84 | + |
| 85 | +Optional: |
| 86 | + |
| 87 | +- `country` (Attributes) (see [below for nested schema](#nestedatt--certificate--x509--country)) |
| 88 | +- `locality` (Attributes) (see [below for nested schema](#nestedatt--certificate--x509--locality)) |
| 89 | +- `organization` (Attributes) (see [below for nested schema](#nestedatt--certificate--x509--organization)) |
| 90 | +- `organizational_unit` (Attributes) (see [below for nested schema](#nestedatt--certificate--x509--organizational_unit)) |
| 91 | +- `postal_code` (Attributes) (see [below for nested schema](#nestedatt--certificate--x509--postal_code)) |
| 92 | +- `province` (Attributes) (see [below for nested schema](#nestedatt--certificate--x509--province)) |
| 93 | +- `sans` (Attributes) (see [below for nested schema](#nestedatt--certificate--x509--sans)) |
| 94 | +- `street_address` (Attributes) (see [below for nested schema](#nestedatt--certificate--x509--street_address)) |
| 95 | + |
| 96 | +<a id="nestedatt--certificate--x509--common_name"></a> |
| 97 | +### Nested Schema for `certificate.x509.common_name` |
| 98 | + |
| 99 | +Optional: |
| 100 | + |
| 101 | +- `device_metadata` (String) A value populated from a key in the device's metadata. The special value `smallstep:identity` refers to the device's assigned user. If no value is found in the device's metadata at the specified key then the static value will be used. |
| 102 | +- `static` (String) A literal value. |
| 103 | + |
| 104 | + |
| 105 | +<a id="nestedatt--certificate--x509--country"></a> |
| 106 | +### Nested Schema for `certificate.x509.country` |
| 107 | + |
| 108 | +Optional: |
| 109 | + |
| 110 | +- `device_metadata` (List of String) Values populated from keys in the device's metadata. The special value `smallstep:identity` refers to the device's assigned user. |
| 111 | +- `static` (List of String) Literal values. |
| 112 | + |
| 113 | + |
| 114 | +<a id="nestedatt--certificate--x509--locality"></a> |
| 115 | +### Nested Schema for `certificate.x509.locality` |
| 116 | + |
| 117 | +Optional: |
| 118 | + |
| 119 | +- `device_metadata` (List of String) Values populated from keys in the device's metadata. The special value `smallstep:identity` refers to the device's assigned user. |
| 120 | +- `static` (List of String) Literal values. |
| 121 | + |
| 122 | + |
| 123 | +<a id="nestedatt--certificate--x509--organization"></a> |
| 124 | +### Nested Schema for `certificate.x509.organization` |
| 125 | + |
| 126 | +Optional: |
| 127 | + |
| 128 | +- `device_metadata` (List of String) Values populated from keys in the device's metadata. The special value `smallstep:identity` refers to the device's assigned user. |
| 129 | +- `static` (List of String) Literal values. |
| 130 | + |
| 131 | + |
| 132 | +<a id="nestedatt--certificate--x509--organizational_unit"></a> |
| 133 | +### Nested Schema for `certificate.x509.organizational_unit` |
| 134 | + |
| 135 | +Optional: |
| 136 | + |
| 137 | +- `device_metadata` (List of String) Values populated from keys in the device's metadata. The special value `smallstep:identity` refers to the device's assigned user. |
| 138 | +- `static` (List of String) Literal values. |
| 139 | + |
| 140 | + |
| 141 | +<a id="nestedatt--certificate--x509--postal_code"></a> |
| 142 | +### Nested Schema for `certificate.x509.postal_code` |
| 143 | + |
| 144 | +Optional: |
| 145 | + |
| 146 | +- `device_metadata` (List of String) Values populated from keys in the device's metadata. The special value `smallstep:identity` refers to the device's assigned user. |
| 147 | +- `static` (List of String) Literal values. |
| 148 | + |
| 149 | + |
| 150 | +<a id="nestedatt--certificate--x509--province"></a> |
| 151 | +### Nested Schema for `certificate.x509.province` |
| 152 | + |
| 153 | +Optional: |
| 154 | + |
| 155 | +- `device_metadata` (List of String) Values populated from keys in the device's metadata. The special value `smallstep:identity` refers to the device's assigned user. |
| 156 | +- `static` (List of String) Literal values. |
| 157 | + |
| 158 | + |
| 159 | +<a id="nestedatt--certificate--x509--sans"></a> |
| 160 | +### Nested Schema for `certificate.x509.sans` |
| 161 | + |
| 162 | +Optional: |
| 163 | + |
| 164 | +- `device_metadata` (List of String) Values populated from keys in the device's metadata. The special value `smallstep:identity` refers to the device's assigned user. |
| 165 | +- `static` (List of String) Literal values. |
| 166 | + |
| 167 | + |
| 168 | +<a id="nestedatt--certificate--x509--street_address"></a> |
| 169 | +### Nested Schema for `certificate.x509.street_address` |
| 170 | + |
| 171 | +Optional: |
| 172 | + |
| 173 | +- `device_metadata` (List of String) Values populated from keys in the device's metadata. The special value `smallstep:identity` refers to the device's assigned user. |
| 174 | +- `static` (List of String) Literal values. |
| 175 | + |
| 176 | + |
| 177 | + |
| 178 | + |
| 179 | +<a id="nestedatt--key"></a> |
| 180 | +### Nested Schema for `key` |
| 181 | + |
| 182 | +Optional: |
| 183 | + |
| 184 | +- `protection` (String) Whether to use a hardware module to store the private key. If set to `NONE` no hardware module will be used. `HARDWARE_WITH_FALLBACK` can only be used with the key file format `DEFAULT`. Allowed values: `NONE` `HARDWARE` `HARDWARE_WITH_FALLBACK` `HARDWARE_ATTESTED` |
| 185 | +- `pub_file` (String) A CSR or SSH public key to use instead of generating one. Cannot be used in conjunction with key type, key protection, key file or key file format. |
| 186 | +- `type` (String) The key type used. The current default type is `ECDSA_P256` but is not fixed at the time the credential resource is created - new keys generated for this credential in the future may have a different type. Allowed values: `DEFAULT` `ECDSA_P256` `ECDSA_P384` `ECDSA_P521` `RSA_2048` `RSA_3072` `RSA_4096` `ED25519` |
| 187 | + |
| 188 | + |
| 189 | +<a id="nestedatt--files"></a> |
| 190 | +### Nested Schema for `files` |
| 191 | + |
| 192 | +Optional: |
| 193 | + |
| 194 | +- `crt_file` (String) The filepath where the certificate is to be stored. |
| 195 | +- `gid` (Number) GID of the files where the credential is stored. |
| 196 | +- `key_file` (String) The filepath where the key is to be stored. |
| 197 | +- `key_format` (String) The format used to encode the private key. For X509 keys the default format is PKCS#8. The classic format is PKCS#1 for RSA keys, SEC 1 for ECDSA keys, and PKCS#8 for ED25519 keys. For SSH keys the default format is always the OPENSSH format. When a hardware module is used to store the keys the default will be a JSON representation of the key, except on Linux tss2 will be used. Allowed values: `DEFAULT` `PKCS8` `OPENSSH` `TSS2` `CLASSIC` |
| 198 | +- `mode` (Number) Permission bits of the files where the credential is stored. |
| 199 | +- `root_file` (String) The filepath where the root certificate is to be stored. |
| 200 | +- `uid` (Number) UID of the files where the credential is stored. |
| 201 | + |
| 202 | + |
| 203 | +<a id="nestedatt--policy"></a> |
| 204 | +### Nested Schema for `policy` |
| 205 | + |
| 206 | +Optional: |
| 207 | + |
| 208 | +- `assurance` (List of String) Assurance levels that devices must match. Allowed values: `normal` `high` |
| 209 | +- `os` (List of String) Operating systems that devices must match. Allowed values: `Linux` `Windows` `macOS` `iOS` `tvOS` `watchOS` `visionOS` |
| 210 | +- `ownership` (List of String) Ownership values that devices must match. Allowed values: `company` `user` |
| 211 | +- `source` (List of String) Registration sources that devices must match. Allowed values: `End-User` `Smallstep API` `Smallstep Agent` `Jamf` `Intune` |
| 212 | +- `tags` (List of String) Tags that devices must match. |
| 213 | + |
| 214 | +## Import |
| 215 | + |
| 216 | +Import is supported using the following syntax: |
| 217 | + |
| 218 | +The [`terraform import` command](https://developer.hashicorp.com/terraform/cli/commands/import) can be used, for example: |
| 219 | + |
| 220 | +```shell |
| 221 | +terraform import smallstep_credential.device_cred c1161f78-d251-401e-b17c-fe38fc26ae7b |
| 222 | +``` |
0 commit comments