-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #311 from NetApp/138-new-resource-security_certifi…
…cates 138 new resource security certificate
- Loading branch information
Showing
12 changed files
with
893 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
--- | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "netapp-ontap_security_certificate Resource - terraform-provider-netapp-ontap" | ||
subcategory: "" | ||
description: |- | ||
SecurityCertificate resource | ||
--- | ||
|
||
# netapp-ontap_security_certificate (Resource) | ||
|
||
Create/ install/ sign a certificate | ||
|
||
### Related ONTAP commands | ||
```commandline | ||
* security certificate show | ||
* security certificate create | ||
* security certificate install | ||
* security certificate sign | ||
``` | ||
|
||
## Supported Platforms | ||
* On-prem ONTAP system 9.6 or higher | ||
* Amazon FSx for NetApp ONTAP | ||
|
||
## Example Usage | ||
|
||
```terraform | ||
# creating a cluster-scoped certificate | ||
resource "netapp-ontap_security_certificate" "create_certificate1" { | ||
cx_profile_name = "cluster5" | ||
name = "test_ca_cert1" | ||
common_name = "test_ca_cert" | ||
type = "root_ca" | ||
expiry_time = "P365DT" | ||
} | ||
# creating a certificate | ||
resource "netapp-ontap_security_certificate" "create_certificate2" { | ||
cx_profile_name = "cluster5" | ||
name = "tfsvm_ca_cert1" | ||
common_name = "tfsvm_ca_cert" | ||
type = "root_ca" | ||
svm_name = "tfsvm" | ||
expiry_time = "P365DT" | ||
} | ||
# signing a certificate | ||
resource "netapp-ontap_security_certificate" "sign_certificate" { | ||
cx_profile_name = "cluster5" | ||
name = "tfsvm_ca_cert1" | ||
common_name = "tfsvm_ca_cert" | ||
type = "root_ca" | ||
svm_name = "svm1" # SVM on which the signed certificate will exist | ||
expiry_time = "P90DT" | ||
signing_request = <<-EOT | ||
-----BEGIN CERTIFICATE REQUEST----- | ||
signing-request | ||
-----END CERTIFICATE REQUEST----- | ||
EOT | ||
} | ||
# installing a certificate | ||
resource "netapp-ontap_security_certificate" "install_certificate" { | ||
cx_profile_name = "cluster5" | ||
common_name = "svm1_cert1" | ||
type = "server" | ||
svm_name = "svm1" | ||
expiry_time = "P90DT" | ||
public_certificate = <<-EOT | ||
-----BEGIN CERTIFICATE----- | ||
certificate | ||
-----END CERTIFICATE----- | ||
EOT | ||
private_key = <<-EOT | ||
-----BEGIN PRIVATE KEY----- | ||
private-key | ||
-----END PRIVATE KEY----- | ||
EOT | ||
} | ||
``` | ||
|
||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
### Required | ||
|
||
- `cx_profile_name` (String) Connection profile name. | ||
- `common_name` (String) Common name of the certificate. | ||
- `type` (String) Type of certificate. | ||
|
||
### Optional | ||
|
||
- `expiry_time` (String) Certificate expiration time, in ISO 8601 duration format or date and time format. | ||
- `hash_function` (String) Hashing function. | ||
- `key_size` (Number) Key size of the certificate in bits. | ||
- `name` (String) The unique name of the security certificate per SVM. | ||
- `private_key` (String, Sensitive) Private key Certificate in PEM format. Only valid when installing a CA-signed certificate. | ||
- `public_certificate` (String) Public key Certificate in PEM format. If this is not provided during create action, a self-signed certificate is created. | ||
- `signing_request` (String) Certificate signing request to be signed by the given certificate authority. Request should be in X509 PEM format. | ||
- `svm_name` (String) Name of the SVM in which the certificate is created or installed or the SVM on which the signed certificate will exist. | ||
|
||
### Read-Only | ||
|
||
- `ca` (String) Certificate authority. | ||
- `id` (String) UUID of the certificate. | ||
- `scope` (String) Set to 'svm' for certificates installed in a SVM. Otherwise, set to 'cluster'. | ||
- `serial_number` (String) Serial number of the certificate. | ||
- `signed_certificate` (String) Signed public key Certificate in PEM format that is returned while signing a certificate. | ||
|
||
## Import | ||
This resource supports import, which allows you to import existing security certificate into the state of this resource. | ||
Import require a unique ID composed of the security certificate name, common name, type and connection profile, separated by a comma or security certificate common name, type, and connection profile, separated by a comma. | ||
|
||
id = `name`,`common_name`,`type`,`cx_profile_name` | ||
|
||
### Terraform Import | ||
|
||
For example | ||
|
||
Import with certificate name; recommended for ONTAP 9.8 or later | ||
```shell | ||
terraform import netapp-ontap_security_certificate.cert_import tfsvm_ca_cert1,tfsvm_ca_cert,root_ca,cluster5 | ||
``` | ||
|
||
Import with certificate common name & type; applicable for ONTAP 9.6 or 9.7 | ||
```shell | ||
terraform import netapp-ontap_security_certificate.cert_import svm1_cert1,server,cluster5 | ||
``` | ||
|
||
### Terraform Import Block | ||
This requires Terraform 1.5 or higher, and will auto create the configuration for you | ||
|
||
First create the block | ||
```terraform | ||
import { | ||
to = netapp-ontap_security_certificate.cert_import | ||
id = "tfsvm_ca_cert1,tfsvm_ca_cert,root_ca,cluster5" | ||
} | ||
``` | ||
Next run, this will auto create the configuration for you | ||
```shell | ||
terraform plan -generate-config-out=generated.tf | ||
``` | ||
This will generate a file called generated.tf, which will contain the configuration for the imported resource | ||
```terraform | ||
# __generated__ by Terraform | ||
# Please review these resources and move them into your main configuration files. | ||
# __generated__ by Terraform from "tfsvm_ca_cert1,tfsvm_ca_cert,root_ca,cluster5" | ||
resource "netapp-ontap_security_certificate" "cert_import" { | ||
common_name = "tfsvm_ca_cert" | ||
cx_profile_name = "cluster5" | ||
expiry_time = "2025-10-04T01:24:54-04:00" | ||
hash_function = "sha256" | ||
key_size = 2048 | ||
name = "tfsvm_ca_cert1" | ||
private_key = null # sensitive | ||
public_certificate = "-----BEGIN CERTIFICATE-----\ncertificate\n-----END CERTIFICATE-----\n" | ||
signing_request = null | ||
svm_name = "tfsvm" | ||
type = "root_ca" | ||
} | ||
``` |
1 change: 1 addition & 0 deletions
1
examples/resources/netapp-ontap_security_certificate/provider.tf
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 @@ | ||
../../provider/provider.tf |
53 changes: 53 additions & 0 deletions
53
examples/resources/netapp-ontap_security_certificate/resource.tf
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,53 @@ | ||
# creating a cluster-scoped certificate | ||
resource "netapp-ontap_security_certificate" "create_certificate1" { | ||
cx_profile_name = "cluster5" | ||
name = "test_ca_cert1" | ||
common_name = "test_ca_cert" | ||
type = "root_ca" | ||
expiry_time = "P365DT" | ||
} | ||
|
||
# creating a certificate | ||
resource "netapp-ontap_security_certificate" "create_certificate2" { | ||
cx_profile_name = "cluster5" | ||
name = "tfsvm_ca_cert1" | ||
common_name = "tfsvm_ca_cert" | ||
type = "root_ca" | ||
svm_name = "tfsvm" | ||
expiry_time = "P365DT" | ||
} | ||
|
||
# signing a certificate | ||
resource "netapp-ontap_security_certificate" "sign_certificate" { | ||
cx_profile_name = "cluster5" | ||
name = "tfsvm_ca_cert1" | ||
common_name = "tfsvm_ca_cert" | ||
type = "root_ca" | ||
svm_name = "svm1" # SVM on which the signed certificate will exist | ||
expiry_time = "P90DT" | ||
signing_request = <<-EOT | ||
-----BEGIN CERTIFICATE REQUEST----- | ||
signing-request | ||
-----END CERTIFICATE REQUEST----- | ||
EOT | ||
} | ||
|
||
# installing a certificate | ||
resource "netapp-ontap_security_certificate" "install_certificate" { | ||
cx_profile_name = "cluster5" | ||
common_name = "svm1_cert1" | ||
type = "server" | ||
svm_name = "svm1" | ||
expiry_time = "P90DT" | ||
public_certificate = <<-EOT | ||
-----BEGIN CERTIFICATE----- | ||
certificate | ||
-----END CERTIFICATE----- | ||
EOT | ||
|
||
private_key = <<-EOT | ||
-----BEGIN PRIVATE KEY----- | ||
private-key | ||
-----END PRIVATE KEY----- | ||
EOT | ||
} |
1 change: 1 addition & 0 deletions
1
examples/resources/netapp-ontap_security_certificate/terraform.tfvars
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 @@ | ||
../../provider/terraform.tfvars |
1 change: 1 addition & 0 deletions
1
examples/resources/netapp-ontap_security_certificate/variables.tf
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 @@ | ||
../../provider/variables.tf |
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
Oops, something went wrong.