Skip to content

Commit ed7a40a

Browse files
authored
Merge pull request #17 from keyfactor-pub/store_fixes
feat: Certificate deployment resource
2 parents a067bad + 77e675d commit ed7a40a

40 files changed

Lines changed: 2425 additions & 369 deletions

.github/workflows/release.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ jobs:
3232
gpg_private_key: ${{ secrets.GPG_PRIVATE_KEY }}
3333
passphrase: ${{ secrets.PASSPHRASE }}
3434
- name: Run GoReleaser
35-
uses: goreleaser/goreleaser-action@v3
35+
uses: goreleaser/goreleaser-action@v4
3636
with:
37-
args: release --rm-dist
37+
args: release --clean
3838
env:
3939
# GitHub sets the GITHUB_TOKEN secret automatically.
4040
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.github/workflows/tests.yml

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -72,37 +72,37 @@ jobs:
7272
- run: go mod download
7373
- env:
7474
TF_ACC: "1"
75-
KEYFACTOR_DEPLOY_CERT_STOREID1: "ef0b8005-63bf-42e8-aa3f-23bc94dcf611"
76-
KEYFACTOR_DEPLOY_CERT_STOREID2: "ef0b8005-63bf-42e8-aa3f-23bc94dcf611"
77-
7875
KEYFACTOR_HOSTNAME: ${{secrets.KEYFACTOR_HOSTNAME}}
7976
KEYFACTOR_USERNAME: ${{secrets.KEYFACTOR_USERNAME}}
8077
KEYFACTOR_PASSWORD: ${{secrets.KEYFACTOR_PASSWORD}}
8178
KEYFACTOR_DOMAIN: ${{secrets.KEYFACTOR_DOMAIN}}
8279

83-
KEYFACTOR_CERTIFICATE_ID: "26"
84-
KEYFACTOR_CERTIFICATE_PASSWORD: ${{secrets.TEST_CERTIFICATE_PASS}}
85-
KEYFACTOR_CERTIFICATE_TEMPLATE_NAME: "2YearTestWebServer"
86-
KEYFACTOR_CERTIFICATE_CA_DOMAIN: "DC-CA.Command.local"
87-
KEYFACTOR_CERTIFICATE_CA_NAME: "CommandCA1"
80+
KEYFACTOR_CERTIFICATE_ID: ${{secrets.KEYFACTOR_CERTIFICATE_ID}}
81+
KEYFACTOR_CERTIFICATE_PASSWORD: ${{secrets.KEYFACTOR_CERTIFICATE_PASSWORD}}
82+
KEYFACTOR_CERTIFICATE_TEMPLATE_NAME: ${{secrets.KEYFACTOR_CERTIFICATE_TEMPLATE_NAME}}
83+
KEYFACTOR_CERTIFICATE_CA_DOMAIN: ${{secrets.KEYFACTOR_CERTIFICATE_CA_DOMAIN}}
84+
KEYFACTOR_CERTIFICATE_CA_NAME: ${{secrets.KEYFACTOR_CERTIFICATE_CA_NAME}}
8885

