From 86e5d20ec3c989861c232778939c3673720fdf0e Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Mon, 7 Jul 2025 19:22:56 +0800 Subject: [PATCH 1/2] add --- .../resource_tc_teo_acceleration_domain.go | 26 +++++++++++++------ .../resource_tc_teo_acceleration_domain.md | 2 ++ .../r/teo_acceleration_domain.html.markdown | 14 +++++----- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/tencentcloud/services/teo/resource_tc_teo_acceleration_domain.go b/tencentcloud/services/teo/resource_tc_teo_acceleration_domain.go index 12835d0a46..a65667b9ec 100644 --- a/tencentcloud/services/teo/resource_tc_teo_acceleration_domain.go +++ b/tencentcloud/services/teo/resource_tc_teo_acceleration_domain.go @@ -48,27 +48,27 @@ func ResourceTencentCloudTeoAccelerationDomain() *schema.Resource { "origin_type": { Type: schema.TypeString, Required: true, - Description: "The origin type. Values: `IP_DOMAIN`: IPv4/IPv6 address or domain name; `COS`: COS bucket address; `ORIGIN_GROUP`: Origin group; `AWS_S3`: AWS S3 bucket address; `SPACE`: EdgeOne Shield Space.", + Description: "Origin server type, with values: IP_DOMAIN: IPv4, IPv6, or domain name type origin server; COS: Tencent Cloud COS origin server; AWS_S3: AWS S3 origin server; ORIGIN_GROUP: origin server group type origin server; VOD: Video on Demand; SPACE: origin server uninstallation. Currently only available to the allowlist; LB: load balancing. Currently only available to the allowlist.", }, "origin": { Type: schema.TypeString, Required: true, - Description: "The origin address. Enter the origin group ID if `OriginType=ORIGIN_GROUP`.", + Description: "Origin server address, which varies according to the value of OriginType: When OriginType = IP_DOMAIN, fill in an IPv4 address, an IPv6 address, or a domain name; When OriginType = COS, fill in the access domain name of the COS bucket; When OriginType = AWS_S3, fill in the access domain name of the S3 bucket; When OriginType = ORIGIN_GROUP, fill in the origin server group ID; When OriginType = VOD, fill in the VOD application ID; When OriginType = LB, fill in the Cloud Load Balancer instance ID. This feature is currently only available to the allowlist; When OriginType = SPACE, fill in the origin server uninstallation space ID. This feature is currently only available to the allowlist.", }, "backup_origin": { Type: schema.TypeString, Optional: true, - Description: "ID of the secondary origin group (valid when `OriginType=ORIGIN_GROUP`). If it is not specified, it indicates that secondary origins are not used.", + Description: "The ID of the secondary origin group. This parameter is valid only when OriginType is ORIGIN_GROUP. This field indicates the old version capability, which cannot be configured or modified on the control panel after being called. Please submit a ticket if required.", }, "private_access": { Type: schema.TypeString, Optional: true, - Description: "Whether to authenticate access to the private object storage origin (valid when `OriginType=COS/AWS_S3`). Values: `on`: Enable private authentication; `off`: Disable private authentication. If this field is not specified, the default value `off` is used.", + Description: "Whether access to the private Cloud Object Storage origin server is allowed. This parameter is valid only when OriginType is COS or AWS_S3. Valid values: on: Enable private authentication; off: Disable private authentication. If it is not specified, the default value is off.", }, "private_parameters": { Type: schema.TypeList, Optional: true, - Description: "The private authentication parameters. This field is valid when `PrivateAccess=on`.", + Description: "Private authentication parameter. This parameter is valid only when `private_access` is on.", Elem: &schema.Resource{ Schema: map[string]*schema.Schema{ "name": { @@ -88,7 +88,7 @@ func ResourceTencentCloudTeoAccelerationDomain() *schema.Resource { Type: schema.TypeString, Optional: true, Computed: true, - Description: "Customize the back-to-origin HOST header. This parameter is only valid when OriginType=IP_DOMAIN. If OriginType=COS or AWS_S3, the back-to-origin HOST header will be consistent with the origin server domain name. If OriginType=ORIGIN_GROUP, the back-to-origin HOST header follows the configuration in the origin server group. If no configuration is made, the default is the acceleration domain name. If OriginType=VOD or SPACE, there is no need to configure this header. It will take effect according to the corresponding back-to-origin domain name.", + Description: "Custom origin server HOST header. this parameter is valid only when OriginType=IP_DOMAIN.If the OriginType is another type of origin, this parameter does not need to be passed in, otherwise an error will be reported. If OriginType is COS or AWS_S3, the HOST header for origin-pull will remain consistent with the origin server domain name. If OriginType is ORIGIN_GROUP, the HOST header follows the ORIGIN site GROUP configuration. if not configured, it defaults to the acceleration domain name. If OriginType is VOD or SPACE, no configuration is required for this header, and the domain name takes effect based on the corresponding origin.", }, "vod_origin_scope": { Type: schema.TypeString, @@ -174,8 +174,10 @@ func resourceTencentCloudTeoAccelerationDomainCreate(d *schema.ResourceData, met if originInfoMap, ok := helper.InterfacesHeadMap(d, "origin_info"); ok { originInfo := teo.OriginInfo{} + var originType string if v, ok := originInfoMap["origin_type"]; ok { originInfo.OriginType = helper.String(v.(string)) + originType = v.(string) } if v, ok := originInfoMap["origin"]; ok { @@ -207,7 +209,11 @@ func resourceTencentCloudTeoAccelerationDomainCreate(d *schema.ResourceData, met } if v, ok := originInfoMap["host_header"].(string); ok && v != "" { - originInfo.HostHeader = helper.String(v) + if originType == "IP_DOMAIN" { + originInfo.HostHeader = helper.String(v) + } else { + return fmt.Errorf("Only `origin_type` is `IP_DOMAIN` can set `host_header`.") + } } if v, ok := originInfoMap["vod_origin_scope"].(string); ok && v != "" { @@ -458,8 +464,10 @@ func resourceTencentCloudTeoAccelerationDomainUpdate(d *schema.ResourceData, met request.DomainName = helper.String(domainName) if originInfoMap, ok := helper.InterfacesHeadMap(d, "origin_info"); ok { originInfo := teo.OriginInfo{} + var originType string if v, ok := originInfoMap["origin_type"]; ok { originInfo.OriginType = helper.String(v.(string)) + originType = v.(string) } if v, ok := originInfoMap["origin"]; ok { @@ -491,7 +499,9 @@ func resourceTencentCloudTeoAccelerationDomainUpdate(d *schema.ResourceData, met } if v, ok := originInfoMap["host_header"].(string); ok && v != "" { - originInfo.HostHeader = helper.String(v) + if originType == "IP_DOMAIN" { + originInfo.HostHeader = helper.String(v) + } } if v, ok := originInfoMap["vod_origin_scope"].(string); ok && v != "" { diff --git a/tencentcloud/services/teo/resource_tc_teo_acceleration_domain.md b/tencentcloud/services/teo/resource_tc_teo_acceleration_domain.md index a9632f96fc..1651b807ed 100644 --- a/tencentcloud/services/teo/resource_tc_teo_acceleration_domain.md +++ b/tencentcloud/services/teo/resource_tc_teo_acceleration_domain.md @@ -2,6 +2,8 @@ Provides a resource to create a TEO acceleration domain ~> **NOTE:** Before modifying resource content, you need to ensure that the `status` is `online`. +~> **NOTE:** Only `origin_type` is `IP_DOMAIN` can set `host_header`. + Example Usage ```hcl diff --git a/website/docs/r/teo_acceleration_domain.html.markdown b/website/docs/r/teo_acceleration_domain.html.markdown index 0523e405a9..8624f24d10 100644 --- a/website/docs/r/teo_acceleration_domain.html.markdown +++ b/website/docs/r/teo_acceleration_domain.html.markdown @@ -13,6 +13,8 @@ Provides a resource to create a TEO acceleration domain ~> **NOTE:** Before modifying resource content, you need to ensure that the `status` is `online`. +~> **NOTE:** Only `origin_type` is `IP_DOMAIN` can set `host_header`. + ## Example Usage ```hcl @@ -48,12 +50,12 @@ The following arguments are supported: The `origin_info` object supports the following: -* `origin_type` - (Required, String) The origin type. Values: `IP_DOMAIN`: IPv4/IPv6 address or domain name; `COS`: COS bucket address; `ORIGIN_GROUP`: Origin group; `AWS_S3`: AWS S3 bucket address; `SPACE`: EdgeOne Shield Space. -* `origin` - (Required, String) The origin address. Enter the origin group ID if `OriginType=ORIGIN_GROUP`. -* `backup_origin` - (Optional, String) ID of the secondary origin group (valid when `OriginType=ORIGIN_GROUP`). If it is not specified, it indicates that secondary origins are not used. -* `host_header` - (Optional, String) Customize the back-to-origin HOST header. This parameter is only valid when OriginType=IP_DOMAIN. If OriginType=COS or AWS_S3, the back-to-origin HOST header will be consistent with the origin server domain name. If OriginType=ORIGIN_GROUP, the back-to-origin HOST header follows the configuration in the origin server group. If no configuration is made, the default is the acceleration domain name. If OriginType=VOD or SPACE, there is no need to configure this header. It will take effect according to the corresponding back-to-origin domain name. -* `private_access` - (Optional, String) Whether to authenticate access to the private object storage origin (valid when `OriginType=COS/AWS_S3`). Values: `on`: Enable private authentication; `off`: Disable private authentication. If this field is not specified, the default value `off` is used. -* `private_parameters` - (Optional, List) The private authentication parameters. This field is valid when `PrivateAccess=on`. +* `origin_type` - (Required, String) Origin server type, with values: IP_DOMAIN: IPv4, IPv6, or domain name type origin server; COS: Tencent Cloud COS origin server; AWS_S3: AWS S3 origin server; ORIGIN_GROUP: origin server group type origin server; VOD: Video on Demand; SPACE: origin server uninstallation. Currently only available to the allowlist; LB: load balancing. Currently only available to the allowlist. +* `origin` - (Required, String) Origin server address, which varies according to the value of OriginType: When OriginType = IP_DOMAIN, fill in an IPv4 address, an IPv6 address, or a domain name; When OriginType = COS, fill in the access domain name of the COS bucket; When OriginType = AWS_S3, fill in the access domain name of the S3 bucket; When OriginType = ORIGIN_GROUP, fill in the origin server group ID; When OriginType = VOD, fill in the VOD application ID; When OriginType = LB, fill in the Cloud Load Balancer instance ID. This feature is currently only available to the allowlist; When OriginType = SPACE, fill in the origin server uninstallation space ID. This feature is currently only available to the allowlist. +* `backup_origin` - (Optional, String) The ID of the secondary origin group. This parameter is valid only when OriginType is ORIGIN_GROUP. This field indicates the old version capability, which cannot be configured or modified on the control panel after being called. Please submit a ticket if required. +* `host_header` - (Optional, String) Custom origin server HOST header. this parameter is valid only when OriginType=IP_DOMAIN.If the OriginType is another type of origin, this parameter does not need to be passed in, otherwise an error will be reported. If OriginType is COS or AWS_S3, the HOST header for origin-pull will remain consistent with the origin server domain name. If OriginType is ORIGIN_GROUP, the HOST header follows the ORIGIN site GROUP configuration. if not configured, it defaults to the acceleration domain name. If OriginType is VOD or SPACE, no configuration is required for this header, and the domain name takes effect based on the corresponding origin. +* `private_access` - (Optional, String) Whether access to the private Cloud Object Storage origin server is allowed. This parameter is valid only when OriginType is COS or AWS_S3. Valid values: on: Enable private authentication; off: Disable private authentication. If it is not specified, the default value is off. +* `private_parameters` - (Optional, List) Private authentication parameter. This parameter is valid only when `private_access` is on. * `vod_bucket_id` - (Optional, String) VOD bucket ID. This parameter is required when OriginType = VOD and VodOriginScope = bucket. Data source: the storage ID of the bucket in the Cloud VOD Professional Edition application. * `vod_origin_scope` - (Optional, String) The scope of cloud on-demand back-to-source. This parameter is effective when OriginType = VOD. The possible values are: all: all files in the cloud on-demand application corresponding to the current origin station. The default value is all; bucket: files in a specified bucket under the cloud on-demand application corresponding to the current origin station. The bucket is specified by the parameter VodBucketId. From 959106fba320331127aacdca7b0d3deff3095ca9 Mon Sep 17 00:00:00 2001 From: SevenEarth <391613297@qq.com> Date: Mon, 7 Jul 2025 19:25:49 +0800 Subject: [PATCH 2/2] add --- .changelog/3436.txt | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .changelog/3436.txt diff --git a/.changelog/3436.txt b/.changelog/3436.txt new file mode 100644 index 0000000000..5339ffea3e --- /dev/null +++ b/.changelog/3436.txt @@ -0,0 +1,3 @@ +```release-note:enhancement +resource/tencentcloud_teo_acceleration_domain: optmize `host_header` params +```