-
Notifications
You must be signed in to change notification settings - Fork 112
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support complex configuration in consul_certificate_authority (#341)
When configuration Consul to use Vault as the certificate authority provider for Consul Connect the configuration can have more than strings so we need to use jsonencode for Terraform to accept the configuration. Also remove the copyright notices in the examples. Closes #324
- Loading branch information
1 parent
8b89c8a
commit 5f1ede6
Showing
8 changed files
with
181 additions
and
191 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
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 |
---|---|---|
@@ -1,80 +1,40 @@ | ||
--- | ||
layout: "consul" | ||
page_title: "Consul: consul_certificate_authority" | ||
sidebar_current: "docs-consul-resource-certificate-authority" | ||
# generated by https://github.com/hashicorp/terraform-plugin-docs | ||
page_title: "consul_certificate_authority Resource - terraform-provider-consul" | ||
subcategory: "" | ||
description: |- | ||
A resource that manage the Consul Connect Certificate Authority | ||
The consul_certificate_authority resource can be used to manage the configuration of the Certificate Authority used by Consul Connect https://www.consul.io/docs/connect/ca. | ||
-> Note: The keys in the config argument must be using Camel case. | ||
--- | ||
|
||
# certificate_authority | ||
# consul_certificate_authority (Resource) | ||
|
||
The `consul_certificate_authority` resource can be used to manage the configuration of | ||
the Certificate Authority used by [Consul Connect](https://www.consul.io/docs/connect/ca). | ||
The `consul_certificate_authority` resource can be used to manage the configuration of the Certificate Authority used by [Consul Connect](https://www.consul.io/docs/connect/ca). | ||
|
||
-> **Note:** The keys in the `config` argument must be using Camel case. | ||
|
||
## Example Usage | ||
|
||
### Using the built-in CA with specific TTL | ||
|
||
```hcl | ||
resource "consul_certificate_authority" "connect" { | ||
connect_provider = "consul" | ||
<!-- schema generated by tfplugindocs --> | ||
## Schema | ||
|
||
config = { | ||
LeafCertTTL = "24h" | ||
RotationPeriod = "2160h" | ||
IntermediateCertTTL = "8760h" | ||
} | ||
} | ||
``` | ||
|
||
### Using Vault to manage and sign certificates | ||
|
||
```hcl | ||
resource "consul_certificate_authority" "connect" { | ||
connect_provider = "vault" | ||
config = { | ||
Address = "http://localhost:8200" | ||
Token = "..." | ||
RootPKIPath = "connect-root" | ||
IntermediatePKIPath = "connect-intermediate" | ||
} | ||
} | ||
``` | ||
|
||
### Using the [AWS Certificate Manager Private Certificate Authority](https://aws.amazon.com/certificate-manager/private-certificate-authority/) | ||
### Required | ||
|
||
```hcl | ||
resource "consul_certificate_authority" "connect" { | ||
connect_provider = "aws-pca" | ||
- `connect_provider` (String) Specifies the CA provider type to use. | ||
|
||
config = { | ||
ExistingARN = "arn:aws:acm-pca:region:account:certificate-authority/12345678-1234-1234-123456789012" | ||
} | ||
} | ||
``` | ||
|
||
## Argument Reference | ||
|
||
The following arguments are supported: | ||
### Optional | ||
|
||
* `connect_provider` - (Required, string) Specifies the CA provider type to use. | ||
* `config` - (Required, map) The raw configuration to use for the chosen provider. | ||
- `config` (Map of String, Deprecated) The raw configuration to use for the chosen provider. For more information on configuring the Connect CA providers, see [Provider Config](https://developer.hashicorp.com/consul/docs/connect/ca). | ||
- `config_json` (String) The raw configuration to use for the chosen provider. For more information on configuring the Connect CA providers, see [Provider Config](https://developer.hashicorp.com/consul/docs/connect/ca). | ||
|
||
### Read-Only | ||
|
||
## Attributes Reference | ||
|
||
The following attributes are exported: | ||
|
||
* `connect_provider` - Specifies the CA provider type to use. | ||
* `config` - The raw configuration to use for the chosen provider. | ||
- `id` (String) The ID of this resource. | ||
|
||
## Import | ||
|
||
`certificate_authority` can be imported: | ||
Import is supported using the following syntax: | ||
|
||
``` | ||
$ terraform import certificate_authority.connect connect-ca | ||
```shell | ||
terraform import certificate_authority.connect connect-ca | ||
``` |
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 @@ | ||
terraform import certificate_authority.connect connect-ca |
34 changes: 34 additions & 0 deletions
34
examples/resources/consul_certificate_authority/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,34 @@ | ||
# Using the built-in CA with specific TTL | ||
resource "consul_certificate_authority" "connect" { | ||
connect_provider = "consul" | ||
|
||
config_json = jsondecode({ | ||
LeafCertTTL = "24h" | ||
RotationPeriod = "2160h" | ||
IntermediateCertTTL = "8760h" | ||
}) | ||
} | ||
|
||
|
||
# Using Vault to manage and sign certificates | ||
resource "consul_certificate_authority" "connect" { | ||
connect_provider = "vault" | ||
|
||
config_json = jsonencode({ | ||
Address = "http://localhost:8200" | ||
Token = "..." | ||
RootPKIPath = "connect-root" | ||
IntermediatePKIPath = "connect-intermediate" | ||
}) | ||
} | ||
|
||
|
||
# Using the AWS Certificate Manager Private Certificate Authority | ||
# * https://aws.amazon.com/certificate-manager/private-certificate-authority/ | ||
resource "consul_certificate_authority" "connect" { | ||
connect_provider = "aws-pca" | ||
|
||
config_json = jsonencode({ | ||
ExistingARN = "arn:aws:acm-pca:region:account:certificate-authority/12345678-1234-1234-123456789012" | ||
}) | ||
} |
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.