89-
KEYFACTOR_CERTIFICATE_STORE_ID: "ef0b8005-63bf-42e8-aa3f-23bc94dcf611"
90-
KEYFACTOR_CERTIFICATE_STORE_CLIENT_MACHINE: "myorchestrator01"
91-
KEYFACTOR_CERTIFICATE_STORE_ORCHESTRATOR_AGENT_ID: "c2b2084f-3d89-4ded-bb8b-b4e0e74d2b59"
92-
KEYFACTOR_CERTIFICATE_STORE_CONTAINER_ID1: "2"
93-
KEYFACTOR_CERTIFICATE_STORE_CONTAINER_ID2: "2"
86+
KEYFACTOR_CERTIFICATE_STORE_ID: ${{secrets.KEYFACTOR_CERTIFICATE_STORE_ID}}
87+
KEYFACTOR_CERTIFICATE_STORE_CLIENT_MACHINE: ${{secrets.KEYFACTOR_CERTIFICATE_STORE_CLIENT_MACHINE}}
88+
KEYFACTOR_CERTIFICATE_STORE_ORCHESTRATOR_AGENT_ID: ${{secrets.KEYFACTOR_CERTIFICATE_STORE_ORCHESTRATOR_AGENT_ID}}
89+
KEYFACTOR_CERTIFICATE_STORE_CONTAINER_ID1: ${{secrets.KEYFACTOR_CERTIFICATE_STORE_CONTAINER_ID1}}
90+
KEYFACTOR_CERTIFICATE_STORE_CONTAINER_ID2: ${{secrets.KEYFACTOR_CERTIFICATE_STORE_CONTAINER_ID2}}
9491
KEYFACTOR_CERTIFICATE_STORE_PASS: ${{secrets.TEST_CERTSTORE_PASS}}
9592

96-
KEYFACTOR_SECURITY_ROLE_NAME: "TerraformTest"
93+
KEYFACTOR_DEPLOY_CERT_STOREID1: ${{secrets.KEYFACTOR_DEPLOY_CERT_STOREID1}}
94+
KEYFACTOR_DEPLOY_CERT_STOREID2: ${{secrets.KEYFACTOR_DEPLOY_CERT_STOREID2}}
95+
96+
KEYFACTOR_SECURITY_ROLE_NAME: ${{secrets.KEYFACTOR_SECURITY_ROLE_NAME}}
9797

98-
KEYFACTOR_SECURITY_IDENTITY_ACCOUNTNAME: 'COMMAND\\terraformer'
99-
KEYFACTOR_SECURITY_IDENTITY_ROLE1: "EnrollPFX"
100-
KEYFACTOR_SECURITY_IDENTITY_ROLE2: "Terraform"
98+
KEYFACTOR_SECURITY_IDENTITY_ACCOUNTNAME: ${{secrets.KEYFACTOR_SECURITY_IDENTITY_ACCOUNTNAME}}
99+
KEYFACTOR_SECURITY_IDENTITY_ROLE1: ${{secrets.KEYFACTOR_SECURITY_IDENTITY_ROLE1}}
100+
KEYFACTOR_SECURITY_IDENTITY_ROLE2: ${{secrets.KEYFACTOR_SECURITY_IDENTITY_ROLE2}}
101101

102-
KEYFACTOR_TEMPLATE_ROLE_BINDING_ROLE_NAME: "Terraform"
103-
KEYFACTOR_TEMPLATE_ROLE_BINDING_TEMPLATE_NAME1: "2YearTestWebServer"
104-
KEYFACTOR_TEMPLATE_ROLE_BINDING_TEMPLATE_NAME2: "Workstation"
105-
KEYFACTOR_TEMPLATE_ROLE_BINDING_TEMPLATE_NAME3: "User"
102+
KEYFACTOR_TEMPLATE_ROLE_BINDING_ROLE_NAME: ${{secrets.KEYFACTOR_TEMPLATE_ROLE_BINDING_ROLE_NAME}}
103+
KEYFACTOR_TEMPLATE_ROLE_BINDING_TEMPLATE_NAME1: ${{secrets.KEYFACTOR_TEMPLATE_ROLE_BINDING_TEMPLATE_NAME1}}
104+
KEYFACTOR_TEMPLATE_ROLE_BINDING_TEMPLATE_NAME2: ${{secrets.KEYFACTOR_TEMPLATE_ROLE_BINDING_TEMPLATE_NAME2}}
105+
KEYFACTOR_TEMPLATE_ROLE_BINDING_TEMPLATE_NAME3: ${{secrets.KEYFACTOR_TEMPLATE_ROLE_BINDING_TEMPLATE_NAME3}}
106106

