Skip to content

Commit 4c86990

Browse files
asmit-singh-devAsmit Singh
andauthored
Updated github release pipeline (#8)
* Updated github release pipeline * Updated gpg signing key * Added provider documentation for terraform registry documentation page * Update github release pipeline --------- Co-authored-by: Asmit Singh <asmit.singh@DC-QXVQM7L526.local>
1 parent 44091bd commit 4c86990

File tree

3 files changed

+222
-46
lines changed

3 files changed

+222
-46
lines changed

.github/workflows/release.yml

Lines changed: 8 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ permissions:
1010

1111
jobs:
1212
goreleaser:
13-
runs-on: windows-latest
13+
runs-on: ubuntu-latest
1414
steps:
1515

1616
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -28,48 +28,12 @@ jobs:
2828
echo "TAG_NAME=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
2929
echo "Version extracted: ${GITHUB_REF#refs/tags/}"
3030
31-
- name: Setup Certificate
32-
run: |
33-
echo "${{ secrets.SM_CLIENT_CERT_FILE_B64 }}" | base64 --decode > D:\\Certificate_pkcs12.p12
34-
shell: bash
35-
36-
- name: Set variables
37-
id: variables
38-
run: |
39-
echo "::set-output name=version::${GITHUB_REF#refs/tags/v}"
40-
echo "SM_HOST=${{ secrets.SM_HOST }}" >> "$GITHUB_ENV"
41-
echo "SM_API_KEY=${{ secrets.SM_API_KEY }}" >> "$GITHUB_ENV"
42-
echo "SM_CLIENT_CERT_FILE=D:\\Certificate_pkcs12.p12" >> "$GITHUB_ENV"
43-
echo "SM_CLIENT_CERT_PASSWORD=${{ secrets.SM_CLIENT_CERT_PASSWORD }}" >> "$GITHUB_ENV"
44-
echo "GPG_CONF_FILE_PATH=C:/Users/RUNNER~1/.gnupg" >> "$GITHUB_ENV"
45-
shell: bash
46-
47-
- name: GPG Signing with Secure Software Manager
48-
id: installer
49-
uses: digicert/ssm-gpg-signing@v0.0.2
50-
51-
- name: Configuration
52-
run: |
53-
del "${{ env.GPG_CONF_FILE_PATH }}/gpg-agent.conf"
54-
echo verbose > ${{ env.GPG_CONF_FILE_PATH }}/gpg-agent.conf
55-
echo debug-all >> ${{ env.GPG_CONF_FILE_PATH }}/gpg-agent.conf
56-
echo "scdaemon-program C:\\Users\\RUNNER~1\\AppData\\Local\\Temp\\DigiCert One Signing Manager Tools\\ssm-scd.exe" >> ${{ env.GPG_CONF_FILE_PATH }}/gpg-agent.conf
57-
58-
- name: Import gpg key
59-
id: gpg-key
60-
run: |
61-
gpgconf --kill all
62-
smctl gpg keyring download ${{ secrets.SM_GPG_KEY_ID }} --file-path ${{ env.GPG_CONF_FILE_PATH }}/pubring.gpg
63-
gpg --card-status
64-
65-
# Extract fingerprint and set as step output
66-
FINGERPRINT=$(gpg --list-secret-keys --with-colons --fingerprint | grep fpr | head -n 1 | cut -d':' -f10)
67-
FINGERPRINT=${FINGERPRINT//:}
68-
echo "fingerprint=$FINGERPRINT" >> $GITHUB_OUTPUT
69-
shell: bash
70-
71-
- name: Clean working directory
72-
run: git clean -fd
31+
- name: Import GPG key
32+
uses: crazy-max/ghaction-import-gpg@e89d40939c28e39f97cf32126055eeae86ba74ec # v6.3.0
33+
id: import_gpg
34+
with:
35+
gpg_private_key: ${{ secrets.TERRAFORM_GPG_SECRET_KEY }}
36+
passphrase: ${{ secrets.TERRAFORM_GPG_PASSPHRASE }}
7337

7438
- name: Run GoReleaser
7539
uses: goreleaser/goreleaser-action@v4
@@ -79,4 +43,4 @@ jobs:
7943
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
8044
GORELEASER_CURRENT_TAG: ${{ env.TAG_NAME }}
8145
GORELEASER_VERSION: ${{ env.TAG_NAME }}
82-
GPG_FINGERPRINT: ${{ steps.gpg-key.outputs.fingerprint }}
46+
GPG_FINGERPRINT: ${{ steps.import_gpg.outputs.fingerprint }}

.goreleaser.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,13 @@ builds:
1414
goarch:
1515
- amd64
1616
- '386'
17+
- arm64
1718
ignore:
18-
- goos: darwin
19-
goarch: '386'
2019
- goos: windows
20+
goarch: 'arm64'
21+
- goos: linux
22+
goarch: 'arm64'
23+
- goos: darwin
2124
goarch: '386'
2225
binary: '{{ .ProjectName }}_v{{ .Version }}'
2326
archives:

docs/index.md

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
## Provider Configuration
2+
3+
Configure the provider with the DigiCert ONE API base URL and an API key:
4+
5+
```hcl
6+
provider "digicert" {
7+
url = "<digicert_host_url>" # DigiCert API base URL
8+
api_key = "<digicert_api_key>" # API key for authentication
9+
}
10+
```
11+
12+
### Provider Arguments
13+
14+
| Name | Description | Type | Required |
15+
|----------|--------------------------------------------------------------------------------------|--------|----------|
16+
| url | The URL pointing to the DigiCert ONE platform (e.g., "https://stage.one.digicert.com") | String | Yes |
17+
| api_key | The api key corresponding to a user’s account for authenticating to the DigiCert ONE platform | String | Yes |
18+
19+
## Resources
20+
21+
### Certificate Resource
22+
23+
The `digicert_certificate` resource allows you to issue and manage certificates.
24+
25+
#### Example with CSR
26+
27+
```hcl
28+
resource "digicert_certificate" "example" {
29+
profile_id = "8e201a92-4b16-412d-aa5c-bbeba3dacdef"
30+
common_name = "example.com"
31+
dns_names = ["www.example.com", "api.example.com"]
32+
csr = "-----BEGIN CERTIFICATE REQUEST-----\nMIICjzCCAX/ZvGPbg=\n-----END CERTIFICATE REQUEST-----\n"
33+
}
34+
```
35+
36+
#### Example without CSR
37+
38+
```hcl
39+
resource "digicert_certificate" "cert" {
40+
profile_id = "8e201a92-4b16-412d-aa5c-bbeba3dacdef"
41+
common_name = "example.com"
42+
dns_names = ["www.example.com", "api.example.com"]
43+
tags = ["production", "web-servers"]
44+
}
45+
```
46+
47+
### Resource Arguments
48+
49+
| Name | Description | Type | Required |
50+
|--------------|---------------------------------------------------------------|----------------|----------|
51+
| profile_id | ID of an existing DigiCert​​®​​ Trust Lifecycle Manager profile to use for certificate | String | Yes |
52+
| common_name | Common name of the certificate | String | Yes |
53+
| dns_names | SANs of the certificate, if any | List of Strings| No |
54+
| csr | Certificate Signing Request (CSR) in PEM format | String | No |
55+
| tags | Tags to attach to the certificate | List of Strings| No |
56+
57+
After enrollment, the `digicert_certificate` resource will expose:
58+
59+
| Name | Description |
60+
|---------------|--------------------------------------------------|
61+
| id | Unique identifier for the certificate |
62+
| serial_number | Serial number of the issued certificate |
63+
| status | Current status of the certificate |
64+
| thumbprint | SHA-1 thumbprint of the certificate |
65+
| valid_from | Certificate validity start date |
66+
| valid_to | Certificate validity end date |
67+
| certificate | Issued certificate in PEM format |
68+
| chain_pem | Certificate chain in PEM format |
69+
| request_id | Request ID for the certificate issuance |
70+
71+
## Certificate Outputs
72+
73+
Certificate outputs allow you to retrieve and use certificate details in your infrastructure or for verification purposes. When you define outputs, Terraform will display or make available specific certificate information after creation.
74+
75+
### Output Example
76+
77+
```hcl
78+
output "certificate_pem" {
79+
value = digicert_certificate.cert.certificate
80+
sensitive = true
81+
}
82+
83+
output "certificate_serial" {
84+
value = digicert_certificate.cert.serial_number
85+
}
86+
```
87+
## Certificate Management
88+
89+
### Creating Certificates
90+
91+
1. Verify your configuration:
92+
To check if your configuration is correct, run:
93+
```
94+
terraform plan
95+
```
96+
This command:
97+
98+
Validates the syntax and provider settings.
99+
100+
Displays the changes Terraform will make without applying them.
101+
102+
If there are no errors, proceed to the next step.
103+
104+
2. Apply the configuration:
105+
To create the certificates, execute:
106+
```
107+
terraform apply
108+
```
109+
Terraform will prompt for confirmation. Type yes and press Enter to proceed.
110+
111+
Upon successful execution, Terraform will:
112+
113+
Send a request to the DigiCert​​®​​ Trust Lifecycle Manager API.
114+
115+
Issue the requested certificates.
116+
117+
Store the certificate details in the Terraform state.
118+
3. View the Applied Configuration:
119+
To review the applied Terraform state, run:
120+
```
121+
terraform show
122+
```
123+
124+
## Revoking Certificates
125+
126+
There are multiple ways to revoke certificates in Terraform:
127+
128+
### Method 1: Remove Resource from Configuration
129+
130+
1. Remove the specific certificate resource from your Terraform configuration file.
131+
2. Run Terraform plan and apply:
132+
```
133+
terraform plan
134+
terraform apply
135+
```
136+
This will automatically detect the removed resource and revoke the corresponding certificate.
137+
138+
### Method 2: Targeted Destruction
139+
140+
Revoke a specific certificate by targeting its resource:
141+
142+
```
143+
terraform destroy -target=digicert_certificate.example
144+
```
145+
146+
### Method 3: Complete Destruction
147+
148+
Revoke all managed certificates:
149+
150+
```
151+
terraform destroy
152+
```
153+
(Be cautious, as this will remove the issued certificates.)
154+
155+
### Important Notes on Revocation
156+
157+
- Removing a certificate resource from the configuration or using `destroy` will trigger certificate revocation.
158+
- The certificate will be removed from both the DigiCert ONE platform and the Terraform state file.
159+
- Always use `terraform plan` before `apply` or `destroy` to preview changes.
160+
161+
## Security Best Practices
162+
163+
### Protecting Terraform State Files
164+
165+
The Terraform state file contains critical infrastructure information, including sensitive data.
166+
167+
Recommendations:
168+
- **Secure Storage**: Use remote backends with encryption and access controls:
169+
- HashiCorp's Terraform Cloud
170+
- AWS S3 with proper IAM policies
171+
- Google Cloud Storage with appropriate permissions
172+
- **Access Control**:
173+
- Restrict state file access to only necessary individuals or systems
174+
- Implement least privilege access principles
175+
176+
For comprehensive guidelines, refer to [HashiCorp's Sensitive Data in State documentation](https://www.terraform.io/language/state/sensitive-data).
177+
178+
## Troubleshooting
179+
- Error: API request failed (401 Unauthorized)
180+
181+
- Ensure the DigiCert ONE API key is valid and has required access.
182+
183+
- Error: Validation failed due to unknown attributes
184+
185+
- Check the DigiCert​​®​​ Trust Lifecycle Manager API documentation for the correct certificate attributes.
186+
187+
- Error: Certificate issuance failed (400 Bad Request)
188+
189+
- Ensure all required fields are correctly defined in main.tf.
190+
191+
For more details, refer to the [DigiCert​​®​​ Trust Lifecycle Manager API documentation](https://stage.one.digicert.com/mpki/docs/swagger-ui/index.html#/Inventory) or enable Terraform debugging:
192+
```
193+
TF_LOG=DEBUG terraform apply
194+
```
195+
196+
## Contributing
197+
198+
DigiCert Terraform Provider is open-source, meaning you can freely download, use, modify, and distribute it according to the terms of our license. However, this is not an open contribution project.
199+
To maintain code quality, security standards, and alignment with our internal development roadmap, we do not accept direct code contributions from external contributors. Our internal development team is solely responsible for all code changes and enhancements.
200+
201+
## Contact Us
202+
203+
If you have any questions, suggestions, or issues regarding this provider, you can contact us at terraform-provider-support@digicert.com.
204+
205+
## License
206+
207+
Copyright © 2025 DigiCert, Inc. All rights reserved.
208+
209+
This project is licensed under the MIT. See the [LICENSE](./LICENSE) file for more information.

0 commit comments

Comments
 (0)