Skip to content

Commit

Permalink
fix: update count condition and add changelog.md file
Browse files Browse the repository at this point in the history
  • Loading branch information
themaheshyadav committed Jul 7, 2023
1 parent d613b51 commit fab9b6e
Show file tree
Hide file tree
Showing 13 changed files with 44 additions and 26 deletions.
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ updates:
open-pull-requests-limit: 3

- package-ecosystem: "terraform" # See documentation for possible values
directory: "/_examples/custom_certificate" # Location of package manifests
directory: "/_examples/complete" # Location of package manifests
schedule:
interval: "weekly"
# Add assignees
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/tf-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
tf-static-checks-custom-certificate-example:
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
with:
working_directory: './_examples/custom_certificate/'
working_directory: './_examples/complete/'

tf-static-checks-lets_encrypt-certificate-example:
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
Expand Down
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
2 changes: 1 addition & 1 deletion README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,6 @@ usage : |-
source = "terraform-do-modules/certificate/digitalocean"
version = "0.15.0"
certificate_name = "test"
domain_names = ["test.do.clouddrove.ca"]
domain_names = ["clouddrove.ca"]
}
```
File renamed without changes.
7 changes: 7 additions & 0 deletions _examples/complete/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##-------------------------------------------------------
## OUTPUT
##-------------------------------------------------------
output "id" {
value = module.custom_certificate[*].id
description = "The unique ID of the certificate."
}
File renamed without changes.
5 changes: 0 additions & 5 deletions _examples/custom_certificate/outputs.tf

This file was deleted.

2 changes: 1 addition & 1 deletion _examples/lets_encrypt_certificate/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ provider "digitalocean" {}
module "lets_encrypt_certificate" {
source = "./../../"
certificate_name = "test"
domain_names = ["test.do.clouddrove.ca"]
domain_names = ["clouddrove.ca"]
}
3 changes: 3 additions & 0 deletions _examples/lets_encrypt_certificate/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
##-------------------------------------------------------
## OUTPUT
##-------------------------------------------------------
output "id" {
value = module.lets_encrypt_certificate[*].id
description = "The unique ID of the certificate."
Expand Down
14 changes: 8 additions & 6 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
#Module : Certificate
##----------------------------------------------------------------------------------------------------
#Description : Provides a DigitalOcean Certificate resource that allows you to manage certificates.
##----------------------------------------------------------------------------------------------------
resource "digitalocean_certificate" "custom" {
count = var.enabled && var.enable_certificate && var.custom_certificate == true ? 1 : 0
count = var.enabled && var.custom_certificate == true ? 1 : 0

name = var.certificate_name
type = "custom"
type = var.type
private_key = var.private_key != "" ? file(var.private_key) : null
leaf_certificate = var.leaf_certificate != "" ? file(var.leaf_certificate) : null
certificate_chain = var.certificate_chain != "" ? file(var.certificate_chain) : null
}

#Module : Certificate
##---------------------------------------------------------------------------------------------------
#Description :Provides a DigitalOcean Certificate resource that allows you to manage certificates.
##---------------------------------------------------------------------------------------------------
resource "digitalocean_certificate" "lets_encrypt" {
count = var.enabled && var.enable_certificate && var.custom_certificate == false ? 1 : 0
count = var.enabled && var.custom_certificate == false ? 1 : 0

name = var.certificate_name
type = "lets_encrypt"
type = var.certificate_type
domains = var.domain_names
}
6 changes: 3 additions & 3 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Module : Certificate
#Description :Provides a DigitalOcean Certificate resource that allows you to manage certificates.

##-------------------------------------------------------
## OUTPUT
##-------------------------------------------------------
output "id" {
value = var.custom_certificate ? join("", digitalocean_certificate.custom[*].id) : join("", digitalocean_certificate.lets_encrypt[*].id)
description = "The unique ID of the certificate."
Expand Down
22 changes: 14 additions & 8 deletions varaibles.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
#Module : Certificate
#Description :Provides a DigitalOcean Certificate resource that allows you to manage certificates.
variable "enable_certificate" {
type = bool
default = true
description = "A boolean flag to enable/disable certificate."
}

##-------------------------------------------------------
## variable
##-------------------------------------------------------
variable "custom_certificate" {
type = bool
default = false
Expand Down Expand Up @@ -48,3 +43,14 @@ variable "certificate_chain" {
description = "Path of certificate chain."
}

variable "type" {
type = string
default = "custom"
description = "The type of certificate to provision"
}

variable "certificate_type" {
type = string
default = "lets_encrypt"
description = "The type of certificate to provision"
}

0 comments on commit fab9b6e

Please sign in to comment.