|
| 1 | +--- |
| 2 | +page_title: "Rancher2: rancher2_secret_v2 Resource" |
| 3 | +--- |
| 4 | + |
| 5 | +# rancher2\_secret\_v2 Resource |
| 6 | + |
| 7 | +Provides a Rancher Secret v2 resource. This can be used to create k8s secrets for Rancher v2 environments and retrieve their information. Secret v2 resource is available at Rancher v2.5.x and above. |
| 8 | + |
| 9 | +## Example Usage |
| 10 | + |
| 11 | +```hcl |
| 12 | +# Create a new Rancher2 Secret V2 |
| 13 | +resource "rancher2_secret_v2" "foo" { |
| 14 | + cluster_id = <CLUSTER_ID> |
| 15 | + name = "foo" |
| 16 | + data = { |
| 17 | + mydata1 = "<data1>" |
| 18 | + mydata2 = "<data2>" |
| 19 | + mydata3 = "<data3>" |
| 20 | + } |
| 21 | +} |
| 22 | +# Create a new Rancher2 Secret V2 basic-auth |
| 23 | +resource "rancher2_secret_v2" "foo" { |
| 24 | + cluster_id = <CLUSTER_ID> |
| 25 | + name = "foo" |
| 26 | + namespace = "<mynamespace>" |
| 27 | + type = "kubernetes.io/basic-auth" |
| 28 | + data = { |
| 29 | + password = "<mysecret>" |
| 30 | + username = "<myuser>" |
| 31 | + } |
| 32 | +} |
| 33 | +``` |
| 34 | + |
| 35 | +## Argument Reference |
| 36 | + |
| 37 | +The following arguments are supported: |
| 38 | + |
| 39 | +* `cluster_id` - (Required/ForceNew) The cluster id of the secret V2 (string) |
| 40 | +* `data` - (Required/Sensitive) The data of the secret v2 (map) |
| 41 | +* `name` - (Required) The name of the secret v2 (string) |
| 42 | +* `namespace` - (Optional/ForceNew) The namespaces of the secret v2. Default: `default` (string) |
| 43 | +* `type` - (Optional) The type of the k8s secret, used to facilitate programmatic handling of secret data, [More info](https://github.com/kubernetes/api/blob/release-1.20/core/v1/types.go#L5772) about k8s secret types and expected format. Default: `Opaque` (string) |
| 44 | +* `immutable` - (Optional) If set to true, any secret update will remove and recreate the secret. This is a beta field enabled by k8s `ImmutableEphemeralVolumes` feature gate. Default: `false` (bool) |
| 45 | +* `annotations` - (Optional/Computed) Annotations for the secret v2 (map) |
| 46 | +* `labels` - (Optional/Computed) Labels for the secret v2 (map) |
| 47 | + |
| 48 | +## Attributes Reference |
| 49 | + |
| 50 | +The following attributes are exported: |
| 51 | + |
| 52 | +* `id` - (Computed) The ID of the resource (string) |
| 53 | +* `resource_version` - (Computed) The k8s resource version (string) |
| 54 | + |
| 55 | +## Timeouts |
| 56 | + |
| 57 | +`rancher2_secret` provides the following |
| 58 | +[Timeouts](https://www.terraform.io/docs/configuration/resources.html#operation-timeouts) configuration options: |
| 59 | + |
| 60 | +- `create` - (Default `10 minutes`) Used for creating v2 secrets. |
| 61 | +- `update` - (Default `10 minutes`) Used for v2 secret modifications. |
| 62 | +- `delete` - (Default `10 minutes`) Used for deleting v2 secrets. |
| 63 | + |
| 64 | +## Import |
| 65 | + |
| 66 | +V2 secrets can be imported using the Rancher cluster ID, Secret V2 namespace and name. |
| 67 | + |
| 68 | +``` |
| 69 | +$ terraform import rancher2_secret_v2.foo <CLUSTER_ID>.<SECRET_V2_NAMESPACE>/<SECRET_V2_NAME> |
| 70 | +``` |
0 commit comments