Skip to content

Commit 19872b9

Browse files
author
Sohan
committed
create examples
1 parent da9d527 commit 19872b9

File tree

11 files changed

+137
-89
lines changed

11 files changed

+137
-89
lines changed

README.md

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33

44
<h1 align="center">
5-
Terraform DigitalOcean SSH Key
5+
Terraform DigitalOcean SSL Certificate
6+
7+
68
</h1>
79

8-
<p align="center" style="font-size: 1.2rem;">
9-
Provides a DigitalOcean SSH key resource to allow you to manage SSH keys for Droplet access.
10+
<p align="center" style="font-size: 1.2rem;">
11+
Provides a DigitalOcean Certificate resource that allows you to manage certificates.
1012
</p>
1113

1214
<p align="center">
@@ -22,13 +24,13 @@
2224
</p>
2325
<p align="center">
2426

25-
<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-digitalocean-ssh-key'>
27+
<a href='https://facebook.com/sharer/sharer.php?u=https://github.com/clouddrove/terraform-digitalocean-ssl-certificate'>
2628
<img title="Share on Facebook" src="https://user-images.githubusercontent.com/50652676/62817743-4f64cb80-bb59-11e9-90c7-b057252ded50.png" />
2729
</a>
28-
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Terraform+DigitalOcean+SSH+Key&url=https://github.com/clouddrove/terraform-digitalocean-ssh-key'>
30+
<a href='https://www.linkedin.com/shareArticle?mini=true&title=Terraform+DigitalOcean+SSL+Certificate&url=https://github.com/clouddrove/terraform-digitalocean-ssl-certificate'>
2931
<img title="Share on LinkedIn" src="https://user-images.githubusercontent.com/50652676/62817742-4e339e80-bb59-11e9-87b9-a1f68cae1049.png" />
3032
</a>
31-
<a href='https://twitter.com/intent/tweet/?text=Terraform+DigitalOcean+SSH+Key&url=https://github.com/clouddrove/terraform-digitalocean-ssh-key'>
33+
<a href='https://twitter.com/intent/tweet/?text=Terraform+DigitalOcean+SSL+Certificate&url=https://github.com/clouddrove/terraform-digitalocean-ssl-certificate'>
3234
<img title="Share on Twitter" src="https://user-images.githubusercontent.com/50652676/62817740-4c69db00-bb59-11e9-8a79-3580fbbf6d5c.png" />
3335
</a>
3436

@@ -41,7 +43,7 @@
4143

4244
## Prerequisites
4345

44-
This module has a few dependencies:
46+
This module has a few dependencies:
4547

4648

4749

@@ -50,18 +52,28 @@ This module has a few dependencies:
5052

5153

5254

