Skip to content

Commit

Permalink
Remove deprecations and update docs (#7)
Browse files Browse the repository at this point in the history
* remove the issue_le_cert deprecated parameter

* remove the ssl_automated deprecated parameter

* upd the gcore_cdn_sslcert (Resource) doc

* upd the gcore_cdn_resource (Resource)
 doc
  • Loading branch information
andrei-lukyanchyk authored Apr 6, 2023
1 parent 85f8290 commit 5164bab
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 24 deletions.
5 changes: 3 additions & 2 deletions docs/resources/gcore_cdn_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ resource "gcore_cdn_resource" "cdn_example_com" {
origin_group = gcore_cdn_origingroup.origin_group_1.id
origin_protocol = "MATCH"
secondary_hostnames = ["cdn2.example.com"]
ssl_enabled = true
ssl_data = gcore_cdn_sslcert.lets_encrypt_cert.id
options {
edge_cache_settings {
Expand Down Expand Up @@ -71,13 +74,11 @@ resource "gcore_cdn_resource" "cdn_example_com" {

- `active` (Boolean) The setting allows to enable or disable a CDN Resource
- `description` (String) Custom client description of the resource.
- `issue_le_cert` (Boolean) Generate LE certificate.
- `options` (Block List, Max: 1) Each option in CDN resource settings. Each option added to CDN resource settings should have the following mandatory request fields: enabled, value. (see [below for nested schema](#nestedblock--options))
- `origin` (String) A domain name or IP of your origin source. Specify a port if custom. You can use either 'origin' parameter or 'originGroup' in the resource definition.
- `origin_group` (Number) ID of the Origins Group. Use one of your Origins Group or create a new one. You can use either 'origin' parameter or 'originGroup' in the resource definition.
- `origin_protocol` (String) This option defines the protocol that will be used by CDN servers to request content from an origin source. If not specified, we will use HTTP to connect to an origin server. Possible values are: HTTPS, HTTP, MATCH.
- `secondary_hostnames` (Set of String) List of additional CNAMEs.
- `ssl_automated` (Boolean) generate LE certificate automatically.
- `ssl_data` (Number) Specify the SSL Certificate ID which should be used for the CDN Resource.
- `ssl_enabled` (Boolean) Use HTTPS protocol for content delivery.

Expand Down
27 changes: 27 additions & 0 deletions docs/resources/gcore_cdn_sslcert.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,31 @@ resource "gcore_cdn_sslcert" "cdnopt_cert" {
- `has_related_resources` (Boolean) It shows if the SSL certificate is used by a CDN resource.
- `id` (String) The ID of this resource.

---

## Example Usage (Let's Encrypt certificate)

```terraform
provider gcore {
permanent_api_token = "251$d3361.............1b35f26d8"
}
resource "gcore_cdn_sslcert" "lets_encrypt_cert" {
name = "Test Let's Encrypt certificate"
automated = true
}
```

## Schema

### Required

- `name` (String) Name of the SSL certificate. Must be unique.
- `automated` (Boolean) The way SSL certificate was issued.

### Read-Only

- `has_related_resources` (Boolean) It shows if the SSL certificate is used by a CDN resource.
- `id` (String) The ID of this resource.


4 changes: 2 additions & 2 deletions examples/resources/gcore_cdn_sslcert/resource.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "gcore_cdn_sslcert" "cdnopt_cert" {
private_key = var.private_key
}

resource "gcore_cdn_sslcert" "cdnopt_lets_encrypt_cert" {
name = "Test LE certificate"
resource "gcore_cdn_sslcert" "lets_encrypt_cert" {
name = "Test Let's Encrypt certificate"
automated = true
}
17 changes: 0 additions & 17 deletions gcore/resource_gcore_cdn_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,17 +441,6 @@ func resourceCDNResource() *schema.Resource {
RequiredWith: []string{"ssl_enabled"},
Description: "Specify the SSL Certificate ID which should be used for the CDN Resource.",
},
"ssl_automated": {
Type: schema.TypeBool,
Optional: true,
Description: "generate LE certificate automatically.",
},
"issue_le_cert": {
Type: schema.TypeBool,
Optional: true,
Computed: true,
Description: "Generate LE certificate.",
},
"active": {
Type: schema.TypeBool,
Optional: true,
Expand Down Expand Up @@ -486,11 +475,6 @@ func resourceCDNResourceCreate(ctx context.Context, d *schema.ResourceData, m in
req.OriginProtocol = resources.Protocol(d.Get("origin_protocol").(string))
req.SSlEnabled = d.Get("ssl_enabled").(bool)
req.SSLData = d.Get("ssl_data").(int)
req.SSLAutomated = d.Get("ssl_automated").(bool)

if d.Get("issue_le_cert") != nil {
req.IssueLECert = d.Get("issue_le_cert").(bool)
}

req.Options = listToOptions(d.Get("options").([]interface{}))

Expand Down Expand Up @@ -533,7 +517,6 @@ func resourceCDNResourceRead(ctx context.Context, d *schema.ResourceData, m inte
d.Set("secondary_hostnames", result.SecondaryHostnames)
d.Set("ssl_enabled", result.SSlEnabled)
d.Set("ssl_data", result.SSLData)
d.Set("ssl_automated", result.SSLAutomated)
d.Set("status", result.Status)
d.Set("active", result.Active)
if err := d.Set("options", optionsToList(result.Options)); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions gcore/resource_gcore_cdn_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func resourceCDNRuleCreate(ctx context.Context, d *schema.ResourceData, m interf
req.RuleType = d.Get("rule_type").(int)

if d.Get("weight") != nil {
req.Weight = d.Get("weight").(int)
req.Weight = d.Get("weight").(int)
}

if d.Get("origin_group") != nil && d.Get("origin_group").(int) > 0 {
Expand Down Expand Up @@ -150,8 +150,8 @@ func resourceCDNRuleUpdate(ctx context.Context, d *schema.ResourceData, m interf
req.Rule = d.Get("rule").(string)
req.RuleType = d.Get("rule_type").(int)

if d.Get("weight") != nil {
req.Weight = d.Get("weight").(int)
if d.Get("weight") != nil {
req.Weight = d.Get("weight").(int)
}

if d.Get("origin_group") != nil && d.Get("origin_group").(int) > 0 {
Expand Down

0 comments on commit 5164bab

Please sign in to comment.