diff --git a/docs/data-sources/cdn_distribution.md b/docs/data-sources/cdn_distribution.md index 7d82a8a3..641e9698 100644 --- a/docs/data-sources/cdn_distribution.md +++ b/docs/data-sources/cdn_distribution.md @@ -55,7 +55,7 @@ Read-Only: - `origin_request_headers` (Map of String) The configured origin request headers for the backend - `origin_url` (String) The configured backend type for the distribution -- `type` (String) The configured backend type +- `type` (String) The configured backend type. Supported values are: `http`. diff --git a/docs/resources/cdn_distribution.md b/docs/resources/cdn_distribution.md index 3899834b..2704a1e6 100644 --- a/docs/resources/cdn_distribution.md +++ b/docs/resources/cdn_distribution.md @@ -61,7 +61,7 @@ Required: Required: - `origin_url` (String) The configured backend type for the distribution -- `type` (String) The configured backend type +- `type` (String) The configured backend type. Supported values are: `http`. Optional: diff --git a/stackit/internal/services/cdn/distribution/datasource.go b/stackit/internal/services/cdn/distribution/datasource.go index 0a28a097..1b2fee35 100644 --- a/stackit/internal/services/cdn/distribution/datasource.go +++ b/stackit/internal/services/cdn/distribution/datasource.go @@ -73,6 +73,7 @@ func (r *distributionDataSource) Metadata(_ context.Context, req datasource.Meta } func (r *distributionDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + backendOptions := []string{"http"} resp.Schema = schema.Schema{ MarkdownDescription: features.AddBetaDescription("CDN distribution data source schema."), Description: "CDN distribution data source schema.", @@ -147,7 +148,7 @@ func (r *distributionDataSource) Schema(_ context.Context, _ datasource.SchemaRe Attributes: map[string]schema.Attribute{ "type": schema.StringAttribute{ Computed: true, - Description: schemaDescriptions["config_backend_type"], + Description: schemaDescriptions["config_backend_type"] + utils.SupportedValuesDocumentation(backendOptions), }, "origin_url": schema.StringAttribute{ Computed: true, diff --git a/stackit/internal/services/cdn/distribution/resource.go b/stackit/internal/services/cdn/distribution/resource.go index 1fe028f9..b4125c1a 100644 --- a/stackit/internal/services/cdn/distribution/resource.go +++ b/stackit/internal/services/cdn/distribution/resource.go @@ -8,6 +8,7 @@ import ( "strings" "github.com/google/uuid" + "github.com/hashicorp/terraform-plugin-framework-validators/stringvalidator" "github.com/hashicorp/terraform-plugin-framework/attr" "github.com/hashicorp/terraform-plugin-framework/path" "github.com/hashicorp/terraform-plugin-framework/resource" @@ -24,6 +25,7 @@ import ( "github.com/stackitcloud/stackit-sdk-go/services/cdn/wait" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/core" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/features" + "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/utils" "github.com/stackitcloud/terraform-provider-stackit/stackit/internal/validate" ) @@ -46,7 +48,7 @@ var schemaDescriptions = map[string]string{ "config": "The distribution configuration", "config_backend": "The configured backend for the distribution", "config_regions": "The configured regions where content will be hosted", - "config_backend_type": "The configured backend type", + "config_backend_type": "The configured backend type. ", "config_backend_origin_url": "The configured backend type for the distribution", "config_backend_origin_request_headers": "The configured origin request headers for the backend", "domain_name": "The name of the domain", @@ -142,6 +144,7 @@ func (r *distributionResource) Metadata(_ context.Context, req resource.Metadata } func (r *distributionResource) Schema(_ context.Context, _ resource.SchemaRequest, resp *resource.SchemaResponse) { + backendOptions := []string{"http"} resp.Schema = schema.Schema{ MarkdownDescription: features.AddBetaDescription("CDN distribution data source schema."), Description: "CDN distribution data source schema.", @@ -218,7 +221,8 @@ func (r *distributionResource) Schema(_ context.Context, _ resource.SchemaReques Attributes: map[string]schema.Attribute{ "type": schema.StringAttribute{ Required: true, - Description: schemaDescriptions["config_backend_type"], + Description: schemaDescriptions["config_backend_type"] + utils.SupportedValuesDocumentation(backendOptions), + Validators: []validator.String{stringvalidator.OneOf(backendOptions...)}, }, "origin_url": schema.StringAttribute{ Required: true,