From 5681aca028cb7357f980508cae653860a0ab9c6b Mon Sep 17 00:00:00 2001 From: tombuildsstuff Date: Wed, 12 Feb 2020 18:45:35 +0100 Subject: [PATCH] 2.0: Removing `azurerm_container_service` This resource is Deprecated in 1.x and no longer supported in version 2.0 of the Azure Provider --- .../services/containers/client/client.go | 9 +- .../services/containers/registration.go | 1 - .../resource_arm_container_service.go | 679 ------------------ .../resource_arm_container_service_test.go | 451 ------------ website/azurerm.erb | 4 - .../docs/r/container_service.html.markdown | 229 ------ 6 files changed, 3 insertions(+), 1370 deletions(-) delete mode 100644 azurerm/internal/services/containers/resource_arm_container_service.go delete mode 100644 azurerm/internal/services/containers/tests/resource_arm_container_service_test.go delete mode 100644 website/docs/r/container_service.html.markdown diff --git a/azurerm/internal/services/containers/client/client.go b/azurerm/internal/services/containers/client/client.go index 2268c0463b92..a76184c890fa 100644 --- a/azurerm/internal/services/containers/client/client.go +++ b/azurerm/internal/services/containers/client/client.go @@ -9,14 +9,12 @@ import ( type Client struct { AgentPoolsClient *containerservice.AgentPoolsClient - KubernetesClustersClient *containerservice.ManagedClustersClient GroupsClient *containerinstance.ContainerGroupsClient + KubernetesClustersClient *containerservice.ManagedClustersClient RegistriesClient *containerregistry.RegistriesClient - WebhooksClient *containerregistry.WebhooksClient ReplicationsClient *containerregistry.ReplicationsClient - - // TODO: this can be removed in 2.0 - ServicesClient *containerservice.ContainerServicesClient + ServicesClient *containerservice.ContainerServicesClient + WebhooksClient *containerregistry.WebhooksClient } func NewClient(o *common.ClientOptions) *Client { @@ -39,7 +37,6 @@ func NewClient(o *common.ClientOptions) *Client { agentPoolsClient := containerservice.NewAgentPoolsClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&agentPoolsClient.Client, o.ResourceManagerAuthorizer) - // ACS servicesClient := containerservice.NewContainerServicesClientWithBaseURI(o.ResourceManagerEndpoint, o.SubscriptionId) o.ConfigureClient(&servicesClient.Client, o.ResourceManagerAuthorizer) diff --git a/azurerm/internal/services/containers/registration.go b/azurerm/internal/services/containers/registration.go index c89b5302c6e1..b25375d4616f 100644 --- a/azurerm/internal/services/containers/registration.go +++ b/azurerm/internal/services/containers/registration.go @@ -26,7 +26,6 @@ func (r Registration) SupportedResources() map[string]*schema.Resource { "azurerm_container_group": resourceArmContainerGroup(), "azurerm_container_registry_webhook": resourceArmContainerRegistryWebhook(), "azurerm_container_registry": resourceArmContainerRegistry(), - "azurerm_container_service": resourceArmContainerService(), "azurerm_kubernetes_cluster": resourceArmKubernetesCluster(), "azurerm_kubernetes_cluster_node_pool": resourceArmKubernetesClusterNodePool(), } diff --git a/azurerm/internal/services/containers/resource_arm_container_service.go b/azurerm/internal/services/containers/resource_arm_container_service.go deleted file mode 100644 index 58ea61f2b927..000000000000 --- a/azurerm/internal/services/containers/resource_arm_container_service.go +++ /dev/null @@ -1,679 +0,0 @@ -package containers - -import ( - "bytes" - "context" - "fmt" - "log" - "time" - - "github.com/Azure/azure-sdk-for-go/services/containerservice/mgmt/2019-10-01/containerservice" - "github.com/hashicorp/terraform-plugin-sdk/helper/hashcode" - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/helper/schema" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/azure" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/suppress" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/helpers/tf" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/tags" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/timeouts" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/utils" -) - -func resourceArmContainerService() *schema.Resource { - return &schema.Resource{ - Create: resourceArmContainerServiceCreateUpdate, - Read: resourceArmContainerServiceRead, - Update: resourceArmContainerServiceCreateUpdate, - Delete: resourceArmContainerServiceDelete, - - Timeouts: &schema.ResourceTimeout{ - Create: schema.DefaultTimeout(90 * time.Minute), - Read: schema.DefaultTimeout(5 * time.Minute), - Update: schema.DefaultTimeout(90 * time.Minute), - Delete: schema.DefaultTimeout(90 * time.Minute), - }, - - DeprecationMessage: `Azure Container Service (ACS) has been deprecated in favour of Azure (Managed) Kubernetes Service (AKS). - -Azure will remove support for ACS Clusters on January 31, 2020. In preparation for this, the AzureRM Provider will remove support for the 'azurerm_container_service' resource in the next major version of the AzureRM Provider, which is targeted for Early 2019. - -If you're using ACS with Kubernetes, we'd recommend migrating to AKS / the 'azurerm_kubernetes_cluster' resource. - -More information can be found here: https://azure.microsoft.com/en-us/updates/azure-container-service-will-retire-on-january-31-2020/ -`, - - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "location": azure.SchemaLocation(), - - "resource_group_name": azure.SchemaResourceGroupName(), - - "orchestration_platform": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - ValidateFunc: ValidateArmContainerServiceOrchestrationPlatform, - }, - - //lintignore:S018 - "master_profile": { - Type: schema.TypeSet, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "count": { - Type: schema.TypeInt, - Optional: true, - Default: 1, - ValidateFunc: ValidateArmContainerServiceMasterProfileCount, - }, - - "dns_prefix": { - Type: schema.TypeString, - Required: true, - }, - - "fqdn": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - Set: resourceAzureRMContainerServiceMasterProfileHash, - }, - - //lintignore:S018 - "linux_profile": { - Type: schema.TypeSet, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "admin_username": { - Type: schema.TypeString, - Required: true, - }, - "ssh_key": { - Type: schema.TypeSet, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "key_data": { - Type: schema.TypeString, - Required: true, - }, - }, - }, - }, - }, - }, - Set: resourceAzureRMContainerServiceLinuxProfilesHash, - }, - - //lintignore:S018 - "agent_pool_profile": { - Type: schema.TypeSet, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "name": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "count": { - Type: schema.TypeInt, - Optional: true, - Default: 1, - ValidateFunc: ValidateArmContainerServiceAgentPoolProfileCount, - }, - - "dns_prefix": { - Type: schema.TypeString, - Required: true, - ForceNew: true, - }, - - "fqdn": { - Type: schema.TypeString, - Computed: true, - }, - - "vm_size": { - Type: schema.TypeString, - Required: true, - DiffSuppressFunc: suppress.CaseDifference, - }, - }, - }, - Set: resourceAzureRMContainerServiceAgentPoolProfilesHash, - }, - - //lintignore:S018 - "service_principal": { - Type: schema.TypeSet, - Optional: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "client_id": { - Type: schema.TypeString, - Required: true, - }, - - "client_secret": { - Type: schema.TypeString, - Required: true, - Sensitive: true, - }, - }, - }, - Set: resourceAzureRMContainerServiceServicePrincipalProfileHash, - }, - - //lintignore:S018 - "diagnostics_profile": { - Type: schema.TypeSet, - Required: true, - MaxItems: 1, - Elem: &schema.Resource{ - Schema: map[string]*schema.Schema{ - "enabled": { - Type: schema.TypeBool, - Required: true, - }, - - "storage_uri": { - Type: schema.TypeString, - Computed: true, - }, - }, - }, - Set: resourceAzureRMContainerServiceDiagnosticProfilesHash, - }, - - "tags": tags.Schema(), - }, - } -} - -func resourceArmContainerServiceCreateUpdate(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client) - ctx, cancel := timeouts.ForCreateUpdate(meta.(*clients.Client).StopContext, d) - defer cancel() - containerServiceClient := client.Containers.ServicesClient - - log.Printf("[INFO] preparing arguments for Azure ARM Container Service creation.") - - resGroup := d.Get("resource_group_name").(string) - name := d.Get("name").(string) - - if features.ShouldResourcesBeImported() && d.IsNewResource() { - existing, err := containerServiceClient.Get(ctx, resGroup, name) - if err != nil { - if !utils.ResponseWasNotFound(existing.Response) { - return fmt.Errorf("Error checking for presence of existing Container Service %q (Resource Group %q): %s", name, resGroup, err) - } - } - - if existing.ID != nil && *existing.ID != "" { - return tf.ImportAsExistsError("azurerm_container_service", *existing.ID) - } - } - - location := azure.NormalizeLocation(d.Get("location").(string)) - - orchestrationPlatform := d.Get("orchestration_platform").(string) - - masterProfile := expandAzureRmContainerServiceMasterProfile(d) - linuxProfile := expandAzureRmContainerServiceLinuxProfile(d) - agentProfiles := expandAzureRmContainerServiceAgentProfiles(d) - diagnosticsProfile := expandAzureRmContainerServiceDiagnostics(d) - - t := d.Get("tags").(map[string]interface{}) - - parameters := containerservice.ContainerService{ - Name: &name, - Location: &location, - Properties: &containerservice.Properties{ - MasterProfile: &masterProfile, - LinuxProfile: &linuxProfile, - OrchestratorProfile: &containerservice.OrchestratorProfileType{ - OrchestratorType: containerservice.OrchestratorTypes(orchestrationPlatform), - }, - AgentPoolProfiles: &agentProfiles, - DiagnosticsProfile: &diagnosticsProfile, - }, - Tags: tags.Expand(t), - } - - servicePrincipalProfile := expandAzureRmContainerServiceServicePrincipal(d) - if servicePrincipalProfile != nil { - parameters.ServicePrincipalProfile = servicePrincipalProfile - } - - if _, err := containerServiceClient.CreateOrUpdate(ctx, resGroup, name, parameters); err != nil { - return err - } - - read, err := containerServiceClient.Get(ctx, resGroup, name) - if err != nil { - return err - } - - if read.ID == nil { - return fmt.Errorf("Cannot read Container Service %s (resource group %s) ID", name, resGroup) - } - - log.Printf("[DEBUG] Waiting for Container Service (%s) to become available", d.Get("name")) - stateConf := &resource.StateChangeConf{ - Pending: []string{"Updating", "Creating"}, - Target: []string{"Succeeded"}, - Refresh: containerServiceStateRefreshFunc(ctx, client, resGroup, name), - MinTimeout: 15 * time.Second, - } - - if d.IsNewResource() { - stateConf.Timeout = d.Timeout(schema.TimeoutCreate) - } else { - stateConf.Timeout = d.Timeout(schema.TimeoutUpdate) - } - - if _, err := stateConf.WaitForState(); err != nil { - return fmt.Errorf("Error waiting for Container Service (%s) to become available: %s", d.Get("name"), err) - } - - d.SetId(*read.ID) - - return resourceArmContainerServiceRead(d, meta) -} - -func resourceArmContainerServiceRead(d *schema.ResourceData, meta interface{}) error { - containerServiceClient := meta.(*clients.Client).Containers.ServicesClient - ctx, cancel := timeouts.ForRead(meta.(*clients.Client).StopContext, d) - defer cancel() - - id, err := azure.ParseAzureResourceID(d.Id()) - if err != nil { - return err - } - resGroup := id.ResourceGroup - name := id.Path["containerServices"] - - resp, err := containerServiceClient.Get(ctx, resGroup, name) - if err != nil { - if utils.ResponseWasNotFound(resp.Response) { - d.SetId("") - return nil - } - - return fmt.Errorf("Error making Read request on Azure Container Service %s: %s", name, err) - } - - d.Set("name", resp.Name) - d.Set("resource_group_name", resGroup) - if location := resp.Location; location != nil { - d.Set("location", azure.NormalizeLocation(*location)) - } - - d.Set("orchestration_platform", string(resp.Properties.OrchestratorProfile.OrchestratorType)) - - masterProfiles := flattenAzureRmContainerServiceMasterProfile(*resp.Properties.MasterProfile) - d.Set("master_profile", &masterProfiles) - - linuxProfile := flattenAzureRmContainerServiceLinuxProfile(*resp.Properties.LinuxProfile) - d.Set("linux_profile", &linuxProfile) - - agentPoolProfiles := flattenAzureRmContainerServiceAgentPoolProfiles(resp.Properties.AgentPoolProfiles) - d.Set("agent_pool_profile", &agentPoolProfiles) - - servicePrincipal := flattenAzureRmContainerServiceServicePrincipalProfile(resp.Properties.ServicePrincipalProfile) - if servicePrincipal != nil { - d.Set("service_principal", servicePrincipal) - } - - diagnosticProfile := flattenAzureRmContainerServiceDiagnosticsProfile(resp.Properties.DiagnosticsProfile) - if diagnosticProfile != nil { - d.Set("diagnostics_profile", diagnosticProfile) - } - - return tags.FlattenAndSet(d, resp.Tags) -} - -func resourceArmContainerServiceDelete(d *schema.ResourceData, meta interface{}) error { - client := meta.(*clients.Client) - ctx, cancel := timeouts.ForDelete(meta.(*clients.Client).StopContext, d) - defer cancel() - containerServiceClient := client.Containers.ServicesClient - - id, err := azure.ParseAzureResourceID(d.Id()) - if err != nil { - return err - } - resGroup := id.ResourceGroup - name := id.Path["containerServices"] - - future, err := containerServiceClient.Delete(ctx, resGroup, name) - - if err != nil { - return fmt.Errorf("Error issuing Azure ARM delete request of Container Service '%s': %s", name, err) - } - - return future.WaitForCompletionRef(ctx, containerServiceClient.Client) -} - -func flattenAzureRmContainerServiceMasterProfile(profile containerservice.MasterProfile) *schema.Set { - masterProfiles := &schema.Set{ - F: resourceAzureRMContainerServiceMasterProfileHash, - } - - masterProfile := make(map[string]interface{}, 3) - - masterProfile["count"] = int(*profile.Count) - masterProfile["dns_prefix"] = *profile.DNSPrefix - masterProfile["fqdn"] = *profile.Fqdn - - masterProfiles.Add(masterProfile) - - return masterProfiles -} - -func flattenAzureRmContainerServiceLinuxProfile(profile containerservice.LinuxProfile) *schema.Set { - profiles := &schema.Set{ - F: resourceAzureRMContainerServiceLinuxProfilesHash, - } - - values := map[string]interface{}{} - - sshKeys := &schema.Set{ - F: resourceAzureRMContainerServiceLinuxProfilesSSHKeysHash, - } - for _, ssh := range *profile.SSH.PublicKeys { - keys := map[string]interface{}{} - keys["key_data"] = *ssh.KeyData - sshKeys.Add(keys) - } - - values["admin_username"] = *profile.AdminUsername - values["ssh_key"] = sshKeys - profiles.Add(values) - - return profiles -} - -func flattenAzureRmContainerServiceAgentPoolProfiles(profiles *[]containerservice.AgentPoolProfile) *schema.Set { - agentPoolProfiles := &schema.Set{ - F: resourceAzureRMContainerServiceAgentPoolProfilesHash, - } - - for _, profile := range *profiles { - agentPoolProfile := map[string]interface{}{} - agentPoolProfile["count"] = int(*profile.Count) - agentPoolProfile["dns_prefix"] = *profile.DNSPrefix - agentPoolProfile["fqdn"] = *profile.Fqdn - agentPoolProfile["name"] = *profile.Name - agentPoolProfile["vm_size"] = string(profile.VMSize) - agentPoolProfiles.Add(agentPoolProfile) - } - - return agentPoolProfiles -} - -func flattenAzureRmContainerServiceServicePrincipalProfile(profile *containerservice.ServicePrincipalProfile) *schema.Set { - if profile == nil { - return nil - } - - servicePrincipalProfiles := &schema.Set{ - F: resourceAzureRMContainerServiceServicePrincipalProfileHash, - } - - values := map[string]interface{}{} - - values["client_id"] = *profile.ClientID - if profile.Secret != nil { - values["client_secret"] = *profile.Secret - } - - servicePrincipalProfiles.Add(values) - - return servicePrincipalProfiles -} - -func flattenAzureRmContainerServiceDiagnosticsProfile(profile *containerservice.DiagnosticsProfile) *schema.Set { - diagnosticProfiles := &schema.Set{ - F: resourceAzureRMContainerServiceDiagnosticProfilesHash, - } - - values := map[string]interface{}{} - - values["enabled"] = *profile.VMDiagnostics.Enabled - if profile.VMDiagnostics.StorageURI != nil { - values["storage_uri"] = *profile.VMDiagnostics.StorageURI - } - diagnosticProfiles.Add(values) - - return diagnosticProfiles -} - -func expandAzureRmContainerServiceDiagnostics(d *schema.ResourceData) containerservice.DiagnosticsProfile { - configs := d.Get("diagnostics_profile").(*schema.Set).List() - - data := configs[0].(map[string]interface{}) - - enabled := data["enabled"].(bool) - - return containerservice.DiagnosticsProfile{ - VMDiagnostics: &containerservice.VMDiagnostics{ - Enabled: &enabled, - }, - } -} - -func expandAzureRmContainerServiceLinuxProfile(d *schema.ResourceData) containerservice.LinuxProfile { - profiles := d.Get("linux_profile").(*schema.Set).List() - config := profiles[0].(map[string]interface{}) - - adminUsername := config["admin_username"].(string) - - linuxKeys := config["ssh_key"].(*schema.Set).List() - sshPublicKeys := make([]containerservice.SSHPublicKey, 0) - - key := linuxKeys[0].(map[string]interface{}) - keyData := key["key_data"].(string) - - sshPublicKey := containerservice.SSHPublicKey{ - KeyData: &keyData, - } - - sshPublicKeys = append(sshPublicKeys, sshPublicKey) - - profile := containerservice.LinuxProfile{ - AdminUsername: &adminUsername, - SSH: &containerservice.SSHConfiguration{ - PublicKeys: &sshPublicKeys, - }, - } - - return profile -} - -func expandAzureRmContainerServiceMasterProfile(d *schema.ResourceData) containerservice.MasterProfile { - configs := d.Get("master_profile").(*schema.Set).List() - config := configs[0].(map[string]interface{}) - - count := int32(config["count"].(int)) - dnsPrefix := config["dns_prefix"].(string) - - profile := containerservice.MasterProfile{ - Count: &count, - DNSPrefix: &dnsPrefix, - } - - return profile -} - -func expandAzureRmContainerServiceServicePrincipal(d *schema.ResourceData) *containerservice.ServicePrincipalProfile { - value, exists := d.GetOk("service_principal") - if !exists { - return nil - } - - configs := value.(*schema.Set).List() - - config := configs[0].(map[string]interface{}) - - clientId := config["client_id"].(string) - clientSecret := config["client_secret"].(string) - - principal := containerservice.ServicePrincipalProfile{ - ClientID: &clientId, - Secret: &clientSecret, - } - - return &principal -} - -func expandAzureRmContainerServiceAgentProfiles(d *schema.ResourceData) []containerservice.AgentPoolProfile { - configs := d.Get("agent_pool_profile").(*schema.Set).List() - config := configs[0].(map[string]interface{}) - profiles := make([]containerservice.AgentPoolProfile, 0, len(configs)) - - name := config["name"].(string) - count := int32(config["count"].(int)) - dnsPrefix := config["dns_prefix"].(string) - vmSize := config["vm_size"].(string) - - profile := containerservice.AgentPoolProfile{ - Name: &name, - Count: &count, - VMSize: containerservice.VMSizeTypes(vmSize), - DNSPrefix: &dnsPrefix, - } - - profiles = append(profiles, profile) - - return profiles -} - -func containerServiceStateRefreshFunc(ctx context.Context, client *clients.Client, resourceGroupName string, containerServiceName string) resource.StateRefreshFunc { - return func() (interface{}, string, error) { - res, err := client.Containers.ServicesClient.Get(ctx, resourceGroupName, containerServiceName) - if err != nil { - return nil, "", fmt.Errorf("Error issuing read request in containerServiceStateRefreshFunc to Azure ARM for Container Service '%s' (RG: '%s'): %s", containerServiceName, resourceGroupName, err) - } - - return res, *res.Properties.ProvisioningState, nil - } -} - -func resourceAzureRMContainerServiceMasterProfileHash(v interface{}) int { - var buf bytes.Buffer - - if m, ok := v.(map[string]interface{}); ok { - buf.WriteString(fmt.Sprintf("%d-", m["count"].(int))) - buf.WriteString(fmt.Sprintf("%s-", m["dns_prefix"].(string))) - } - - return hashcode.String(buf.String()) -} - -func resourceAzureRMContainerServiceLinuxProfilesHash(v interface{}) int { - var buf bytes.Buffer - - if m, ok := v.(map[string]interface{}); ok { - buf.WriteString(fmt.Sprintf("%s-", m["admin_username"].(string))) - } - - return hashcode.String(buf.String()) -} - -func resourceAzureRMContainerServiceLinuxProfilesSSHKeysHash(v interface{}) int { - var buf bytes.Buffer - - if m, ok := v.(map[string]interface{}); ok { - buf.WriteString(fmt.Sprintf("%s-", m["key_data"].(string))) - } - - return hashcode.String(buf.String()) -} - -func resourceAzureRMContainerServiceAgentPoolProfilesHash(v interface{}) int { - var buf bytes.Buffer - - if m, ok := v.(map[string]interface{}); ok { - buf.WriteString(fmt.Sprintf("%d-", m["count"].(int))) - buf.WriteString(fmt.Sprintf("%s-", m["dns_prefix"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["name"].(string))) - buf.WriteString(fmt.Sprintf("%s-", m["vm_size"].(string))) - } - - return hashcode.String(buf.String()) -} - -func resourceAzureRMContainerServiceServicePrincipalProfileHash(v interface{}) int { - var buf bytes.Buffer - - if m, ok := v.(map[string]interface{}); ok { - buf.WriteString(fmt.Sprintf("%s-", m["client_id"].(string))) - } - - return hashcode.String(buf.String()) -} - -func resourceAzureRMContainerServiceDiagnosticProfilesHash(v interface{}) int { - var buf bytes.Buffer - - if m, ok := v.(map[string]interface{}); ok { - buf.WriteString(fmt.Sprintf("%t", m["enabled"].(bool))) - } - - return hashcode.String(buf.String()) -} - -func ValidateArmContainerServiceOrchestrationPlatform(v interface{}, _ string) (warnings []string, errors []error) { - value := v.(string) - capacities := map[string]bool{ - "DCOS": true, - "Kubernetes": true, - "Swarm": true, - } - - if !capacities[value] { - errors = append(errors, fmt.Errorf("Container Service: Orchestration Platgorm can only be DCOS / Kubernetes / Swarm")) - } - return warnings, errors -} - -func ValidateArmContainerServiceMasterProfileCount(v interface{}, _ string) (warnings []string, errors []error) { - value := v.(int) - capacities := map[int]bool{ - 1: true, - 3: true, - 5: true, - } - - if !capacities[value] { - errors = append(errors, fmt.Errorf("The number of master nodes must be 1, 3 or 5.")) - } - return warnings, errors -} - -func ValidateArmContainerServiceAgentPoolProfileCount(v interface{}, _ string) (warnings []string, errors []error) { - value := v.(int) - if value > 100 || 0 >= value { - errors = append(errors, fmt.Errorf("The Count for an Agent Pool Profile can only be between 1 and 100.")) - } - return warnings, errors -} diff --git a/azurerm/internal/services/containers/tests/resource_arm_container_service_test.go b/azurerm/internal/services/containers/tests/resource_arm_container_service_test.go deleted file mode 100644 index 0465943fef9a..000000000000 --- a/azurerm/internal/services/containers/tests/resource_arm_container_service_test.go +++ /dev/null @@ -1,451 +0,0 @@ -package tests - -import ( - "fmt" - "net/http" - "os" - "testing" - - "github.com/hashicorp/terraform-plugin-sdk/helper/resource" - "github.com/hashicorp/terraform-plugin-sdk/terraform" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/acceptance" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/clients" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/features" - "github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/containers" -) - -func TestAccAzureRMContainerService_orchestrationPlatformValidation(t *testing.T) { - cases := []struct { - Value string - ErrCount int - }{ - {Value: "DCOS", ErrCount: 0}, - {Value: "Kubernetes", ErrCount: 0}, - {Value: "Swarm", ErrCount: 0}, - {Value: "Mesos", ErrCount: 1}, - } - - for _, tc := range cases { - _, errors := containers.ValidateArmContainerServiceOrchestrationPlatform(tc.Value, "azurerm_container_service") - - if len(errors) != tc.ErrCount { - t.Fatalf("Expected the Azure RM Container Service Orchestration Platform to trigger a validation error for '%s'", tc.Value) - } - } -} - -func TestAccAzureRMContainerService_masterProfileCountValidation(t *testing.T) { - cases := []struct { - Value int - ErrCount int - }{ - {Value: 0, ErrCount: 1}, - {Value: 1, ErrCount: 0}, - {Value: 2, ErrCount: 1}, - {Value: 3, ErrCount: 0}, - {Value: 4, ErrCount: 1}, - {Value: 5, ErrCount: 0}, - {Value: 6, ErrCount: 1}, - } - - for _, tc := range cases { - _, errors := containers.ValidateArmContainerServiceMasterProfileCount(tc.Value, "azurerm_container_service") - - if len(errors) != tc.ErrCount { - t.Fatalf("Expected the Azure RM Container Service Master Profile Count to trigger a validation error for '%d'", tc.Value) - } - } -} - -func TestAccAzureRMContainerService_agentProfilePoolCountValidation(t *testing.T) { - cases := []struct { - Value int - ErrCount int - }{ - {Value: 0, ErrCount: 1}, - {Value: 1, ErrCount: 0}, - {Value: 2, ErrCount: 0}, - {Value: 99, ErrCount: 0}, - {Value: 100, ErrCount: 0}, - {Value: 101, ErrCount: 1}, - } - - for _, tc := range cases { - _, errors := containers.ValidateArmContainerServiceAgentPoolProfileCount(tc.Value, "azurerm_container_service") - - if len(errors) != tc.ErrCount { - t.Fatalf("Expected the Azure RM Container Service Agent Pool Profile Count to trigger a validation error for '%d'", tc.Value) - } - } -} - -func TestAccAzureRMContainerService_dcosBasic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_container_service", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMContainerServiceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMContainerService_dcosBasic(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMContainerServiceExists("azurerm_container_service.test"), - ), - }, - }, - }) -} - -func TestAccAzureRMContainerService_requiresImport(t *testing.T) { - if !features.ShouldResourcesBeImported() { - t.Skip("Skipping since resources aren't required to be imported") - return - } - - data := acceptance.BuildTestData(t, "azurerm_container_service", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMContainerServiceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMContainerService_dcosBasic(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMContainerServiceExists("azurerm_container_service.test"), - ), - }, - { - Config: testAccAzureRMContainerService_requiresImport(data), - ExpectError: acceptance.RequiresImportError("azurerm_container_service"), - }, - }, - }) -} - -func TestAccAzureRMContainerService_kubernetesBasic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_container_service", "test") - clientId := os.Getenv("ARM_CLIENT_ID") - clientSecret := os.Getenv("ARM_CLIENT_SECRET") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMContainerServiceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMContainerService_kubernetesBasic(data, clientId, clientSecret), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMContainerServiceExists("azurerm_container_service.test"), - ), - }, - }, - }) -} - -func TestAccAzureRMContainerService_kubernetesComplete(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_container_service", "test") - clientId := os.Getenv("ARM_CLIENT_ID") - clientSecret := os.Getenv("ARM_CLIENT_SECRET") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMContainerServiceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMContainerService_kubernetesComplete(data, clientId, clientSecret), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMContainerServiceExists("azurerm_container_service.test"), - ), - }, - }, - }) -} - -func TestAccAzureRMContainerService_swarmBasic(t *testing.T) { - data := acceptance.BuildTestData(t, "azurerm_container_service", "test") - - resource.ParallelTest(t, resource.TestCase{ - PreCheck: func() { acceptance.PreCheck(t) }, - Providers: acceptance.SupportedProviders, - CheckDestroy: testCheckAzureRMContainerServiceDestroy, - Steps: []resource.TestStep{ - { - Config: testAccAzureRMContainerService_swarmBasic(data), - Check: resource.ComposeTestCheckFunc( - testCheckAzureRMContainerServiceExists("azurerm_container_service.test"), - ), - }, - }, - }) -} - -func testAccAzureRMContainerService_dcosBasic(data acceptance.TestData) string { - return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" -} - -resource "azurerm_container_service" "test" { - name = "acctestcontservice%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - orchestration_platform = "DCOS" - - master_profile { - count = 1 - dns_prefix = "acctestmaster%d" - } - - linux_profile { - admin_username = "acctestuser%d" - - ssh_key { - key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" - } - } - - agent_pool_profile { - name = "default" - count = 1 - dns_prefix = "acctestagent%d" - vm_size = "Standard_F2" - } - - diagnostics_profile { - enabled = false - } -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) -} - -func testAccAzureRMContainerService_requiresImport(data acceptance.TestData) string { - template := testAccAzureRMContainerService_dcosBasic(data) - return fmt.Sprintf(` -%s - -resource "azurerm_container_service" "import" { - name = "${azurerm_container_service.test.name}" - location = "${azurerm_container_service.test.location}" - resource_group_name = "${azurerm_container_service.test.resource_group_name}" - orchestration_platform = "DCOS" - - master_profile { - count = 1 - dns_prefix = "acctestmaster%d" - } - - linux_profile { - admin_username = "acctestuser%d" - - ssh_key { - key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" - } - } - - agent_pool_profile { - name = "default" - count = 1 - dns_prefix = "acctestagent%d" - vm_size = "Standard_F2" - } - - diagnostics_profile { - enabled = false - } -} -`, template, data.RandomInteger, data.RandomInteger, data.RandomInteger) -} - -func testAccAzureRMContainerService_kubernetesBasic(data acceptance.TestData, clientId string, clientSecret string) string { - return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" -} - -resource "azurerm_container_service" "test" { - name = "acctestcontservice%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - orchestration_platform = "Kubernetes" - - master_profile { - count = 1 - dns_prefix = "acctestmaster%d" - } - - linux_profile { - admin_username = "acctestuser%d" - - ssh_key { - key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" - } - } - - agent_pool_profile { - name = "default" - count = 1 - dns_prefix = "acctestagent%d" - vm_size = "Standard_F2" - } - - service_principal { - client_id = "%s" - client_secret = "%s" - } - - diagnostics_profile { - enabled = false - } -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, clientId, clientSecret) -} - -func testAccAzureRMContainerService_kubernetesComplete(data acceptance.TestData, clientId string, clientSecret string) string { - return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" -} - -resource "azurerm_container_service" "test" { - name = "acctestcontservice%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - orchestration_platform = "Kubernetes" - - master_profile { - count = 1 - dns_prefix = "acctestmaster%d" - } - - linux_profile { - admin_username = "acctestuser%d" - - ssh_key { - key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" - } - } - - agent_pool_profile { - name = "default" - count = 1 - dns_prefix = "acctestagent%d" - vm_size = "Standard_F2" - } - - service_principal { - client_id = "%s" - client_secret = "%s" - } - - diagnostics_profile { - enabled = false - } - - tags = { - you = "me" - } -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger, clientId, clientSecret) -} - -func testAccAzureRMContainerService_swarmBasic(data acceptance.TestData) string { - return fmt.Sprintf(` -resource "azurerm_resource_group" "test" { - name = "acctestRG-%d" - location = "%s" -} - -resource "azurerm_container_service" "test" { - name = "acctestcontservice%d" - location = "${azurerm_resource_group.test.location}" - resource_group_name = "${azurerm_resource_group.test.name}" - orchestration_platform = "Swarm" - - master_profile { - count = 1 - dns_prefix = "acctestmaster%d" - } - - linux_profile { - admin_username = "acctestuser%d" - - ssh_key { - key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" - } - } - - agent_pool_profile { - name = "default" - count = 1 - dns_prefix = "acctestagent%d" - vm_size = "Standard_F2" - } - - diagnostics_profile { - enabled = false - } -} -`, data.RandomInteger, data.Locations.Primary, data.RandomInteger, data.RandomInteger, data.RandomInteger, data.RandomInteger) -} - -func testCheckAzureRMContainerServiceExists(resourceName string) resource.TestCheckFunc { - return func(s *terraform.State) error { - conn := acceptance.AzureProvider.Meta().(*clients.Client).Containers.ServicesClient - ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext - - // Ensure we have enough information in state to look up in API - rs, ok := s.RootModule().Resources[resourceName] - if !ok { - return fmt.Errorf("Not found: %s", resourceName) - } - - name := rs.Primary.Attributes["name"] - resourceGroup, hasResourceGroup := rs.Primary.Attributes["resource_group_name"] - if !hasResourceGroup { - return fmt.Errorf("Bad: no resource group found in state for Container Service Instance: %s", name) - } - - resp, err := conn.Get(ctx, resourceGroup, name) - if err != nil { - return fmt.Errorf("Bad: Get on containerServicesClient: %+v", err) - } - - if resp.StatusCode == http.StatusNotFound { - return fmt.Errorf("Bad: Container Service Instance %q (resource group: %q) does not exist", name, resourceGroup) - } - - return nil - } -} - -func testCheckAzureRMContainerServiceDestroy(s *terraform.State) error { - conn := acceptance.AzureProvider.Meta().(*clients.Client).Containers.ServicesClient - ctx := acceptance.AzureProvider.Meta().(*clients.Client).StopContext - - for _, rs := range s.RootModule().Resources { - if rs.Type != "azurerm_container_service" { - continue - } - - name := rs.Primary.Attributes["name"] - resourceGroup := rs.Primary.Attributes["resource_group_name"] - - resp, err := conn.Get(ctx, resourceGroup, name) - - if err != nil { - return nil - } - - if resp.StatusCode != http.StatusNotFound { - return fmt.Errorf("Container Service Instance still exists:\n%#v", resp) - } - } - - return nil -} diff --git a/website/azurerm.erb b/website/azurerm.erb index 98933151ec5f..4c9dc925f71e 100644 --- a/website/azurerm.erb +++ b/website/azurerm.erb @@ -1048,10 +1048,6 @@ azurerm_container_registry_webhook -
  • - azurerm_container_service -
  • -
  • azurerm_kubernetes_cluster
  • diff --git a/website/docs/r/container_service.html.markdown b/website/docs/r/container_service.html.markdown deleted file mode 100644 index cbd774d0b056..000000000000 --- a/website/docs/r/container_service.html.markdown +++ /dev/null @@ -1,229 +0,0 @@ ---- -subcategory: "Container" -layout: "azurerm" -page_title: "Azure Resource Manager: azurerm_container_service" -description: |- - Manages an Azure Container Service instance. ---- - -# azurerm_container_service - -Manages an Azure Container Service Instance - -~> **NOTE:** All arguments including the client secret will be stored in the raw state as plain-text. -[Read more about sensitive data in state](/docs/state/sensitive-data.html). - -~> **DEPRECATED:** [Azure Container Service (ACS) has been deprecated by Azure in favour of Azure (Managed) Kubernetes Service (AKS)](https://azure.microsoft.com/en-us/updates/azure-container-service-will-retire-on-january-31-2020/). Support for ACS will be removed in the next major version of the AzureRM Provider (2.0) - and we **strongly recommend** you consider using [Azure Kubernetes Service (AKS)](kubernetes_cluster.html) for new deployments. - -## Example Usage (DCOS) - -```hcl -resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West US" -} - -resource "azurerm_container_service" "example" { - name = "acctestcontservice1" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - orchestration_platform = "DCOS" - - master_profile { - count = 1 - dns_prefix = "acctestmaster1" - } - - linux_profile { - admin_username = "acctestuser1" - - ssh_key { - key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" - } - } - - agent_pool_profile { - name = "default" - count = 1 - dns_prefix = "acctestagent1" - vm_size = "Standard_F2" - } - - diagnostics_profile { - enabled = false - } - - tags = { - Environment = "Production" - } -} -``` - -## Example Usage (Kubernetes) - -```hcl -resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West US" -} - -resource "azurerm_container_service" "example" { - name = "acctestcontservice1" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - orchestration_platform = "Kubernetes" - - master_profile { - count = 1 - dns_prefix = "acctestmaster1" - } - - linux_profile { - admin_username = "acctestuser1" - - ssh_key { - key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" - } - } - - agent_pool_profile { - name = "default" - count = 1 - dns_prefix = "acctestagent1" - vm_size = "Standard_F2" - } - - service_principal { - client_id = "00000000-0000-0000-0000-000000000000" - client_secret = "00000000000000000000000000000000" - } - - diagnostics_profile { - enabled = false - } - - tags = { - Environment = "Production" - } -} -``` - -## Example Usage (Swarm) - -```hcl -resource "azurerm_resource_group" "example" { - name = "example-resources" - location = "West US" -} - -resource "azurerm_container_service" "example" { - name = "acctestcontservice1" - location = azurerm_resource_group.example.location - resource_group_name = azurerm_resource_group.example.name - orchestration_platform = "Swarm" - - master_profile { - count = 1 - dns_prefix = "acctestmaster1" - } - - linux_profile { - admin_username = "acctestuser1" - - ssh_key { - key_data = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCqaZoyiz1qbdOQ8xEf6uEu1cCwYowo5FHtsBhqLoDnnp7KUTEBN+L2NxRIfQ781rxV6Iq5jSav6b2Q8z5KiseOlvKA/RF2wqU0UPYqQviQhLmW6THTpmrv/YkUCuzxDpsH7DUDhZcwySLKVVe0Qm3+5N2Ta6UYH3lsDf9R9wTP2K/+vAnflKebuypNlmocIvakFWoZda18FOmsOoIVXQ8HWFNCuw9ZCunMSN62QGamCe3dL5cXlkgHYv7ekJE15IA9aOJcM7e90oeTqo+7HTcWfdu0qQqPWY5ujyMw/llas8tsXY85LFqRnr3gJ02bAscjc477+X+j/gkpFoN1QEmt terraform@demo.tld" - } - } - - agent_pool_profile { - name = "default" - count = 1 - dns_prefix = "acctestagent1" - vm_size = "Standard_F2" - } - - diagnostics_profile { - enabled = false - } - - tags = { - Environment = "Production" - } -} -``` - -## Argument Reference - -The following arguments are supported: - -* `name` - (Required) The name of the Container Service instance to create. Changing this forces a new resource to be created. - -* `location` - (Required) The location where the Container Service instance should be created. Changing this forces a new resource to be created. - -* `resource_group_name` - (Required) Specifies the resource group where the resource exists. Changing this forces a new resource to be created. - -* `orchestration_platform` - (Required) Specifies the Container Orchestration Platform to use. Currently can be either `DCOS`, `Kubernetes` or `Swarm`. Changing this forces a new resource to be created. - -* `master_profile` - (Required) A Master Profile block as documented below. - -* `linux_profile` - (Required) A Linux Profile block as documented below. - -* `agent_pool_profile` - (Required) A Agent Pool Profile's block as documented below. - -* `service_principal` - (only Required when you're using `Kubernetes` as an Orchestration Platform) A Service Principal block as documented below. - -* `diagnostics_profile` - (Required) A VM Diagnostics Profile block as documented below. - -* `tags` - (Optional) A mapping of tags to assign to the resource. - - -`master_profile` supports the following: - -* `count` - (Required) Number of masters (VMs) in the container service cluster. Allowed values are 1, 3, and 5. The default value is 1. -* `dns_prefix` - (Required) The DNS Prefix to use for the Container Service master nodes. - -`linux_profile` supports the following: - -* `admin_username` - (Required) The Admin Username for the Cluster. -* `ssh_key` - (Required) An SSH Key block as documented below. - -`ssh_key` supports the following: - -* `key_data` - (Required) The Public SSH Key used to access the cluster. - -`agent_pool_profile` supports the following: - -* `name` - (Required) Unique name of the agent pool profile in the context of the subscription and resource group. -* `count` - (Required) Number of agents (VMs) to host docker containers. Allowed values must be in the range of 1 to 100 (inclusive). The default value is 1. -* `dns_prefix` - (Required) The DNS Prefix given to Agents in this Agent Pool. -* `vm_size` - (Required) The VM Size of each of the Agent Pool VM's (e.g. Standard_F1 / Standard_D2v2). - -`service_principal` supports the following: - -* `client_id` - (Required) The ID for the Service Principal. -* `client_secret` - (Required) The secret password associated with the service principal. - -`diagnostics_profile` supports the following: - -* `enabled` - (Required) Should VM Diagnostics be enabled for the Container Service VM's - -## Attributes Reference - -The following attributes are exported: - -* `id` - The Container Service ID. - -* `master_profile.fqdn` - FDQN for the master. - -* `agent_pool_profile.fqdn` - FDQN for the agent pool. - -* `diagnostics_profile.storage_uri` - The URI of the storage account where diagnostics are stored. - -## Timeouts - -The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/docs/configuration/resources.html#timeouts) for certain actions: - -* `create` - (Defaults to 90 minutes) Used when creating the Container Service. -* `update` - (Defaults to 90 minutes) Used when updating the Container Service. -* `read` - (Defaults to 5 minutes) Used when retrieving the Container Service. -* `delete` - (Defaults to 90 minutes) Used when deleting the Container Service.