53-
**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-digitalocean-ssh-key/releases).
55+
**IMPORTANT:** Since the `master` branch used in `source` varies based on new modifications, we suggest that you use the release versions [here](https://github.com/clouddrove/terraform-digitalocean-ssl-certificate/releases).
5456

5557

56-
### Simple Example
57-
Here is an example of how you can use this module in your inventory structure:
58+
Here are examples of how you can use this module in your inventory structure:
59+
### custom-certificate
60+
```hcl
61+
module "custom_certificate" {
62+
source = "./../../"
63+
certificate_name = "test"
64+
private_key = "./../../../_ssl/private-key.pem"
65+
leaf_certificate = "./../../../_ssl/star.crt"
66+
custom_certificate = true
67+
}
68+
```
69+
### lets-encrypt-certificate
5870
```hcl
59-
module "ssh-key" {
60-
source = "./../"
61-
key = "~/.ssh/id_rsa.pub"
62-
key_name = "devops"
63-
enable_ssh_key = true
64-
}
71+
module "lets_encrypt_certificate" {
72+
source = "./../../"
73+
certificate_name = "test"
74+
domain_names = ["clouddrove.com"]
75+
lets_encrypt_certificate = true
76+
}
6577
```
6678

6779

@@ -73,27 +85,33 @@ Here is an example of how you can use this module in your inventory structure:
7385

7486
| Name | Description | Type | Default | Required |
7587
|------|-------------|:----:|:-----:|:-----:|
76-
| enable_ssh_key | A boolean flag to enable/disable ssh key. | bool | `true` | no |
77-
| key_name | Name (e.g. `it-admin` or `devops`). | string | `` | no |
78-
| key_path | Name (e.g. `~/.ssh/id_rsa.pub` or `ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQ`). | string | `` | no |
88+
| certificate_chain | Path of certificate chain. | string | `` | no |
89+
| certificate_name | The name of the certificate for identification. | string | `` | no |
90+
| custom_certificate | A boolean flag to enable/disable custom_certificate. | bool | `false` | no |
91+
| domain_names | List of fully qualified domain names (FQDNs) for which the certificate will be issued. The domains must be managed using DigitalOcean's DNS. Only valid when type is lets_encrypt. | list | `<list>` | no |
92+
| enable_certificate | A boolean flag to enable/disable certificate. | bool | `true` | no |
93+
| leaf_certificate | Path of certificate body. | string | `~` | no |
94+
| lets_encrypt_certificate | A boolean flag to enable/disable lets_encrypt_certificate. | bool | `false` | no |
95+
| private_key | Path of private key. | string | `` | no |
7996

8097
## Outputs
8198

8299
| Name | Description |
83100
|------|-------------|
84-
| id | The unique ID of the key. |
85-
| name | Name of SSH key. |
86-
| public_key | The text of the public key. |
101+
| id | The unique ID of the certificate. |
102+
| name | The name of the certificate. |
103+
| not_after | The expiration date of the certificate. |
104+
| sha1_fingerprint | The SHA-1 fingerprint of the certificate. |
87105

88106

89107

90108

91109

92110

93-
## Feedback
94-
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-digitalocean-ssh-key/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).
111+
## Feedback
112+
If you come accross a bug or have any feedback, please log it in our [issue tracker](https://github.com/clouddrove/terraform-digitalocean-ssl-certificate/issues), or feel free to drop us an email at [[email protected]](mailto:[email protected]).
95113

96-
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-digitalocean-ssh-key)!
114+
If you have found it worth your time, go ahead and give us a ★ on [our GitHub](https://github.com/clouddrove/terraform-digitalocean-ssl-certificate)!
97115

98116
## About us
99117

@@ -108,4 +126,4 @@ At [CloudDrove][website], we offer expert guidance, implementation support and s
108126
[linkedin]: https://cpco.io/linkedin
109127
[twitter]: https://twitter.com/clouddrove/
110128
[email]: https://clouddrove.com/contact-us.html
111-
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=
129+
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=

README.yaml

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55
#
66

77
# Name of this project
8-
name : Terraform DigitalOcean SSH Key
8+
name : Terraform DigitalOcean SSL Certificate
99

1010
# License of this project
1111
license: "MIT"
1212

1313
# Canonical GitHub repo
14-
github_repo: clouddrove/terraform-digitalocean-ssh-key
14+
github_repo: clouddrove/terraform-digitalocean-ssl-certificate
1515

1616
# Badges to display
1717
badges:
@@ -24,21 +24,31 @@ badges:
2424

2525
# description of this project
2626
description: |-
27-
Provides a DigitalOcean SSH key resource to allow you to manage SSH keys for Droplet access.
27+
Provides a DigitalOcean Certificate resource that allows you to manage certificates.
2828
2929
# extra content
3030
include:
3131
- "terraform.md"
3232

3333
# How to use this project
3434
usage : |-
35-
### Simple Example
36-
Here is an example of how you can use this module in your inventory structure:
35+
Here are examples of how you can use this module in your inventory structure:
36+
### custom-certificate
3737
```hcl
38-
module "ssh-key" {
39-
source = "./../"
40-
key = "~/.ssh/id_rsa.pub"
41-
key_name = "devops"
42-
enable_ssh_key = true
43-
}
38+
module "custom_certificate" {
39+
source = "./../../"
40+
certificate_name = "test"
41+
private_key = "./../../../_ssl/private-key.pem"
42+
leaf_certificate = "./../../../_ssl/star.crt"
43+
custom_certificate = true
44+
}
45+
```
46+
### lets-encrypt-certificate
47+
```hcl
48+
module "lets_encrypt_certificate" {
49+
source = "./../../"
50+
certificate_name = "test"
51+
domain_names = ["clouddrove.com"]
52+
lets_encrypt_certificate = true
53+
}
4454
```
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
provider "digitalocean" {
3+
# You need to set this in your .bashrc
4+
# export DIGITALOCEAN_TOKEN="Your API TOKEN"
5+
#
6+
}
7+
8+
module "custom_certificate" {
9+
source = "./../../"
10+
certificate_name = "test"
11+
private_key = "./../../../_ssl/private-key.pem"
12+
leaf_certificate = "./../../../_ssl/star.crt"
13+
custom_certificate = true
14+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
output "id" {
3+
value = module.custom_certificate.*.id
4+
description = "The unique ID of the certificate."
5+
}

_example/example.tf

Lines changed: 0 additions & 26 deletions
This file was deleted.
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
2+
provider "digitalocean" {
3+
# You need to set this in your .bashrc
4+
# export DIGITALOCEAN_TOKEN="Your API TOKEN"
5+
#
6+
}
7+
8+
module "lets_encrypt_certificate" {
9+
source = "./../../"
10+
certificate_name = "test"
11+
domain_names = ["clouddrove.com"]
12+
lets_encrypt_certificate = true
13+
}
14+
15+
16+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
output "id" {
2+
value = module.lets_encrypt_certificate.*.id
3+
description = "The unique ID of the certificate."
4+
}

_example/outputs.tf

Lines changed: 0 additions & 14 deletions
This file was deleted.

main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
## Managed By : CloudDrove
2-
##Description : This Script is used to create Certificate Key.
2+
##Description : This Script is used to create SSL Certificate.
33
## Copyright @ CloudDrove. All Right Reserved.
44

55
#Module : Certificate
6-
#Description :Provides a DigitalOcean Certificate resource that allows you to manage certificates.
6+
#Description : Provides a DigitalOcean Certificate resource that allows you to manage certificates.
77
resource "digitalocean_certificate" "custom" {
8-
count = var.enable_certificate && var.custom_certificate == true ? 1 : 0
8+
count = var.enable_certificate && var.custom_certificate == true ? 1 : 0
99

1010
name = var.certificate_name
1111
type = "custom"
12-
private_key = file(var.private_key)
13-
leaf_certificate = file(var.leaf_certificate)
14-
certificate_chain = file(var.certificate_chain)
12+
private_key = var.private_key != "" ? file(var.private_key) : null
13+
leaf_certificate = var.leaf_certificate != "" ? file(var.leaf_certificate) : null
14+
certificate_chain = var.certificate_chain != "" ? file(var.certificate_chain) : null
1515
}
1616

1717
#Module : Certificate
1818
#Description :Provides a DigitalOcean Certificate resource that allows you to manage certificates.
1919
resource "digitalocean_certificate" "lets_encrypt" {
20-
count = var.enable_certificate && var.lets_encrypt_certificate == true ? 1 : 0
20+
count = var.enable_certificate && var.lets_encrypt_certificate == true ? 1 : 0
2121

22-
name = var.certificate_name
22+
name = var.certificate_name
2323
type = "lets_encrypt"
24-
domains = var.domain_names
24+
domains = var.domain_names
2525
}

outputs.tf

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#Module : Certificate
2+
#Description :Provides a DigitalOcean Certificate resource that allows you to manage certificates.
3+
4+
output "id" {
5+
value = var.custom_certificate ? join("", digitalocean_certificate.custom.*.id) : join("", digitalocean_certificate.lets_encrypt.*.id)
6+
description = "The unique ID of the certificate."
7+
}
8+
9+
output "name" {
10+
value = var.custom_certificate ? join("", digitalocean_certificate.custom.*.name) : join("", digitalocean_certificate.lets_encrypt.*.name)
11+
description = "The name of the certificate."
12+
}
13+
14+
output "not_after" {
15+
value = var.custom_certificate ? join("", digitalocean_certificate.custom.*.not_after) : join("", digitalocean_certificate.lets_encrypt.*.not_after)
16+
description = "The expiration date of the certificate."
17+
}
18+
19+
output "sha1_fingerprint" {
20+
value = var.custom_certificate ? join("", digitalocean_certificate.custom.*.sha1_fingerprint) : join("", digitalocean_certificate.lets_encrypt.*.sha1_fingerprint)
21+
description = "The SHA-1 fingerprint of the certificate."
22+
}

0 commit comments

Comments
 (0)