diff --git a/azurerm/config.go b/azurerm/config.go index b250516e2c47..c466a2766b57 100644 --- a/azurerm/config.go +++ b/azurerm/config.go @@ -16,7 +16,7 @@ import ( "github.com/Azure/azure-sdk-for-go/services/cdn/mgmt/2017-10-12/cdn" "github.com/Azure/azure-sdk-for-go/services/cognitiveservices/mgmt/2017-04-18/cognitiveservices" "github.com/Azure/azure-sdk-for-go/services/compute/mgmt/2018-06-01/compute" - "github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance" + "github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance" "github.com/Azure/azure-sdk-for-go/services/containerregistry/mgmt/2017-10-01/containerregistry" "github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2018-03-31/containerservice" "github.com/Azure/azure-sdk-for-go/services/cosmos-db/mgmt/2015-04-08/documentdb" diff --git a/azurerm/resource_arm_api_management.go b/azurerm/resource_arm_api_management.go index 231ee0429458..399cc505e8c2 100644 --- a/azurerm/resource_arm_api_management.go +++ b/azurerm/resource_arm_api_management.go @@ -581,8 +581,6 @@ func flattenApiManagementHostnameConfigurations(input *[]apimanagement.HostnameC "scm": scmResults, }, } - - return nil } func expandAzureRmApiManagementCertificates(d *schema.ResourceData) *[]apimanagement.CertificateConfiguration { diff --git a/azurerm/resource_arm_container_group.go b/azurerm/resource_arm_container_group.go index 5169f0073c34..20510a804cae 100644 --- a/azurerm/resource_arm_container_group.go +++ b/azurerm/resource_arm_container_group.go @@ -5,7 +5,7 @@ import ( "log" "strings" - "github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance" + "github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance" "github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/validation" "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" @@ -165,14 +165,20 @@ func resourceArmContainerGroup() *schema.Resource { "environment_variables": { Type: schema.TypeMap, - Optional: true, ForceNew: true, + Optional: true, + }, + + "secure_environment_variables": { + Type: schema.TypeMap, + Optional: true, + ForceNew: true, + Sensitive: true, }, "command": { Type: schema.TypeString, Optional: true, - ForceNew: true, Computed: true, Deprecated: "Use `commands` instead.", }, @@ -180,7 +186,6 @@ func resourceArmContainerGroup() *schema.Resource { "commands": { Type: schema.TypeList, Optional: true, - ForceNew: true, Computed: true, Elem: &schema.Schema{Type: schema.TypeString}, }, @@ -366,154 +371,6 @@ func resourceArmContainerGroupDelete(d *schema.ResourceData, meta interface{}) e return nil } -func flattenContainerGroupContainers(d *schema.ResourceData, containers *[]containerinstance.Container, containerGroupPorts *[]containerinstance.Port, containerGroupVolumes *[]containerinstance.Volume) []interface{} { - - containerConfigs := make([]interface{}, 0, len(*containers)) - for _, container := range *containers { - containerConfig := make(map[string]interface{}) - containerConfig["name"] = *container.Name - containerConfig["image"] = *container.Image - - if resources := container.Resources; resources != nil { - if resourceRequests := resources.Requests; resourceRequests != nil { - containerConfig["cpu"] = *resourceRequests.CPU - containerConfig["memory"] = *resourceRequests.MemoryInGB - } - } - - if len(*container.Ports) > 0 { - containerPort := *(*container.Ports)[0].Port - containerConfig["port"] = containerPort - // protocol isn't returned in container config, have to search in container group ports - protocol := "" - if containerGroupPorts != nil { - for _, cgPort := range *containerGroupPorts { - if *cgPort.Port == containerPort { - protocol = string(cgPort.Protocol) - } - } - } - if protocol != "" { - containerConfig["protocol"] = protocol - } - } - - if container.EnvironmentVariables != nil { - if len(*container.EnvironmentVariables) > 0 { - containerConfig["environment_variables"] = flattenContainerEnvironmentVariables(container.EnvironmentVariables) - } - } - - commands := make([]string, 0) - if command := container.Command; command != nil { - containerConfig["command"] = strings.Join(*command, " ") - - for _, v := range *command { - commands = append(commands, v) - } - } - containerConfig["commands"] = commands - - if containerGroupVolumes != nil && container.VolumeMounts != nil { - // Also pass in the container volume config from schema - var containerVolumesConfig *[]interface{} - containersConfigRaw := d.Get("container").([]interface{}) - for _, containerConfigRaw := range containersConfigRaw { - data := containerConfigRaw.(map[string]interface{}) - nameRaw := data["name"].(string) - if nameRaw == *container.Name { - // found container config for current container - // extract volume mounts from config - if v, ok := data["volume"]; ok { - containerVolumesRaw := v.([]interface{}) - containerVolumesConfig = &containerVolumesRaw - } - } - } - containerConfig["volume"] = flattenContainerVolumes(container.VolumeMounts, containerGroupVolumes, containerVolumesConfig) - } - - containerConfigs = append(containerConfigs, containerConfig) - } - - return containerConfigs -} - -func flattenContainerEnvironmentVariables(input *[]containerinstance.EnvironmentVariable) map[string]interface{} { - output := make(map[string]interface{}) - if input == nil { - return output - } - - for _, envVar := range *input { - if envVar.Name != nil && envVar.Value != nil { - output[*envVar.Name] = *envVar.Value - } - } - - return output -} - -func flattenContainerVolumes(volumeMounts *[]containerinstance.VolumeMount, containerGroupVolumes *[]containerinstance.Volume, containerVolumesConfig *[]interface{}) []interface{} { - volumeConfigs := make([]interface{}, 0) - - if volumeMounts == nil { - return volumeConfigs - } - - for _, vm := range *volumeMounts { - volumeConfig := make(map[string]interface{}) - if vm.Name != nil { - volumeConfig["name"] = *vm.Name - } - if vm.MountPath != nil { - volumeConfig["mount_path"] = *vm.MountPath - } - if vm.ReadOnly != nil { - volumeConfig["read_only"] = *vm.ReadOnly - } - - // find corresponding volume in container group volumes - // and use the data - if containerGroupVolumes != nil { - for _, cgv := range *containerGroupVolumes { - if cgv.Name == nil || vm.Name == nil { - continue - } - - if *cgv.Name == *vm.Name { - if file := cgv.AzureFile; file != nil { - if file.ShareName != nil { - volumeConfig["share_name"] = *file.ShareName - } - if file.StorageAccountName != nil { - volumeConfig["storage_account_name"] = *file.StorageAccountName - } - // skip storage_account_key, is always nil - } - } - } - } - - // find corresponding volume in config - // and use the data - if containerVolumesConfig != nil { - for _, cvr := range *containerVolumesConfig { - cv := cvr.(map[string]interface{}) - rawName := cv["name"].(string) - if vm.Name != nil && *vm.Name == rawName { - storageAccountKey := cv["storage_account_key"].(string) - volumeConfig["storage_account_key"] = storageAccountKey - } - } - } - - volumeConfigs = append(volumeConfigs, volumeConfig) - } - - return volumeConfigs -} - func expandContainerGroupContainers(d *schema.ResourceData) (*[]containerinstance.Container, *[]containerinstance.Port, *[]containerinstance.Volume) { containersConfig := d.Get("container").([]interface{}) containers := make([]containerinstance.Container, 0) @@ -564,10 +421,26 @@ func expandContainerGroupContainers(d *schema.ResourceData) (*[]containerinstanc containerGroupPorts = append(containerGroupPorts, containerGroupPort) } + // Set both sensitive and non-secure environment variables + var envVars *[]containerinstance.EnvironmentVariable + var secEnvVars *[]containerinstance.EnvironmentVariable + + // Expand environment_variables into slice if v, ok := data["environment_variables"]; ok { - container.EnvironmentVariables = expandContainerEnvironmentVariables(v) + envVars = expandContainerEnvironmentVariables(v, false) + } + + // Expand secure_environment_variables into slice + if v, ok := data["secure_environment_variables"]; ok { + secEnvVars = expandContainerEnvironmentVariables(v, true) } + // Combine environment variabel slices + *envVars = append(*envVars, *secEnvVars...) + + // Set both secure and non secure environment variables + container.EnvironmentVariables = envVars + if v, ok := data["commands"]; ok { c := v.([]interface{}) command := make([]string, 0) @@ -599,18 +472,33 @@ func expandContainerGroupContainers(d *schema.ResourceData) (*[]containerinstanc return &containers, &containerGroupPorts, &containerGroupVolumes } -func expandContainerEnvironmentVariables(input interface{}) *[]containerinstance.EnvironmentVariable { +func expandContainerEnvironmentVariables(input interface{}, secure bool) *[]containerinstance.EnvironmentVariable { + envVars := input.(map[string]interface{}) - output := make([]containerinstance.EnvironmentVariable, 0) + output := make([]containerinstance.EnvironmentVariable, 0, len(envVars)) + + if secure == true { + + for k, v := range envVars { + ev := containerinstance.EnvironmentVariable{ + Name: utils.String(k), + SecureValue: utils.String(v.(string)), + } - for k, v := range envVars { - ev := containerinstance.EnvironmentVariable{ - Name: utils.String(k), - Value: utils.String(v.(string)), + output = append(output, ev) } - output = append(output, ev) - } + } else { + + for k, v := range envVars { + ev := containerinstance.EnvironmentVariable{ + Name: utils.String(k), + Value: utils.String(v.(string)), + } + + output = append(output, ev) + } + } return &output } @@ -635,6 +523,50 @@ func expandContainerImageRegistryCredentials(d *schema.ResourceData) *[]containe return &output } +func expandContainerVolumes(input interface{}) (*[]containerinstance.VolumeMount, *[]containerinstance.Volume) { + volumesRaw := input.([]interface{}) + + if len(volumesRaw) == 0 { + return nil, nil + } + + volumeMounts := make([]containerinstance.VolumeMount, 0) + containerGroupVolumes := make([]containerinstance.Volume, 0) + + for _, volumeRaw := range volumesRaw { + volumeConfig := volumeRaw.(map[string]interface{}) + + name := volumeConfig["name"].(string) + mountPath := volumeConfig["mount_path"].(string) + readOnly := volumeConfig["read_only"].(bool) + shareName := volumeConfig["share_name"].(string) + storageAccountName := volumeConfig["storage_account_name"].(string) + storageAccountKey := volumeConfig["storage_account_key"].(string) + + vm := containerinstance.VolumeMount{ + Name: utils.String(name), + MountPath: utils.String(mountPath), + ReadOnly: utils.Bool(readOnly), + } + + volumeMounts = append(volumeMounts, vm) + + cv := containerinstance.Volume{ + Name: utils.String(name), + AzureFile: &containerinstance.AzureFileVolume{ + ShareName: utils.String(shareName), + ReadOnly: utils.Bool(readOnly), + StorageAccountName: utils.String(storageAccountName), + StorageAccountKey: utils.String(storageAccountKey), + }, + } + + containerGroupVolumes = append(containerGroupVolumes, cv) + } + + return &volumeMounts, &containerGroupVolumes +} + func flattenContainerImageRegistryCredentials(d *schema.ResourceData, input *[]containerinstance.ImageRegistryCredential) []interface{} { if input == nil { return nil @@ -666,46 +598,192 @@ func flattenContainerImageRegistryCredentials(d *schema.ResourceData, input *[]c return output } -func expandContainerVolumes(input interface{}) (*[]containerinstance.VolumeMount, *[]containerinstance.Volume) { - volumesRaw := input.([]interface{}) +func flattenContainerGroupContainers(d *schema.ResourceData, containers *[]containerinstance.Container, containerGroupPorts *[]containerinstance.Port, containerGroupVolumes *[]containerinstance.Volume) []interface{} { + + //map old container names to index so we can look up things up + nameIndexMap := map[string]int{} + for i, c := range d.Get("container").([]interface{}) { + cfg := c.(map[string]interface{}) + nameIndexMap[cfg["name"].(string)] = i - if len(volumesRaw) == 0 { - return nil, nil } - volumeMounts := make([]containerinstance.VolumeMount, 0) - containerGroupVolumes := make([]containerinstance.Volume, 0) + containerCfg := make([]interface{}, 0, len(*containers)) + for _, container := range *containers { - for _, volumeRaw := range volumesRaw { - volumeConfig := volumeRaw.(map[string]interface{}) + //TODO fix this crash point + name := *container.Name - name := volumeConfig["name"].(string) - mountPath := volumeConfig["mount_path"].(string) - readOnly := volumeConfig["read_only"].(bool) - shareName := volumeConfig["share_name"].(string) - storageAccountName := volumeConfig["storage_account_name"].(string) - storageAccountKey := volumeConfig["storage_account_key"].(string) + //get index from name + index := nameIndexMap[name] - vm := containerinstance.VolumeMount{ - Name: utils.String(name), - MountPath: utils.String(mountPath), - ReadOnly: utils.Bool(readOnly), + containerConfig := make(map[string]interface{}) + containerConfig["name"] = name + + if v := container.Image; v != nil { + containerConfig["image"] = *v } - volumeMounts = append(volumeMounts, vm) + if resources := container.Resources; resources != nil { + if resourceRequests := resources.Requests; resourceRequests != nil { + if v := resourceRequests.CPU; v != nil { + containerConfig["cpu"] = *v + } + if v := resourceRequests.MemoryInGB; v != nil { + containerConfig["memory"] = *v + } + } + } - cv := containerinstance.Volume{ - Name: utils.String(name), - AzureFile: &containerinstance.AzureFileVolume{ - ShareName: utils.String(shareName), - ReadOnly: utils.Bool(readOnly), - StorageAccountName: utils.String(storageAccountName), - StorageAccountKey: utils.String(storageAccountKey), - }, + if len(*container.Ports) > 0 { + containerPort := *(*container.Ports)[0].Port + containerConfig["port"] = containerPort + // protocol isn't returned in container config, have to search in container group ports + protocol := "" + if containerGroupPorts != nil { + for _, cgPort := range *containerGroupPorts { + if *cgPort.Port == containerPort { + protocol = string(cgPort.Protocol) + } + } + } + if protocol != "" { + containerConfig["protocol"] = protocol + } } - containerGroupVolumes = append(containerGroupVolumes, cv) + if container.EnvironmentVariables != nil { + if len(*container.EnvironmentVariables) > 0 { + containerConfig["environment_variables"] = flattenContainerEnvironmentVariables(container.EnvironmentVariables, false, d, index) + } + } + + if container.EnvironmentVariables != nil { + if len(*container.EnvironmentVariables) > 0 { + containerConfig["secure_environment_variables"] = flattenContainerEnvironmentVariables(container.EnvironmentVariables, true, d, index) + } + } + + commands := make([]string, 0) + if command := container.Command; command != nil { + containerConfig["command"] = strings.Join(*command, " ") + + for _, v := range *command { + commands = append(commands, v) + } + } + containerConfig["commands"] = commands + + if containerGroupVolumes != nil && container.VolumeMounts != nil { + // Also pass in the container volume config from schema + var containerVolumesConfig *[]interface{} + containersConfigRaw := d.Get("container").([]interface{}) + for _, containerConfigRaw := range containersConfigRaw { + data := containerConfigRaw.(map[string]interface{}) + nameRaw := data["name"].(string) + if nameRaw == *container.Name { + // found container config for current container + // extract volume mounts from config + if v, ok := data["volume"]; ok { + containerVolumesRaw := v.([]interface{}) + containerVolumesConfig = &containerVolumesRaw + } + } + } + containerConfig["volume"] = flattenContainerVolumes(container.VolumeMounts, containerGroupVolumes, containerVolumesConfig) + } + + containerCfg = append(containerCfg, containerConfig) } - return &volumeMounts, &containerGroupVolumes + return containerCfg +} + +func flattenContainerEnvironmentVariables(input *[]containerinstance.EnvironmentVariable, isSecure bool, d *schema.ResourceData, oldContainerIndex int) map[string]interface{} { + output := make(map[string]interface{}) + + if input == nil { + return output + } + + if isSecure { + for _, envVar := range *input { + + if envVar.Name != nil && envVar.Value == nil { + if v, ok := d.GetOk(fmt.Sprintf("container.%d.secure_environment_variables.%s", oldContainerIndex, *envVar.Name)); ok { + log.Printf("[DEBUG] SECURE : Name: %s - Value: %s", *envVar.Name, v.(string)) + output[*envVar.Name] = v.(string) + } + } + } + } else { + for _, envVar := range *input { + if envVar.Name != nil && envVar.Value != nil { + log.Printf("[DEBUG] NOT SECURE: Name: %s - Value: %s", *envVar.Name, *envVar.Value) + output[*envVar.Name] = *envVar.Value + } + } + } + + return output +} + +func flattenContainerVolumes(volumeMounts *[]containerinstance.VolumeMount, containerGroupVolumes *[]containerinstance.Volume, containerVolumesConfig *[]interface{}) []interface{} { + volumeConfigs := make([]interface{}, 0) + + if volumeMounts == nil { + return volumeConfigs + } + + for _, vm := range *volumeMounts { + volumeConfig := make(map[string]interface{}) + if vm.Name != nil { + volumeConfig["name"] = *vm.Name + } + if vm.MountPath != nil { + volumeConfig["mount_path"] = *vm.MountPath + } + if vm.ReadOnly != nil { + volumeConfig["read_only"] = *vm.ReadOnly + } + + // find corresponding volume in container group volumes + // and use the data + if containerGroupVolumes != nil { + for _, cgv := range *containerGroupVolumes { + if cgv.Name == nil || vm.Name == nil { + continue + } + + if *cgv.Name == *vm.Name { + if file := cgv.AzureFile; file != nil { + if file.ShareName != nil { + volumeConfig["share_name"] = *file.ShareName + } + if file.StorageAccountName != nil { + volumeConfig["storage_account_name"] = *file.StorageAccountName + } + // skip storage_account_key, is always nil + } + } + } + } + + // find corresponding volume in config + // and use the data + if containerVolumesConfig != nil { + for _, cvr := range *containerVolumesConfig { + cv := cvr.(map[string]interface{}) + rawName := cv["name"].(string) + if vm.Name != nil && *vm.Name == rawName { + storageAccountKey := cv["storage_account_key"].(string) + volumeConfig["storage_account_key"] = storageAccountKey + } + } + } + + volumeConfigs = append(volumeConfigs, volumeConfig) + } + + return volumeConfigs } diff --git a/azurerm/resource_arm_container_group_test.go b/azurerm/resource_arm_container_group_test.go index dc693c0bf967..ef7fa1b4c0ec 100644 --- a/azurerm/resource_arm_container_group_test.go +++ b/azurerm/resource_arm_container_group_test.go @@ -173,6 +173,9 @@ func TestAccAzureRMContainerGroup_linuxComplete(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.%", "2"), resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.foo", "bar"), resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.foo1", "bar1"), + resource.TestCheckResourceAttr(resourceName, "container.0.secure_environment_variables.%", "2"), + resource.TestCheckResourceAttr(resourceName, "container.0.secure_environment_variables.secureFoo", "secureBar"), + resource.TestCheckResourceAttr(resourceName, "container.0.secure_environment_variables.secureFoo1", "secureBar1"), resource.TestCheckResourceAttr(resourceName, "container.0.volume.#", "1"), resource.TestCheckResourceAttr(resourceName, "container.0.volume.0.mount_path", "/aci/logs"), resource.TestCheckResourceAttr(resourceName, "container.0.volume.0.name", "logs"), @@ -187,6 +190,9 @@ func TestAccAzureRMContainerGroup_linuxComplete(t *testing.T) { ImportStateVerify: true, ImportStateVerifyIgnore: []string{ "container.0.volume.0.storage_account_key", + "container.0.secure_environment_variables.%", + "container.0.secure_environment_variables.secureFoo", + "container.0.secure_environment_variables.secureFoo1", }, }, }, @@ -245,6 +251,9 @@ func TestAccAzureRMContainerGroup_windowsComplete(t *testing.T) { resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.%", "2"), resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.foo", "bar"), resource.TestCheckResourceAttr(resourceName, "container.0.environment_variables.foo1", "bar1"), + resource.TestCheckResourceAttr(resourceName, "container.0.secure_environment_variables.%", "2"), + resource.TestCheckResourceAttr(resourceName, "container.0.secure_environment_variables.secureFoo", "secureBar"), + resource.TestCheckResourceAttr(resourceName, "container.0.secure_environment_variables.secureFoo1", "secureBar1"), resource.TestCheckResourceAttr(resourceName, "os_type", "Windows"), resource.TestCheckResourceAttr(resourceName, "restart_policy", "Never"), ), @@ -253,6 +262,11 @@ func TestAccAzureRMContainerGroup_windowsComplete(t *testing.T) { ResourceName: resourceName, ImportState: true, ImportStateVerify: true, + ImportStateVerifyIgnore: []string{ + "container.0.secure_environment_variables.%", + "container.0.secure_environment_variables.secureFoo", + "container.0.secure_environment_variables.secureFoo1", + }, }, }, }) @@ -308,7 +322,7 @@ resource "azurerm_container_group" "test" { memory = "0.5" port = "80" } - + image_registry_credential { server = "hub.docker.com" username = "yourusername" @@ -356,7 +370,7 @@ resource "azurerm_container_group" "test" { memory = "0.5" port = "80" } - + image_registry_credential { server = "hub.docker.com" username = "updatedusername" @@ -466,9 +480,15 @@ resource "azurerm_container_group" "test" { port = "80" environment_variables { - "foo" = "bar" - "foo1" = "bar1" + "foo" = "bar" + "foo1" = "bar1" } + + secure_environment_variables { + "secureFoo" = "secureBar" + "secureFoo1" = "secureBar1" + } + commands = ["cmd.exe", "echo", "hi"] } @@ -522,18 +542,23 @@ resource "azurerm_container_group" "test" { protocol = "TCP" volume { - name = "logs" - mount_path = "/aci/logs" - read_only = false - share_name = "${azurerm_storage_share.test.name}" + name = "logs" + mount_path = "/aci/logs" + read_only = false + share_name = "${azurerm_storage_share.test.name}" - storage_account_name = "${azurerm_storage_account.test.name}" - storage_account_key = "${azurerm_storage_account.test.primary_access_key}" + storage_account_name = "${azurerm_storage_account.test.name}" + storage_account_key = "${azurerm_storage_account.test.primary_access_key}" } environment_variables { - "foo" = "bar" - "foo1" = "bar1" + "foo" = "bar" + "foo1" = "bar1" + } + + secure_environment_variables { + "secureFoo" = "secureBar" + "secureFoo1" = "secureBar1" } commands = ["/bin/bash", "-c", "ls"] diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/containerlogs.go b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/containerlogs.go deleted file mode 100644 index 0b975f92862b..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/containerlogs.go +++ /dev/null @@ -1,114 +0,0 @@ -package containerinstance - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// ContainerLogsClient is the client for the ContainerLogs methods of the Containerinstance service. -type ContainerLogsClient struct { - BaseClient -} - -// NewContainerLogsClient creates an instance of the ContainerLogsClient client. -func NewContainerLogsClient(subscriptionID string) ContainerLogsClient { - return NewContainerLogsClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewContainerLogsClientWithBaseURI creates an instance of the ContainerLogsClient client. -func NewContainerLogsClientWithBaseURI(baseURI string, subscriptionID string) ContainerLogsClient { - return ContainerLogsClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// List get the logs for a specified container instance in a specified resource group and container group. -// Parameters: -// resourceGroupName - the name of the resource group. -// containerGroupName - the name of the container group. -// containerName - the name of the container instance. -// tail - the number of lines to show from the tail of the container instance log. If not provided, all -// available logs are shown up to 4mb. -func (client ContainerLogsClient) List(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, tail *int32) (result Logs, err error) { - req, err := client.ListPreparer(ctx, resourceGroupName, containerGroupName, containerName, tail) - if err != nil { - err = autorest.NewErrorWithError(err, "containerinstance.ContainerLogsClient", "List", nil, "Failure preparing request") - return - } - - resp, err := client.ListSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerinstance.ContainerLogsClient", "List", resp, "Failure sending request") - return - } - - result, err = client.ListResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerinstance.ContainerLogsClient", "List", resp, "Failure responding to request") - } - - return -} - -// ListPreparer prepares the List request. -func (client ContainerLogsClient) ListPreparer(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, tail *int32) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerGroupName": autorest.Encode("path", containerGroupName), - "containerName": autorest.Encode("path", containerName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-04-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - if tail != nil { - queryParameters["tail"] = autorest.Encode("query", *tail) - } - - preparer := autorest.CreatePreparer( - autorest.AsGet(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs", pathParameters), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// ListSender sends the List request. The method will close the -// http.Response Body if it receives an error. -func (client ContainerLogsClient) ListSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// ListResponder handles the response to the List request. The method always -// closes the http.Response Body. -func (client ContainerLogsClient) ListResponder(resp *http.Response) (result Logs, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/startcontainer.go b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/startcontainer.go deleted file mode 100644 index 2a4a4c55017d..000000000000 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/startcontainer.go +++ /dev/null @@ -1,113 +0,0 @@ -package containerinstance - -// Copyright (c) Microsoft and contributors. All rights reserved. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// -// See the License for the specific language governing permissions and -// limitations under the License. -// -// Code generated by Microsoft (R) AutoRest Code Generator. -// Changes may cause incorrect behavior and will be lost if the code is regenerated. - -import ( - "context" - "github.com/Azure/go-autorest/autorest" - "github.com/Azure/go-autorest/autorest/azure" - "net/http" -) - -// StartContainerClient is the client for the StartContainer methods of the Containerinstance service. -type StartContainerClient struct { - BaseClient -} - -// NewStartContainerClient creates an instance of the StartContainerClient client. -func NewStartContainerClient(subscriptionID string) StartContainerClient { - return NewStartContainerClientWithBaseURI(DefaultBaseURI, subscriptionID) -} - -// NewStartContainerClientWithBaseURI creates an instance of the StartContainerClient client. -func NewStartContainerClientWithBaseURI(baseURI string, subscriptionID string) StartContainerClient { - return StartContainerClient{NewWithBaseURI(baseURI, subscriptionID)} -} - -// LaunchExec starts the exec command for a specified container instance in a specified resource group and container -// group. -// Parameters: -// resourceGroupName - the name of the resource group. -// containerGroupName - the name of the container group. -// containerName - the name of the container instance. -// containerExecRequest - the request for the exec command. -func (client StartContainerClient) LaunchExec(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest) (result ContainerExecResponse, err error) { - req, err := client.LaunchExecPreparer(ctx, resourceGroupName, containerGroupName, containerName, containerExecRequest) - if err != nil { - err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "LaunchExec", nil, "Failure preparing request") - return - } - - resp, err := client.LaunchExecSender(req) - if err != nil { - result.Response = autorest.Response{Response: resp} - err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "LaunchExec", resp, "Failure sending request") - return - } - - result, err = client.LaunchExecResponder(resp) - if err != nil { - err = autorest.NewErrorWithError(err, "containerinstance.StartContainerClient", "LaunchExec", resp, "Failure responding to request") - } - - return -} - -// LaunchExecPreparer prepares the LaunchExec request. -func (client StartContainerClient) LaunchExecPreparer(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest) (*http.Request, error) { - pathParameters := map[string]interface{}{ - "containerGroupName": autorest.Encode("path", containerGroupName), - "containerName": autorest.Encode("path", containerName), - "resourceGroupName": autorest.Encode("path", resourceGroupName), - "subscriptionId": autorest.Encode("path", client.SubscriptionID), - } - - const APIVersion = "2018-04-01" - queryParameters := map[string]interface{}{ - "api-version": APIVersion, - } - - preparer := autorest.CreatePreparer( - autorest.AsContentType("application/json; charset=utf-8"), - autorest.AsPost(), - autorest.WithBaseURL(client.BaseURI), - autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec", pathParameters), - autorest.WithJSON(containerExecRequest), - autorest.WithQueryParameters(queryParameters)) - return preparer.Prepare((&http.Request{}).WithContext(ctx)) -} - -// LaunchExecSender sends the LaunchExec request. The method will close the -// http.Response Body if it receives an error. -func (client StartContainerClient) LaunchExecSender(req *http.Request) (*http.Response, error) { - return autorest.SendWithSender(client, req, - azure.DoRetryWithRegistration(client.Client)) -} - -// LaunchExecResponder handles the response to the LaunchExec request. The method always -// closes the http.Response Body. -func (client StartContainerClient) LaunchExecResponder(resp *http.Response) (result ContainerExecResponse, err error) { - err = autorest.Respond( - resp, - client.ByInspecting(), - azure.WithErrorUnlessStatusCode(http.StatusOK), - autorest.ByUnmarshallingJSON(&result), - autorest.ByClosing()) - result.Response = autorest.Response{Response: resp} - return -} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/client.go b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/client.go similarity index 97% rename from vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/client.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/client.go index b494c2a07bfa..d52e3559bc40 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/client.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/client.go @@ -1,4 +1,4 @@ -// Package containerinstance implements the Azure ARM Containerinstance service API version 2018-04-01. +// Package containerinstance implements the Azure ARM Containerinstance service API version 2018-06-01. // // package containerinstance diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/container.go b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/container.go new file mode 100644 index 000000000000..6f6aa6b38ac8 --- /dev/null +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/container.go @@ -0,0 +1,187 @@ +package containerinstance + +// Copyright (c) Microsoft and contributors. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// +// See the License for the specific language governing permissions and +// limitations under the License. +// +// Code generated by Microsoft (R) AutoRest Code Generator. +// Changes may cause incorrect behavior and will be lost if the code is regenerated. + +import ( + "context" + "github.com/Azure/go-autorest/autorest" + "github.com/Azure/go-autorest/autorest/azure" + "net/http" +) + +// ContainerClient is the client for the Container methods of the Containerinstance service. +type ContainerClient struct { + BaseClient +} + +// NewContainerClient creates an instance of the ContainerClient client. +func NewContainerClient(subscriptionID string) ContainerClient { + return NewContainerClientWithBaseURI(DefaultBaseURI, subscriptionID) +} + +// NewContainerClientWithBaseURI creates an instance of the ContainerClient client. +func NewContainerClientWithBaseURI(baseURI string, subscriptionID string) ContainerClient { + return ContainerClient{NewWithBaseURI(baseURI, subscriptionID)} +} + +// ExecuteCommand executes a command for a specific container instance in a specified resource group and container +// group. +// Parameters: +// resourceGroupName - the name of the resource group. +// containerGroupName - the name of the container group. +// containerName - the name of the container instance. +// containerExecRequest - the request for the exec command. +func (client ContainerClient) ExecuteCommand(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest) (result ContainerExecResponse, err error) { + req, err := client.ExecuteCommandPreparer(ctx, resourceGroupName, containerGroupName, containerName, containerExecRequest) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerClient", "ExecuteCommand", nil, "Failure preparing request") + return + } + + resp, err := client.ExecuteCommandSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.ContainerClient", "ExecuteCommand", resp, "Failure sending request") + return + } + + result, err = client.ExecuteCommandResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerClient", "ExecuteCommand", resp, "Failure responding to request") + } + + return +} + +// ExecuteCommandPreparer prepares the ExecuteCommand request. +func (client ContainerClient) ExecuteCommandPreparer(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, containerExecRequest ContainerExecRequest) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "containerGroupName": autorest.Encode("path", containerGroupName), + "containerName": autorest.Encode("path", containerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsContentType("application/json; charset=utf-8"), + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/exec", pathParameters), + autorest.WithJSON(containerExecRequest), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ExecuteCommandSender sends the ExecuteCommand request. The method will close the +// http.Response Body if it receives an error. +func (client ContainerClient) ExecuteCommandSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ExecuteCommandResponder handles the response to the ExecuteCommand request. The method always +// closes the http.Response Body. +func (client ContainerClient) ExecuteCommandResponder(resp *http.Response) (result ContainerExecResponse, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} + +// ListLogs get the logs for a specified container instance in a specified resource group and container group. +// Parameters: +// resourceGroupName - the name of the resource group. +// containerGroupName - the name of the container group. +// containerName - the name of the container instance. +// tail - the number of lines to show from the tail of the container instance log. If not provided, all +// available logs are shown up to 4mb. +func (client ContainerClient) ListLogs(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, tail *int32) (result Logs, err error) { + req, err := client.ListLogsPreparer(ctx, resourceGroupName, containerGroupName, containerName, tail) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerClient", "ListLogs", nil, "Failure preparing request") + return + } + + resp, err := client.ListLogsSender(req) + if err != nil { + result.Response = autorest.Response{Response: resp} + err = autorest.NewErrorWithError(err, "containerinstance.ContainerClient", "ListLogs", resp, "Failure sending request") + return + } + + result, err = client.ListLogsResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerClient", "ListLogs", resp, "Failure responding to request") + } + + return +} + +// ListLogsPreparer prepares the ListLogs request. +func (client ContainerClient) ListLogsPreparer(ctx context.Context, resourceGroupName string, containerGroupName string, containerName string, tail *int32) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "containerGroupName": autorest.Encode("path", containerGroupName), + "containerName": autorest.Encode("path", containerName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + if tail != nil { + queryParameters["tail"] = autorest.Encode("query", *tail) + } + + preparer := autorest.CreatePreparer( + autorest.AsGet(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/containers/{containerName}/logs", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// ListLogsSender sends the ListLogs request. The method will close the +// http.Response Body if it receives an error. +func (client ContainerClient) ListLogsSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// ListLogsResponder handles the response to the ListLogs request. The method always +// closes the http.Response Body. +func (client ContainerClient) ListLogsResponder(resp *http.Response) (result Logs, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK), + autorest.ByUnmarshallingJSON(&result), + autorest.ByClosing()) + result.Response = autorest.Response{Response: resp} + return +} diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/containergroups.go b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/containergroups.go similarity index 78% rename from vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/containergroups.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/containergroups.go index aad2a5013ee7..015499c7d414 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/containergroups.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/containergroups.go @@ -54,6 +54,12 @@ func (client ContainerGroupsClient) CreateOrUpdate(ctx context.Context, resource Chain: []validation.Constraint{{Target: "containerGroup.ContainerGroupProperties.IPAddress.Ports", Name: validation.Null, Rule: true, Chain: nil}, {Target: "containerGroup.ContainerGroupProperties.IPAddress.Type", Name: validation.Null, Rule: true, Chain: nil}, }}, + {Target: "containerGroup.ContainerGroupProperties.Diagnostics", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "containerGroup.ContainerGroupProperties.Diagnostics.LogAnalytics", Name: validation.Null, Rule: false, + Chain: []validation.Constraint{{Target: "containerGroup.ContainerGroupProperties.Diagnostics.LogAnalytics.WorkspaceID", Name: validation.Null, Rule: true, Chain: nil}, + {Target: "containerGroup.ContainerGroupProperties.Diagnostics.LogAnalytics.WorkspaceKey", Name: validation.Null, Rule: true, Chain: nil}, + }}, + }}, }}}}}); err != nil { return result, validation.NewError("containerinstance.ContainerGroupsClient", "CreateOrUpdate", err.Error()) } @@ -81,7 +87,7 @@ func (client ContainerGroupsClient) CreateOrUpdatePreparer(ctx context.Context, "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-04-01" + const APIVersion = "2018-06-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -161,7 +167,7 @@ func (client ContainerGroupsClient) DeletePreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-04-01" + const APIVersion = "2018-06-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -230,7 +236,7 @@ func (client ContainerGroupsClient) GetPreparer(ctx context.Context, resourceGro "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-04-01" + const APIVersion = "2018-06-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -295,7 +301,7 @@ func (client ContainerGroupsClient) ListPreparer(ctx context.Context) (*http.Req "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-04-01" + const APIVersion = "2018-06-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -390,7 +396,7 @@ func (client ContainerGroupsClient) ListByResourceGroupPreparer(ctx context.Cont "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-04-01" + const APIVersion = "2018-06-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } @@ -450,6 +456,143 @@ func (client ContainerGroupsClient) ListByResourceGroupComplete(ctx context.Cont return } +// Restart restarts all containers in a contaienr group in place. If container image has updates, new image will be +// downloaded. +// Parameters: +// resourceGroupName - the name of the resource group. +// containerGroupName - the name of the container group. +func (client ContainerGroupsClient) Restart(ctx context.Context, resourceGroupName string, containerGroupName string) (result ContainerGroupsRestartFuture, err error) { + req, err := client.RestartPreparer(ctx, resourceGroupName, containerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Restart", nil, "Failure preparing request") + return + } + + result, err = client.RestartSender(req) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Restart", result.Response(), "Failure sending request") + return + } + + return +} + +// RestartPreparer prepares the Restart request. +func (client ContainerGroupsClient) RestartPreparer(ctx context.Context, resourceGroupName string, containerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "containerGroupName": autorest.Encode("path", containerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/restart", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// RestartSender sends the Restart request. The method will close the +// http.Response Body if it receives an error. +func (client ContainerGroupsClient) RestartSender(req *http.Request) (future ContainerGroupsRestartFuture, err error) { + var resp *http.Response + resp, err = autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) + if err != nil { + return + } + err = autorest.Respond(resp, azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent)) + if err != nil { + return + } + future.Future, err = azure.NewFutureFromResponse(resp) + return +} + +// RestartResponder handles the response to the Restart request. The method always +// closes the http.Response Body. +func (client ContainerGroupsClient) RestartResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + +// Stop stops all containers in a contaienr group. Compute resources will be deallocated and billing will stop. +// Parameters: +// resourceGroupName - the name of the resource group. +// containerGroupName - the name of the container group. +func (client ContainerGroupsClient) Stop(ctx context.Context, resourceGroupName string, containerGroupName string) (result autorest.Response, err error) { + req, err := client.StopPreparer(ctx, resourceGroupName, containerGroupName) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Stop", nil, "Failure preparing request") + return + } + + resp, err := client.StopSender(req) + if err != nil { + result.Response = resp + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Stop", resp, "Failure sending request") + return + } + + result, err = client.StopResponder(resp) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsClient", "Stop", resp, "Failure responding to request") + } + + return +} + +// StopPreparer prepares the Stop request. +func (client ContainerGroupsClient) StopPreparer(ctx context.Context, resourceGroupName string, containerGroupName string) (*http.Request, error) { + pathParameters := map[string]interface{}{ + "containerGroupName": autorest.Encode("path", containerGroupName), + "resourceGroupName": autorest.Encode("path", resourceGroupName), + "subscriptionId": autorest.Encode("path", client.SubscriptionID), + } + + const APIVersion = "2018-06-01" + queryParameters := map[string]interface{}{ + "api-version": APIVersion, + } + + preparer := autorest.CreatePreparer( + autorest.AsPost(), + autorest.WithBaseURL(client.BaseURI), + autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerInstance/containerGroups/{containerGroupName}/stop", pathParameters), + autorest.WithQueryParameters(queryParameters)) + return preparer.Prepare((&http.Request{}).WithContext(ctx)) +} + +// StopSender sends the Stop request. The method will close the +// http.Response Body if it receives an error. +func (client ContainerGroupsClient) StopSender(req *http.Request) (*http.Response, error) { + return autorest.SendWithSender(client, req, + azure.DoRetryWithRegistration(client.Client)) +} + +// StopResponder handles the response to the Stop request. The method always +// closes the http.Response Body. +func (client ContainerGroupsClient) StopResponder(resp *http.Response) (result autorest.Response, err error) { + err = autorest.Respond( + resp, + client.ByInspecting(), + azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusNoContent), + autorest.ByClosing()) + result.Response = resp + return +} + // Update updates container group tags with specified values. // Parameters: // resourceGroupName - the name of the resource group. @@ -485,7 +628,7 @@ func (client ContainerGroupsClient) UpdatePreparer(ctx context.Context, resource "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-04-01" + const APIVersion = "2018-06-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/containergroupusage.go b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/containergroupusage.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/containergroupusage.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/containergroupusage.go index 4e9f5b52c18d..71ca9dd97522 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/containergroupusage.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/containergroupusage.go @@ -71,7 +71,7 @@ func (client ContainerGroupUsageClient) ListPreparer(ctx context.Context, locati "subscriptionId": autorest.Encode("path", client.SubscriptionID), } - const APIVersion = "2018-04-01" + const APIVersion = "2018-06-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/models.go b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/models.go similarity index 87% rename from vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/models.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/models.go index 01563f1513ac..35a90edf7d2f 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/models.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/models.go @@ -103,6 +103,21 @@ func PossibleOperationsOriginValues() []OperationsOrigin { return []OperationsOrigin{System, User} } +// Scheme enumerates the values for scheme. +type Scheme string + +const ( + // HTTP ... + HTTP Scheme = "http" + // HTTPS ... + HTTPS Scheme = "https" +) + +// PossibleSchemeValues returns an array of possible values for the Scheme const type. +func PossibleSchemeValues() []Scheme { + return []Scheme{HTTP, HTTPS} +} + // AzureFileVolume the properties of the Azure File volume. Azure File shares are mounted as volumes. type AzureFileVolume struct { // ShareName - The name of the Azure File share to be mounted as a volume. @@ -168,7 +183,13 @@ func (c *Container) UnmarshalJSON(body []byte) error { return nil } -// ContainerExecRequest the start container exec request. +// ContainerExec the container execution command, for liveness or readiness probe +type ContainerExec struct { + // Command - The commands to execute within the container. + Command *[]string `json:"command,omitempty"` +} + +// ContainerExecRequest the container exec request. type ContainerExecRequest struct { // Command - The command to be executed. Command *string `json:"command,omitempty"` @@ -178,10 +199,10 @@ type ContainerExecRequest struct { // ContainerExecRequestTerminalSize the size of the terminal. type ContainerExecRequestTerminalSize struct { - // Row - The row size of the terminal - Row *int32 `json:"row,omitempty"` - // Column - The column size of the terminal - Column *int32 `json:"column,omitempty"` + // Rows - The row size of the terminal + Rows *int32 `json:"rows,omitempty"` + // Cols - The column size of the terminal + Cols *int32 `json:"cols,omitempty"` } // ContainerExecResponse the information for the container exec command. @@ -302,6 +323,12 @@ func (cg *ContainerGroup) UnmarshalJSON(body []byte) error { return nil } +// ContainerGroupDiagnostics container group diagnostic information. +type ContainerGroupDiagnostics struct { + // LogAnalytics - Container group log analytics information. + LogAnalytics *LogAnalytics `json:"logAnalytics,omitempty"` +} + // ContainerGroupListResult the container group list response that contains the container group properties. type ContainerGroupListResult struct { autorest.Response `json:"-"` @@ -426,6 +453,8 @@ type ContainerGroupProperties struct { Volumes *[]Volume `json:"volumes,omitempty"` // InstanceView - The instance view of the container group. Only valid in response. InstanceView *ContainerGroupPropertiesInstanceView `json:"instanceView,omitempty"` + // Diagnostics - The diagnostic information for a container group. + Diagnostics *ContainerGroupDiagnostics `json:"diagnostics,omitempty"` } // ContainerGroupPropertiesInstanceView the instance view of the container group. Only valid in response. @@ -465,6 +494,39 @@ func (future *ContainerGroupsCreateOrUpdateFuture) Result(client ContainerGroups return } +// ContainerGroupsRestartFuture an abstraction for monitoring and retrieving the results of a long-running +// operation. +type ContainerGroupsRestartFuture struct { + azure.Future +} + +// Result returns the result of the asynchronous operation. +// If the operation has not completed it will return an error. +func (future *ContainerGroupsRestartFuture) Result(client ContainerGroupsClient) (ar autorest.Response, err error) { + var done bool + done, err = future.Done(client) + if err != nil { + err = autorest.NewErrorWithError(err, "containerinstance.ContainerGroupsRestartFuture", "Result", future.Response(), "Polling failure") + return + } + if !done { + err = azure.NewAsyncOpIncompleteError("containerinstance.ContainerGroupsRestartFuture") + return + } + ar.Response = future.Response() + return +} + +// ContainerHTTPGet the container Http Get settings, for liveness or readiness probe +type ContainerHTTPGet struct { + // Path - The path to probe. + Path *string `json:"path,omitempty"` + // Port - The port number to probe. + Port *int32 `json:"port,omitempty"` + // Scheme - The scheme. Possible values include: 'HTTP', 'HTTPS' + Scheme Scheme `json:"scheme,omitempty"` +} + // ContainerPort the port exposed on the container instance. type ContainerPort struct { // Protocol - The protocol associated with the port. Possible values include: 'ContainerNetworkProtocolTCP', 'ContainerNetworkProtocolUDP' @@ -473,6 +535,24 @@ type ContainerPort struct { Port *int32 `json:"port,omitempty"` } +// ContainerProbe the container probe, for liveness or readiness +type ContainerProbe struct { + // Exec - The execution command to probe + Exec *ContainerExec `json:"exec,omitempty"` + // HTTPGet - The Http Get settings to probe + HTTPGet *ContainerHTTPGet `json:"httpGet,omitempty"` + // InitialDelaySeconds - The initial delay seconds. + InitialDelaySeconds *int32 `json:"initialDelaySeconds,omitempty"` + // PeriodSeconds - The period seconds. + PeriodSeconds *int32 `json:"periodSeconds,omitempty"` + // FailureThreshold - The failure threshold. + FailureThreshold *int32 `json:"failureThreshold,omitempty"` + // SuccessThreshold - The success threshold. + SuccessThreshold *int32 `json:"successThreshold,omitempty"` + // TimeoutSeconds - The timeout seconds. + TimeoutSeconds *int32 `json:"timeoutSeconds,omitempty"` +} + // ContainerProperties the container instance properties. type ContainerProperties struct { // Image - The name of the image used to create the container instance. @@ -489,6 +569,10 @@ type ContainerProperties struct { Resources *ResourceRequirements `json:"resources,omitempty"` // VolumeMounts - The volume mounts available to the container instance. VolumeMounts *[]VolumeMount `json:"volumeMounts,omitempty"` + // LivenessProbe - The liveness probe. + LivenessProbe *ContainerProbe `json:"livenessProbe,omitempty"` + // ReadinessProbe - The readiness probe. + ReadinessProbe *ContainerProbe `json:"readinessProbe,omitempty"` } // ContainerPropertiesInstanceView the instance view of the container instance. Only valid in response. @@ -523,6 +607,8 @@ type EnvironmentVariable struct { Name *string `json:"name,omitempty"` // Value - The value of the environment variable. Value *string `json:"value,omitempty"` + // SecureValue - The value of the secure environment variable. + SecureValue *string `json:"secureValue,omitempty"` } // Event a container group or container instance event. @@ -575,6 +661,14 @@ type IPAddress struct { Fqdn *string `json:"fqdn,omitempty"` } +// LogAnalytics container group log analytics information. +type LogAnalytics struct { + // WorkspaceID - The workspace id for log analytics + WorkspaceID *string `json:"workspaceId,omitempty"` + // WorkspaceKey - The workspace key for log analytics + WorkspaceKey *string `json:"workspaceKey,omitempty"` +} + // Logs the logs. type Logs struct { autorest.Response `json:"-"` diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/operations.go b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/operations.go similarity index 99% rename from vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/operations.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/operations.go index 559a24c8f992..e8998e0b448c 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/operations.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/operations.go @@ -64,7 +64,7 @@ func (client OperationsClient) List(ctx context.Context) (result OperationListRe // ListPreparer prepares the List request. func (client OperationsClient) ListPreparer(ctx context.Context) (*http.Request, error) { - const APIVersion = "2018-04-01" + const APIVersion = "2018-06-01" queryParameters := map[string]interface{}{ "api-version": APIVersion, } diff --git a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/version.go b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/version.go similarity index 98% rename from vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/version.go rename to vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/version.go index df5d7da41d05..d6d96251823a 100644 --- a/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance/version.go +++ b/vendor/github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance/version.go @@ -21,7 +21,7 @@ import "github.com/Azure/azure-sdk-for-go/version" // UserAgent returns the UserAgent string to use when sending http.Requests. func UserAgent() string { - return "Azure-SDK-For-Go/" + version.Number + " containerinstance/2018-04-01" + return "Azure-SDK-For-Go/" + version.Number + " containerinstance/2018-06-01" } // Version returns the semantic version (see http://semver.org) of the client. diff --git a/vendor/vendor.json b/vendor/vendor.json index 447f2a9d03a5..3f478b347c04 100644 --- a/vendor/vendor.json +++ b/vendor/vendor.json @@ -43,10 +43,10 @@ "versionExact": "v21.1.0" }, { - "checksumSHA1": "a/mbRxz450lwbacAUuG77DpKKJU=", - "path": "github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-04-01/containerinstance", + "checksumSHA1": "eB6b4vGKEbAND0MUWfKLTn6H7uw=", + "path": "github.com/Azure/azure-sdk-for-go/services/containerinstance/mgmt/2018-06-01/containerinstance", "revision": "6d20bdbae88c06c36d72eb512295417693bfdf4e", - "revisionTime": "2018-09-28T00:20:07Z", + "revisionTime": "2018-09-27T22:44:43Z", "version": "v21.1.0", "versionExact": "v21.1.0" }, diff --git a/website/docs/r/container_group.html.markdown b/website/docs/r/container_group.html.markdown index 19dca5be4a93..3223f13cfd69 100644 --- a/website/docs/r/container_group.html.markdown +++ b/website/docs/r/container_group.html.markdown @@ -1,170 +1,176 @@ ---- -layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_container_group" -sidebar_current: "docs-azurerm-resource-container-group" -description: |- - Create as an Azure Container Group instance. ---- - -# azurerm_container_group - -Manage as an Azure Container Group instance. - -## Example Usage - -```hcl -resource "azurerm_resource_group" "aci-rg" { - name = "aci-test" - location = "west us" -} - -resource "azurerm_storage_account" "aci-sa" { - name = "acistorageacct" - resource_group_name = "${azurerm_resource_group.aci-rg.name}" - location = "${azurerm_resource_group.aci-rg.location}" - account_tier = "Standard" - - account_replication_type = "LRS" -} - -resource "azurerm_storage_share" "aci-share" { - name = "aci-test-share" - - resource_group_name = "${azurerm_resource_group.aci-rg.name}" - storage_account_name = "${azurerm_storage_account.aci-sa.name}" - - quota = 50 -} - -resource "azurerm_container_group" "aci-helloworld" { - name = "aci-hw" - location = "${azurerm_resource_group.aci-rg.location}" - resource_group_name = "${azurerm_resource_group.aci-rg.name}" - ip_address_type = "public" - dns_name_label = "aci-label" - os_type = "Linux" - - container { - name = "hw" - image = "seanmckenna/aci-hellofiles" - cpu ="0.5" - memory = "1.5" - port = "80" - - environment_variables { - "NODE_ENV" = "testing" - } - - commands = ["/bin/bash", "-c", "'/path to/myscript.sh'"] - - volume { - name = "logs" - mount_path = "/aci/logs" - read_only = false - share_name = "${azurerm_storage_share.aci-share.name}" - - storage_account_name = "${azurerm_storage_account.aci-sa.name}" - storage_account_key = "${azurerm_storage_account.aci-sa.primary_access_key}" - } - } - - container { - name = "sidecar" - image = "microsoft/aci-tutorial-sidecar" - cpu = "0.5" - memory = "1.5" - } - - tags { - environment = "testing" - } -} -``` - -## Argument Reference - -The following arguments are supported: - -* `name` - (Required) Specifies the name of the Container Group. Changing this forces a new resource to be created. - -* `resource_group_name` - (Required) The name of the resource group in which to create the Container Group. Changing this forces a new resource to be created. - -* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. - -* `ip_address_type` - (Optional) Specifies the ip address type of the container. `Public` is the only acceptable value at this time. Changing this forces a new resource to be created. - -* `dns_name_label` - (Optional) The DNS label/name for the container groups IP. - -* `os_type` - (Required) The OS for the container group. Allowed values are `Linux` and `Windows`. Changing this forces a new resource to be created. - -* `restart_policy` - (Optional) Restart policy for the container group. Allowed values are `Always`, `Never`, `OnFailure`. Defaults to `Always`. - -* `image_registry_credential` - (Optional) Set image registry credentials for the group as documented in the `image_registry_credential` block below - -* `container` - (Required) The definition of a container that is part of the group as documented in the `container` block below. Changing this forces a new resource to be created. - -~> **Note:** if `os_type` is set to `Windows` currently only a single `container` block is supported. - -The `container` block supports: - -* `name` - (Required) Specifies the name of the Container. Changing this forces a new resource to be created. - -* `image` - (Required) The container image name. Changing this forces a new resource to be created. - -* `cpu` - (Required) The required number of CPU cores of the containers. Changing this forces a new resource to be created. - -* `memory` - (Required) The required memory of the containers in GB. Changing this forces a new resource to be created. - -* `port` - (Optional) A public port for the container. Changing this forces a new resource to be created. - -* `protocol` - (Optional) The protocol associated with port for the container. Allowed values are `TCP` and `UDP`. - -* `environment_variables` - (Optional) A list of environment variables to be set on the container. Specified as a map of name/value pairs. Changing this forces a new resource to be created. - -* `command` - (Optional) A command line to be run on the container. Changing this forces a new resource to be created. - -~> **NOTE:** The field `command` has been deprecated in favor of `commands` to better match the API. - -* `commands` - (Optional) A list of commands which should be run on the container. Changing this forces a new resource to be created. - -* `volume` - (Optional) The definition of a volume mount for this container as documented in the `volume` block below. Changing this forces a new resource to be created. - -The `volume` block supports: - -* `name` - (Required) The name of the volume mount. Changing this forces a new resource to be created. - -* `mount_path` - (Required) The path on which this volume is to be mounted. Changing this forces a new resource to be created. - -* `read_only` - (Optional) Specify if the volume is to be mounted as read only or not. The default value is `false`. Changing this forces a new resource to be created. - -* `storage_account_name` - (Required) The Azure storage account from which the volume is to be mounted. Changing this forces a new resource to be created. - -* `storage_account_key` - (Required) The access key for the Azure Storage account specified as above. Changing this forces a new resource to be created. - -* `share_name` - (Required) The Azure storage share that is to be mounted as a volume. This must be created on the storage account specified as above. Changing this forces a new resource to be created. - -The `image_registry_credential` block supports: - -* `username` - (Required) The username with which to connect to the registry. - -* `password` - (Required) The password with which to connect to the registry. - -* `server` - (Required) The address to use to connect to the registry without protocol ("https"/"http"). For example: "myacr.acr.io" - -## Attributes Reference - -The following attributes are exported: - -* `id` - The container group ID. - -* `ip_address` - The IP address allocated to the container group. - -* `fqdn` - The FQDN of the container group derived from `dns_name_label`. - -## Import - -Container Group's can be imported using the `resource id`, e.g. - -```shell -terraform import azurerm_container_group.containerGroup1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ContainerInstance/containerGroups/myContainerGroup1 -``` +--- +layout: "azurerm" +page_title: "Azure Resource Manager: azurerm_container_group" +sidebar_current: "docs-azurerm-resource-container-group" +description: |- + Create as an Azure Container Group instance. +--- + +# azurerm_container_group + +Manage as an Azure Container Group instance. + +## Example Usage + +```hcl +resource "azurerm_resource_group" "aci-rg" { + name = "aci-test" + location = "west us" +} + +resource "azurerm_storage_account" "aci-sa" { + name = "acistorageacct" + resource_group_name = "${azurerm_resource_group.aci-rg.name}" + location = "${azurerm_resource_group.aci-rg.location}" + account_tier = "Standard" + + account_replication_type = "LRS" +} + +resource "azurerm_storage_share" "aci-share" { + name = "aci-test-share" + + resource_group_name = "${azurerm_resource_group.aci-rg.name}" + storage_account_name = "${azurerm_storage_account.aci-sa.name}" + + quota = 50 +} + +resource "azurerm_container_group" "aci-helloworld" { + name = "aci-hw" + location = "${azurerm_resource_group.aci-rg.location}" + resource_group_name = "${azurerm_resource_group.aci-rg.name}" + ip_address_type = "public" + dns_name_label = "aci-label" + os_type = "Linux" + + container { + name = "hw" + image = "seanmckenna/aci-hellofiles" + cpu ="0.5" + memory = "1.5" + port = "80" + + environment_variables { + "NODE_ENV" = "testing" + } + + secure_environment_variables { + "ACCESS_KEY" = "secure_testing" + } + + commands = ["/bin/bash", "-c", "'/path to/myscript.sh'"] + + volume { + name = "logs" + mount_path = "/aci/logs" + read_only = false + share_name = "${azurerm_storage_share.aci-share.name}" + + storage_account_name = "${azurerm_storage_account.aci-sa.name}" + storage_account_key = "${azurerm_storage_account.aci-sa.primary_access_key}" + } + } + + container { + name = "sidecar" + image = "microsoft/aci-tutorial-sidecar" + cpu = "0.5" + memory = "1.5" + } + + tags { + environment = "testing" + } +} +``` + +## Argument Reference + +The following arguments are supported: + +* `name` - (Required) Specifies the name of the Container Group. Changing this forces a new resource to be created. + +* `resource_group_name` - (Required) The name of the resource group in which to create the Container Group. Changing this forces a new resource to be created. + +* `location` - (Required) Specifies the supported Azure location where the resource exists. Changing this forces a new resource to be created. + +* `ip_address_type` - (Optional) Specifies the ip address type of the container. `Public` is the only acceptable value at this time. Changing this forces a new resource to be created. + +* `dns_name_label` - (Optional) The DNS label/name for the container groups IP. + +* `os_type` - (Required) The OS for the container group. Allowed values are `Linux` and `Windows`. Changing this forces a new resource to be created. + +* `restart_policy` - (Optional) Restart policy for the container group. Allowed values are `Always`, `Never`, `OnFailure`. Defaults to `Always`. + +* `image_registry_credential` - (Optional) Set image registry credentials for the group as documented in the `image_registry_credential` block below + +* `container` - (Required) The definition of a container that is part of the group as documented in the `container` block below. Changing this forces a new resource to be created. + +~> **Note:** if `os_type` is set to `Windows` currently only a single `container` block is supported. + +The `container` block supports: + +* `name` - (Required) Specifies the name of the Container. Changing this forces a new resource to be created. + +* `image` - (Required) The container image name. Changing this forces a new resource to be created. + +* `cpu` - (Required) The required number of CPU cores of the containers. Changing this forces a new resource to be created. + +* `memory` - (Required) The required memory of the containers in GB. Changing this forces a new resource to be created. + +* `port` - (Optional) A public port for the container. Changing this forces a new resource to be created. + +* `protocol` - (Optional) The protocol associated with port for the container. Allowed values are `TCP` and `UDP`. + +* `environment_variables` - (Optional) A list of environment variables to be set on the container. Specified as a map of name/value pairs. Changing this forces a new resource to be created. + +* `secure_environment_variables` - (Optional) A list of sensitive environment variables to be set on the container. Specified as a map of name/value pairs. Changing this forces a new resource to be created. + +* `command` - (Optional) A command line to be run on the container. + +~> **NOTE:** The field `command` has been deprecated in favor of `commands` to better match the API. + +* `commands` - (Optional) A list of commands which should be run on the container. + +* `volume` - (Optional) The definition of a volume mount for this container as documented in the `volume` block below. Changing this forces a new resource to be created. + +The `volume` block supports: + +* `name` - (Required) The name of the volume mount. Changing this forces a new resource to be created. + +* `mount_path` - (Required) The path on which this volume is to be mounted. Changing this forces a new resource to be created. + +* `read_only` - (Optional) Specify if the volume is to be mounted as read only or not. The default value is `false`. Changing this forces a new resource to be created. + +* `storage_account_name` - (Required) The Azure storage account from which the volume is to be mounted. Changing this forces a new resource to be created. + +* `storage_account_key` - (Required) The access key for the Azure Storage account specified as above. Changing this forces a new resource to be created. + +* `share_name` - (Required) The Azure storage share that is to be mounted as a volume. This must be created on the storage account specified as above. Changing this forces a new resource to be created. + +The `image_registry_credential` block supports: + +* `username` - (Required) The username with which to connect to the registry. + +* `password` - (Required) The password with which to connect to the registry. + +* `server` - (Required) The address to use to connect to the registry without protocol ("https"/"http"). For example: "myacr.acr.io" + +## Attributes Reference + +The following attributes are exported: + +* `id` - The container group ID. + +* `ip_address` - The IP address allocated to the container group. + +* `fqdn` - The FQDN of the container group derived from `dns_name_label`. + +## Import + +Container Group's can be imported using the `resource id`, e.g. + +```shell +terraform import azurerm_container_group.containerGroup1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.ContainerInstance/containerGroups/myContainerGroup1 +```