107107
run: go test -v -cover ./keyfactor
108108
timeout-minutes: 10

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ builds:
2828
ignore:
2929
- goos: darwin
3030
goarch: '386'
31-
binary: '{{ .ProjectName }}_v{{ .Version }}'
31+
binary: '{{ .ProjectName }}'
3232
archives:
3333
- format: zip
3434
name_template: '{{ .ProjectName }}_{{ .Version }}_{{ .Os }}_{{ .Arch }}'

GNUmakefile

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ NAMESPACE=keyfactor
66
WEBSITE_REPO=https://github.com/Keyfactor/terraform-provider-keyfactor
77
NAME=keyfactor
88
BINARY=terraform-provider-${NAME}
9-
VERSION=1.0.3
9+
VERSION=1.3.0
1010
OS_ARCH := $(shell go env GOOS)_$(shell go env GOARCH)
1111
BASEDIR := ~/.terraform.d/plugins
1212
INSTALLDIR := ${BASEDIR}/${HOSTNAME}/${NAMESPACE}/${NAME}/${VERSION}/${OS_ARCH}
1313

1414
default: build
1515

1616
build: fmtcheck
17+
go mod tidy
1718
go install
1819

1920
tfdocs:
@@ -59,4 +60,17 @@ fmt:
5960
debug: install
6061
@./scripts/gofmtcheck.sh
6162

62-
.PHONY: build release install test testacc fmtcheck fmt
63+
setversion:
64+
sed -i '' -e 's/VERSION = ".*"/VERSION = "$(VERSION)"/' keyfactor/version.go
65+
@sed -i '' -e 's/TAG_VERSION=v*.*/TAG_VERSION=v$(VERSION)/' tag.sh
66+
67+
vendor:
68+
go mod vendor
69+
70+
tag:
71+
git tag -d v$(VERSION) || true
72+
git push origin v$(VERSION) || true
73+
git tag v$(VERSION) || true
74+
git push origin v$(VERSION) || true
75+
76+
.PHONY: build release install test testacc fmtcheck fmt tag setversion vendor

