From fdb09a2c1b06a03d0e5408f71e685e82debd5fae Mon Sep 17 00:00:00 2001 From: Kagashino Date: Fri, 17 Sep 2021 19:32:26 +0800 Subject: [PATCH] feat: cdn - support ipv6 access switch --- tencentcloud/resource_tc_cdn_domain.go | 22 ++++++++++++++++++++++ website/docs/r/cdn_domain.html.markdown | 1 + 2 files changed, 23 insertions(+) diff --git a/tencentcloud/resource_tc_cdn_domain.go b/tencentcloud/resource_tc_cdn_domain.go index c6269dfee8..577f231b42 100644 --- a/tencentcloud/resource_tc_cdn_domain.go +++ b/tencentcloud/resource_tc_cdn_domain.go @@ -408,6 +408,13 @@ func resourceTencentCloudCdnDomain() *schema.Resource { ValidateFunc: validateAllowedStringValue(CDN_SWITCH), Description: "Sharding back to source configuration switch. Valid values are `on` and `off`. Default value is `on`.", }, + "ipv6_access_switch": { + Type: schema.TypeString, + Optional: true, + Default: CDN_SWITCH_OFF, + ValidateFunc: validateAllowedStringValue(CDN_SWITCH), + Description: "ipv6 access configuration switch. Only available when area set to `mainland`. Valid values are `on` and `off`. Default value is `off`.", + }, "rule_cache": { Type: schema.TypeList, Optional: true, @@ -602,6 +609,12 @@ func resourceTencentCloudCdnDomainCreate(d *schema.ResourceData, meta interface{ request.RangeOriginPull = &cdn.RangeOriginPull{} request.RangeOriginPull.Switch = helper.String(d.Get("range_origin_switch").(string)) + if v, ok := d.GetOk("ipv6_access_switch"); ok { + request.Ipv6Access = &cdn.Ipv6Access{ + Switch: helper.String(v.(string)), + } + } + // rule_cache if v, ok := d.GetOk("rule_cache"); ok { ruleCache := v.([]interface{}) @@ -863,6 +876,10 @@ func resourceTencentCloudCdnDomainRead(d *schema.ResourceData, meta interface{}) _ = d.Set("create_time", domainConfig.CreateTime) _ = d.Set("cname", domainConfig.Cname) _ = d.Set("range_origin_switch", domainConfig.RangeOriginPull.Switch) + + if domainConfig.Ipv6Access != nil { + _ = d.Set("ipv6_access_switch", domainConfig.Ipv6Access.Switch) + } if *domainConfig.CacheKey.FullUrlCache == CDN_SWITCH_OFF { _ = d.Set("full_url_cache", false) } else { @@ -1041,6 +1058,11 @@ func resourceTencentCloudCdnDomainUpdate(d *schema.ResourceData, meta interface{ request.RangeOriginPull.Switch = helper.String(d.Get("range_origin_switch").(string)) updateAttrs = append(updateAttrs, "range_origin_switch") } + if d.HasChange("ipv6_access_switch") { + request.Ipv6Access = &cdn.Ipv6Access{} + request.Ipv6Access.Switch = helper.String(d.Get("ipv6_access_switch").(string)) + updateAttrs = append(updateAttrs, "ipv6_access_switch") + } if d.HasChange("origin") { updateAttrs = append(updateAttrs, "origin") origins := d.Get("origin").([]interface{}) diff --git a/website/docs/r/cdn_domain.html.markdown b/website/docs/r/cdn_domain.html.markdown index 8d8cbad224..3966c50ab1 100644 --- a/website/docs/r/cdn_domain.html.markdown +++ b/website/docs/r/cdn_domain.html.markdown @@ -144,6 +144,7 @@ The following arguments are supported: * `area` - (Optional) Domain name acceleration region. `mainland`: acceleration inside mainland China, `overseas`: acceleration outside mainland China, `global`: global acceleration. Overseas acceleration service must be enabled to use overseas acceleration and global acceleration. * `full_url_cache` - (Optional) Whether to enable full-path cache. Default value is `true`. * `https_config` - (Optional) HTTPS acceleration configuration. It's a list and consist of at most one item. +* `ipv6_access_switch` - (Optional) ipv6 access configuration switch. Only available when area set to `mainland`. Valid values are `on` and `off`. Default value is `off`. * `project_id` - (Optional) The project CDN belongs to, default to 0. * `range_origin_switch` - (Optional) Sharding back to source configuration switch. Valid values are `on` and `off`. Default value is `on`. * `request_header` - (Optional) Request header configuration. It's a list and consist of at most one item.