Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azure_cognitive_deployment - Changes model.version property from Required to Optional. #24264

Merged
merged 8 commits into from
Jan 23, 2024
Merged
20 changes: 19 additions & 1 deletion internal/services/cognitive/cognitive_deployment_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/hashicorp/go-azure-helpers/lang/response"
"github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/cognitiveservicesaccounts"
"github.com/hashicorp/go-azure-sdk/resource-manager/cognitive/2023-05-01/deployments"
"github.com/hashicorp/terraform-provider-azurerm/helpers/azure"
"github.com/hashicorp/terraform-provider-azurerm/internal/features"
"github.com/hashicorp/terraform-provider-azurerm/internal/locks"
"github.com/hashicorp/terraform-provider-azurerm/internal/sdk"
Expand All @@ -32,6 +33,7 @@ type cognitiveDeploymentModel struct {
type DeploymentModelModel struct {
Format string `tfschema:"format"`
Name string `tfschema:"name"`
Source string `tfschema:"source"`
Version string `tfschema:"version"`
}

Expand Down Expand Up @@ -98,9 +100,15 @@ func (r CognitiveDeploymentResource) Arguments() map[string]*pluginsdk.Schema {
ValidateFunc: validation.StringIsNotEmpty,
},

"source": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as this is a resource id wouldn't it make more sense to have it be

Suggested change
"source": {
"source_resource_id": {

Type: pluginsdk.TypeString,
Optional: true,
ValidateFunc: azure.ValidateResourceID,
},

"version": {
Type: pluginsdk.TypeString,
Required: true,
Optional: true,
},
},
},
Expand Down Expand Up @@ -411,6 +419,10 @@ func expandDeploymentModelModel(inputList []DeploymentModelModel) *deployments.D
output.Name = &input.Name
}

if input.Source != "" {
output.Source = &input.Source
}

if input.Version != "" {
output.Version = &input.Version
}
Expand Down Expand Up @@ -461,6 +473,12 @@ func flattenDeploymentModelModel(input *deployments.DeploymentModel) []Deploymen
}
output.Name = name

source := ""
if input.Source != nil {
source = *input.Source
}
output.Source = source

version := ""
if input.Version != nil {
version = *input.Version
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,21 +142,21 @@ resource "azurerm_cognitive_account" "test" {
func (r CognitiveDeploymentTestResource) basic(data acceptance.TestData) string {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we add a test for the new property?

template := r.template(data, "OpenAI")
return fmt.Sprintf(`


%s

resource "azurerm_cognitive_deployment" "test" {
name = "acctest-cd-%d"
cognitive_account_id = azurerm_cognitive_account.test.id
model {
format = "OpenAI"
name = "text-embedding-ada-002"
version = "2"
format = "OpenAI"
name = "text-embedding-ada-002"
}
scale {
type = "Standard"
}
lifecycle {
ignore_changes = [model.0.version]
}
}
`, template, data.RandomInteger)
}
Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/cognitive_deployment.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ A `model` block supports the following:

* `name` - (Required) The name of the Cognitive Services Account Deployment model. Changing this forces a new resource to be created.

* `version` - (Required) The version of Cognitive Services Account Deployment model.
* `source` - (Optional) Deployment model source ARM resource ID.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is a valid resource here? could we expand on the docs a bit more


* `version` - (Optional) The version of Cognitive Services Account Deployment model. If `version` is not specified, a default version will be assigned. The default version is different for different models and might change when there is new version available for a model.
liuwuliuyun marked this conversation as resolved.
Show resolved Hide resolved

---

Expand Down
Loading