docs/data-sources/certificate.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@ data "keyfactor_certificate" "protected_cert" {
3030

3131
### Required
3232

33-
- `id` (Number) Keyfactor certificate ID
33+
- `id` (Number) Keyfactor certificate identifier.
3434

3535
### Optional
3636

37-
- `key_password` (String, Sensitive) Password to protect certificate and private key with
37+
- `collection_id` (Number) Optional certificate collection identifier used to ensure user access to the certificate.
38+
- `key_password` (String, Sensitive) Optional, used to read the private key if it is password protected.
3839
- `metadata` (Map of String) Metadata key-value pairs to be attached to certificate
3940

4041
### Read-Only

docs/data-sources/certificate_store.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ output "iis_personal_metadata" {
5353
### Read-Only
5454

5555
- `agent_id` (String) String indicating the Keyfactor Command GUID of the orchestrator for the created store.
56-
- `certificates` (List of Number) A list of certificate IDs associated with the certificate store.
5756
- `client_machine` (String) Client machine name; value depends on certificate store type. See API reference guide
5857
- `container_id` (Number) Container identifier of the store's associated certificate store container.
5958
- `store_path` (String) Path to the new certificate store on a target. Format varies depending on type.

docs/resources/certificate.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ description: |-
1414

1515
```terraform
1616
provider "keyfactor" {
17-
username = "COMMAND\\your_username"
17+
username = "your_username"
1818
password = "your_api_password"
1919
hostname = "mykfinstance.kfdelivery.com"
2020
domain = "mydomain.com"
@@ -89,6 +89,7 @@ resource "keyfactor_certificate" "kf_csr_cert" {
8989

9090
### Optional
9191

92+
- `collection_id` (Number) Optional certificate collection identifier used to ensure user access to the certificate.
9293
- `csr` (String) Base-64 encoded certificate signing request (CSR)
9394
- `dns_sans` (List of String) List of DNS names to use as subjects of the certificate
9495
- `ip_sans` (List of String) List of DNS names to use as subjects of the certificate
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
# generated by https://github.com/hashicorp/terraform-plugin-docs
3+
page_title: "keyfactor_certificate_deployment Resource - terraform-provider-keyfactor"
4+
subcategory: ""
5+
description: |-
6+
7+
---
8+
9+
# keyfactor_certificate_deployment (Resource)
10+
11+
12+
13+
## Example Usage
14+
15+
```terraform
16+
provider "keyfactor" {
17+
username = "COMMAND\\your_username"
18+
password = "your_api_password"
19+
hostname = "mykfinstance.kfdelivery.com"
20+
domain = "mydomain.com"
21+
}
22+
23+
## PFX Enrollment
24+
resource "keyfactor_certificate" "pfx_cert" {
25+
subject = {
26+
subject_common_name = "ShortlivedTest7622-test"
27+
}
28+
dns_sans = ["ShortlivedTest7622-test"]
29+
30+
key_password = "don't put secrets in code!" // Please don't use this password in production pass in an environmental variable or something
31+
certificate_authority = "<test_domain>\\<test_ca>"
32+
certificate_template = "<my_template>"
33+
}
34+
35+
# Deploy the created PFX certificate to all created cert stores
36+
resource "keyfactor_certificate_deployment" "pfx_cert" {
37+
certificate_id = keyfactor_certificate.pfx_cert.id # ID of the certificate to deploy
38+
certificate_store_id = "<my_certstore_id>" # ID of the certificate store to deploy to
39+
certificate_alias = "<my_cert_alias>" # Alias to use for the certificate in the store
40+
}
41+
```
42+
43+
<!-- schema generated by tfplugindocs -->
44+
## Schema
45+
46+
### Required
47+
48+
- `certificate_alias` (String) A string providing an alias to be used for the certificate upon entry into the certificate store. The function of the alias varies depending on the certificate store type. Please ensure that the alias is lowercase, or problems can arise in Terraform Plan.
49+
- `certificate_id` (Number) Keyfactor certificate ID
50+
- `certificate_store_id` (String) A string containing the GUID for the certificate store to which the certificate should be added.
51+
52+
### Optional
53+
54+
- `key_password` (String, Sensitive) Password that protects PFX certificate, if the certificate was enrolled using PFX enrollment, or is password protected in general. This value cannot change, and Terraform will throw an error if a change is attempted.
55+
56+
### Read-Only
57+
58+
- `id` (String) A unique identifier for this certificate deployment.
59+
60+

docs/resources/certificate_store.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ resource "keyfactor_certificate_store" "iis_trusted_roots" {
6060

6161
### Read-Only
6262

63-
- `certificates` (List of Number) A list of certificate IDs associated with the certificate store.
6463
- `id` (String) Keyfactor certificate store GUID.
6564

6665
## Import

examples/resources/keyfactor_certificate/resource.tf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
provider "keyfactor" {
2-
username = "COMMAND\\your_username"
2+
username = "your_username"
33
password = "your_api_password"
44
hostname = "mykfinstance.kfdelivery.com"
55
domain = "mydomain.com"
@@ -19,7 +19,7 @@ resource "keyfactor_certificate" "PFXCertificate" {
1919

2020
# Optional SANs
2121
ip_sans = ["192.168.123.2", "172.51.2.4"] # Optional IP SANs
22-
dns_sans = ["meow.example.com", "meow2"] # Optional DNS SANs
22+
dns_sans = ["san1.example.com", "san2"] # Optional DNS SANs
2323
key_password = "my certificate password!"
2424
# The password for the certificate. Note: This is bad practice, use TF_VAR_<variable_name> instead.
2525
certificate_authority = "COMMAND\\MY_CA_01" # Keyfactor CA to use to handle the certificate request.

0 commit comments

Comments
 (0)