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

azurerm_container_group - allow empty log_type #4013

Merged
merged 2 commits into from
Aug 8, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions azurerm/resource_arm_container_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func resourceArmContainerGroup() *schema.Resource {

"log_type": {
Type: schema.TypeString,
Required: true,
Optional: true,
ForceNew: true,
ValidateFunc: validation.StringInSlice([]string{
string(containerinstance.ContainerInsights),
Expand Down Expand Up @@ -1241,23 +1241,26 @@ func expandContainerGroupDiagnostics(input []interface{}) *containerinstance.Con

workspaceId := analyticsV["workspace_id"].(string)
workspaceKey := analyticsV["workspace_key"].(string)
logType := containerinstance.LogAnalyticsLogType(analyticsV["log_type"].(string))

metadataMap := analyticsV["metadata"].(map[string]interface{})
metadata := make(map[string]*string)
for k, v := range metadataMap {
strValue := v.(string)
metadata[k] = &strValue
logAnalytics := containerinstance.LogAnalytics{
WorkspaceID: utils.String(workspaceId),
WorkspaceKey: utils.String(workspaceKey),
}

return &containerinstance.ContainerGroupDiagnostics{
LogAnalytics: &containerinstance.LogAnalytics{
WorkspaceID: utils.String(workspaceId),
WorkspaceKey: utils.String(workspaceKey),
LogType: logType,
Metadata: metadata,
},
if logType := analyticsV["log_type"].(string); logType != "" {
logAnalytics.LogType = containerinstance.LogAnalyticsLogType(logType)

metadataMap := analyticsV["metadata"].(map[string]interface{})
metadata := make(map[string]*string)
for k, v := range metadataMap {
strValue := v.(string)
metadata[k] = &strValue
}

logAnalytics.Metadata = metadata
tombuildsstuff marked this conversation as resolved.
Show resolved Hide resolved
}

return &containerinstance.ContainerGroupDiagnostics{LogAnalytics: &logAnalytics}
}

func flattenContainerGroupDiagnostics(d *schema.ResourceData, input *containerinstance.ContainerGroupDiagnostics) []interface{} {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/container_group.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ A `image_registry_credential` block supports:

A `log_analytics` block supports:

* `log_type` - (Required) The log type which should be used. Possible values are `ContainerInsights` and `ContainerInstanceLogs`. Changing this forces a new resource to be created.
* `log_type` - (Optional) The log type which should be used. Possible values are `ContainerInsights` and `ContainerInstanceLogs`. Changing this forces a new resource to be created.

* `workspace_id` - (Required) The Workspace ID of the Log Analytics Workspace. Changing this forces a new resource to be created.

Expand Down