provider/azurerm: Container Service (#10820)

* Importing v7.0.1 of the SDK

* Configuring the Container Service Client

* Scaffolding the Container Service resource

* Scaffolding the Website documentation

* Completing the documentation

* Acceptance Tests for Kubernetes Azure Container Service

* DCOS / Swarm tests

* Parsing values back from the API properly

* Fixing the test

* Service Principal can be optional. Because of course it can.

* Validation for the Container Service Count's

* Updating the docs

* Updating the field required values

* Making the documentation more explicit

* Fixing the build

* Examples for DCOS and Swarm

* Removing storage_uri for now

* Making the SSH Key required as per the docs

* Resolving the merge conflicts

* Removing the unused error's

* Adding Hash's to the schema's

* Switching out the provider registration

* Fixing the hash definitions

* Updating keydata to match

* Client Secret is sensitive

* List -> Set

* Using the first item for the diagnostic_profile

* Helps if you actually update the type

* Updating the docs to include the Computed fields

* Fixing comments / removing redundant optional checks

* Removing the FQDN's from the examples

* Moving the Container resources together
This commit is contained in:
Tom Harvey 2017-02-13 16:33:50 +00:00 committed by Paul Stack
parent 64fda44b00
commit f349309a8f
11 changed files with 2080 additions and 0 deletions

View File

@ -10,6 +10,7 @@ import (
"github.com/Azure/azure-sdk-for-go/arm/cdn" "github.com/Azure/azure-sdk-for-go/arm/cdn"
"github.com/Azure/azure-sdk-for-go/arm/compute" "github.com/Azure/azure-sdk-for-go/arm/compute"
"github.com/Azure/azure-sdk-for-go/arm/containerregistry" "github.com/Azure/azure-sdk-for-go/arm/containerregistry"
"github.com/Azure/azure-sdk-for-go/arm/containerservice"
"github.com/Azure/azure-sdk-for-go/arm/eventhub" "github.com/Azure/azure-sdk-for-go/arm/eventhub"
"github.com/Azure/azure-sdk-for-go/arm/keyvault" "github.com/Azure/azure-sdk-for-go/arm/keyvault"
"github.com/Azure/azure-sdk-for-go/arm/network" "github.com/Azure/azure-sdk-for-go/arm/network"
@ -66,6 +67,7 @@ type ArmClient struct {
cdnEndpointsClient cdn.EndpointsClient cdnEndpointsClient cdn.EndpointsClient
containerRegistryClient containerregistry.RegistriesClient containerRegistryClient containerregistry.RegistriesClient
containerServicesClient containerservice.ContainerServicesClient
eventHubClient eventhub.EventHubsClient eventHubClient eventhub.EventHubsClient
eventHubConsumerGroupClient eventhub.ConsumerGroupsClient eventHubConsumerGroupClient eventhub.ConsumerGroupsClient
@ -237,6 +239,12 @@ func (c *Config) getArmClient() (*ArmClient, error) {
crc.Sender = autorest.CreateSender(withRequestLogging()) crc.Sender = autorest.CreateSender(withRequestLogging())
client.containerRegistryClient = crc client.containerRegistryClient = crc
csc := containerservice.NewContainerServicesClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&csc.Client)
csc.Authorizer = spt
csc.Sender = autorest.CreateSender(withRequestLogging())
client.containerServicesClient = csc
ehc := eventhub.NewEventHubsClientWithBaseURI(endpoint, c.SubscriptionID) ehc := eventhub.NewEventHubsClientWithBaseURI(endpoint, c.SubscriptionID)
setUserAgent(&ehc.Client) setUserAgent(&ehc.Client)
ehc.Authorizer = spt ehc.Authorizer = spt

View File

@ -68,6 +68,7 @@ func Provider() terraform.ResourceProvider {
"azurerm_cdn_endpoint": resourceArmCdnEndpoint(), "azurerm_cdn_endpoint": resourceArmCdnEndpoint(),
"azurerm_cdn_profile": resourceArmCdnProfile(), "azurerm_cdn_profile": resourceArmCdnProfile(),
"azurerm_container_registry": resourceArmContainerRegistry(), "azurerm_container_registry": resourceArmContainerRegistry(),
"azurerm_container_service": resourceArmContainerService(),
"azurerm_eventhub": resourceArmEventHub(), "azurerm_eventhub": resourceArmEventHub(),
"azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(), "azurerm_eventhub_authorization_rule": resourceArmEventHubAuthorizationRule(),
@ -232,6 +233,7 @@ func registerAzureResourceProvidersWithSubscription(providerList []resources.Pro
"Microsoft.Compute": struct{}{}, "Microsoft.Compute": struct{}{},
"Microsoft.Cache": struct{}{}, "Microsoft.Cache": struct{}{},
"Microsoft.ContainerRegistry": struct{}{}, "Microsoft.ContainerRegistry": struct{}{},
"Microsoft.ContainerService": struct{}{},
"Microsoft.Network": struct{}{}, "Microsoft.Network": struct{}{},
"Microsoft.Cdn": struct{}{}, "Microsoft.Cdn": struct{}{},
"Microsoft.Storage": struct{}{}, "Microsoft.Storage": struct{}{},

View File

@ -0,0 +1,647 @@
package azurerm
import (
"fmt"
"log"
"net/http"
"time"
"bytes"
"github.com/Azure/azure-sdk-for-go/arm/containerservice"
"github.com/hashicorp/terraform/helper/hashcode"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/helper/schema"
)
func resourceArmContainerService() *schema.Resource {
return &schema.Resource{
Create: resourceArmContainerServiceCreate,
Read: resourceArmContainerServiceRead,
Update: resourceArmContainerServiceCreate,
Delete: resourceArmContainerServiceDelete,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"location": locationSchema(),
"resource_group_name": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"orchestration_platform": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validateArmContainerServiceOrchestrationPlatform,
},
"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,
},
"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,
},
"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,
},
},
},
Set: resourceAzureRMContainerServiceAgentPoolProfilesHash,
},
"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,
},
"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": tagsSchema(),
},
}
}
func resourceArmContainerServiceCreate(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient)
containerServiceClient := client.containerServicesClient
log.Printf("[INFO] preparing arguments for Azure ARM Container Service creation.")
resGroup := d.Get("resource_group_name").(string)
name := d.Get("name").(string)
location := d.Get("location").(string)
orchestrationPlatform := d.Get("orchestration_platform").(string)
masterProfile := expandAzureRmContainerServiceMasterProfile(d)
linuxProfile := expandAzureRmContainerServiceLinuxProfile(d)
agentProfiles := expandAzureRmContainerServiceAgentProfiles(d)
diagnosticsProfile := expandAzureRmContainerServiceDiagnostics(d)
tags := d.Get("tags").(map[string]interface{})
parameters := containerservice.ContainerService{
Name: &name,
Location: &location,
Properties: &containerservice.Properties{
MasterProfile: &masterProfile,
LinuxProfile: &linuxProfile,
OrchestratorProfile: &containerservice.OrchestratorProfile{
OrchestratorType: containerservice.OchestratorTypes(orchestrationPlatform),
},
AgentPoolProfiles: &agentProfiles,
DiagnosticsProfile: &diagnosticsProfile,
},
Tags: expandTags(tags),
}
servicePrincipalProfile := expandAzureRmContainerServiceServicePrincipal(d)
if servicePrincipalProfile != nil {
parameters.ServicePrincipalProfile = servicePrincipalProfile
}
_, err := containerServiceClient.CreateOrUpdate(resGroup, name, parameters, make(chan struct{}))
if err != nil {
return err
}
read, err := containerServiceClient.Get(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(client, resGroup, name),
Timeout: 30 * time.Minute,
MinTimeout: 15 * time.Second,
}
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.(*ArmClient).containerServicesClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
resGroup := id.ResourceGroup
name := id.Path["containerServices"]
resp, err := containerServiceClient.Get(resGroup, name)
if err != nil {
return fmt.Errorf("Error making Read request on Azure Container Service %s: %s", name, err)
}
if resp.StatusCode == http.StatusNotFound {
d.SetId("")
return nil
}
d.Set("name", resp.Name)
d.Set("location", azureRMNormalizeLocation(*resp.Location))
d.Set("resource_group_name", resGroup)
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)
}
flattenAndSetTags(d, resp.Tags)
return nil
}
func resourceArmContainerServiceDelete(d *schema.ResourceData, meta interface{}) error {
client := meta.(*ArmClient)
containerServiceClient := client.containerServicesClient
id, err := parseAzureResourceID(d.Id())
if err != nil {
return err
}
resGroup := id.ResourceGroup
name := id.Path["containerServices"]
resp, err := containerServiceClient.Delete(resGroup, name, make(chan struct{}))
if err != nil {
return err
}
if resp.StatusCode != http.StatusOK {
return fmt.Errorf("Error issuing Azure ARM delete request of Container Service '%s': %s", name, err)
}
return nil
}
func flattenAzureRmContainerServiceMasterProfile(profile containerservice.MasterProfile) schema.Set {
masterProfiles := schema.Set{
F: resourceAzureRMContainerServiceMasterProfileHash,
}
masterProfile := make(map[string]interface{}, 2)
masterProfile["count"] = int(*profile.Count)
masterProfile["dns_prefix"] = *profile.DNSPrefix
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()
profile := containerservice.DiagnosticsProfile{}
data := configs[0].(map[string]interface{})
enabled := data["enabled"].(bool)
profile = containerservice.DiagnosticsProfile{
VMDiagnostics: &containerservice.VMDiagnostics{
Enabled: &enabled,
},
}
return profile
}
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 := []containerservice.SSHPublicKey{}
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(client *ArmClient, resourceGroupName string, containerServiceName string) resource.StateRefreshFunc {
return func() (interface{}, string, error) {
res, err := client.containerServicesClient.Get(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
m := v.(map[string]interface{})
count := m["count"].(int)
dnsPrefix := m["dns_prefix"].(string)
buf.WriteString(fmt.Sprintf("%d-", count))
buf.WriteString(fmt.Sprintf("%s-", dnsPrefix))
return hashcode.String(buf.String())
}
func resourceAzureRMContainerServiceLinuxProfilesHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
adminUsername := m["admin_username"].(string)
buf.WriteString(fmt.Sprintf("%s-", adminUsername))
return hashcode.String(buf.String())
}
func resourceAzureRMContainerServiceLinuxProfilesSSHKeysHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
keyData := m["key_data"].(string)
buf.WriteString(fmt.Sprintf("%s-", keyData))
return hashcode.String(buf.String())
}
func resourceAzureRMContainerServiceAgentPoolProfilesHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
count := m["count"].(int)
dnsPrefix := m["dns_prefix"].(string)
name := m["name"].(string)
vm_size := m["vm_size"].(string)
buf.WriteString(fmt.Sprintf("%d-", count))
buf.WriteString(fmt.Sprintf("%s-", dnsPrefix))
buf.WriteString(fmt.Sprintf("%s-", name))
buf.WriteString(fmt.Sprintf("%s-", vm_size))
return hashcode.String(buf.String())
}
func resourceAzureRMContainerServiceServicePrincipalProfileHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
clientId := m["client_id"].(string)
buf.WriteString(fmt.Sprintf("%s-", clientId))
return hashcode.String(buf.String())
}
func resourceAzureRMContainerServiceDiagnosticProfilesHash(v interface{}) int {
var buf bytes.Buffer
m := v.(map[string]interface{})
enabled := m["enabled"].(bool)
buf.WriteString(fmt.Sprintf("%t", enabled))
return hashcode.String(buf.String())
}
func validateArmContainerServiceOrchestrationPlatform(v interface{}, k string) (ws []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
}
func validateArmContainerServiceMasterProfileCount(v interface{}, k string) (ws []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
}
func validateArmContainerServiceAgentPoolProfileCount(v interface{}, k string) (ws []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
}

View File

@ -0,0 +1,372 @@
package azurerm
import (
"fmt"
"net/http"
"testing"
"github.com/hashicorp/terraform/helper/acctest"
"github.com/hashicorp/terraform/helper/resource"
"github.com/hashicorp/terraform/terraform"
)
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 := 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")
}
}
}
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 := 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")
}
}
}
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 := 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")
}
}
}
func TestAccAzureRMContainerService_dcosBasic(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMContainerService_dcosBasic, ri, ri, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMContainerServiceDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMContainerServiceExists("azurerm_container_service.test"),
),
},
},
})
}
func TestAccAzureRMContainerService_kubernetesBasic(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMContainerService_kubernetesBasic, ri, ri, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMContainerServiceDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMContainerServiceExists("azurerm_container_service.test"),
),
},
},
})
}
func TestAccAzureRMContainerService_kubernetesComplete(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMContainerService_kubernetesComplete, ri, ri, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMContainerServiceDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMContainerServiceExists("azurerm_container_service.test"),
),
},
},
})
}
func TestAccAzureRMContainerService_swarmBasic(t *testing.T) {
ri := acctest.RandInt()
config := fmt.Sprintf(testAccAzureRMContainerService_swarmBasic, ri, ri, ri, ri, ri)
resource.Test(t, resource.TestCase{
PreCheck: func() { testAccPreCheck(t) },
Providers: testAccProviders,
CheckDestroy: testCheckAzureRMContainerServiceDestroy,
Steps: []resource.TestStep{
{
Config: config,
Check: resource.ComposeTestCheckFunc(
testCheckAzureRMContainerServiceExists("azurerm_container_service.test"),
),
},
},
})
}
var testAccAzureRMContainerService_dcosBasic = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
}
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_A0"
}
diagnostics_profile {
enabled = false
}
}
`
var testAccAzureRMContainerService_kubernetesBasic = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
}
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_A0"
}
service_principal {
client_id = "00000000-0000-0000-0000-000000000000"
client_secret = "00000000000000000000000000000000"
}
diagnostics_profile {
enabled = false
}
}
`
var testAccAzureRMContainerService_kubernetesComplete = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
}
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_A0"
}
service_principal {
client_id = "00000000-0000-0000-0000-000000000000"
client_secret = "00000000000000000000000000000000"
}
diagnostics_profile {
enabled = false
}
tags {
you = "me"
}
}
`
var testAccAzureRMContainerService_swarmBasic = `
resource "azurerm_resource_group" "test" {
name = "acctestRG-%d"
location = "West US"
}
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_A0"
}
diagnostics_profile {
enabled = false
}
}
`
func testCheckAzureRMContainerServiceExists(name string) resource.TestCheckFunc {
return func(s *terraform.State) error {
// Ensure we have enough information in state to look up in API
rs, ok := s.RootModule().Resources[name]
if !ok {
return fmt.Errorf("Not found: %s", name)
}
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)
}
conn := testAccProvider.Meta().(*ArmClient).containerServicesClient
resp, err := conn.Get(resourceGroup, name)
if err != nil {
return fmt.Errorf("Bad: Get on containerServicesClient: %s", 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 := testAccProvider.Meta().(*ArmClient).containerServicesClient
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(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
}

View File

@ -0,0 +1,58 @@
// Package containerservice implements the Azure ARM Containerservice service
// API version 2016-09-30.
//
// The Container Service Client.
package containerservice
// 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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
)
const (
// APIVersion is the version of the Containerservice
APIVersion = "2016-09-30"
// DefaultBaseURI is the default URI used for the service Containerservice
DefaultBaseURI = "https://management.azure.com"
)
// ManagementClient is the base client for Containerservice.
type ManagementClient struct {
autorest.Client
BaseURI string
APIVersion string
SubscriptionID string
}
// New creates an instance of the ManagementClient client.
func New(subscriptionID string) ManagementClient {
return NewWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewWithBaseURI creates an instance of the ManagementClient client.
func NewWithBaseURI(baseURI string, subscriptionID string) ManagementClient {
return ManagementClient{
Client: autorest.NewClientWithUserAgent(UserAgent()),
BaseURI: baseURI,
APIVersion: APIVersion,
SubscriptionID: subscriptionID,
}
}

View File

@ -0,0 +1,464 @@
package containerservice
// 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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/azure"
"github.com/Azure/go-autorest/autorest/validation"
"net/http"
)
// ContainerServicesClient is the the Container Service Client.
type ContainerServicesClient struct {
ManagementClient
}
// NewContainerServicesClient creates an instance of the
// ContainerServicesClient client.
func NewContainerServicesClient(subscriptionID string) ContainerServicesClient {
return NewContainerServicesClientWithBaseURI(DefaultBaseURI, subscriptionID)
}
// NewContainerServicesClientWithBaseURI creates an instance of the
// ContainerServicesClient client.
func NewContainerServicesClientWithBaseURI(baseURI string, subscriptionID string) ContainerServicesClient {
return ContainerServicesClient{NewWithBaseURI(baseURI, subscriptionID)}
}
// CreateOrUpdate creates or updates a container service with the specified
// configuration of orchestrator, masters, and agents. This method may poll
// for completion. Polling can be canceled by passing the cancel channel
// argument. The channel will be used to cancel polling and any outstanding
// HTTP requests.
//
// resourceGroupName is the name of the resource group. containerServiceName
// is the name of the container service in the specified subscription and
// resource group. parameters is parameters supplied to the Create or Update
// a Container Service operation.
func (client ContainerServicesClient) CreateOrUpdate(resourceGroupName string, containerServiceName string, parameters ContainerService, cancel <-chan struct{}) (result autorest.Response, err error) {
if err := validation.Validate([]validation.Validation{
{TargetValue: parameters,
Constraints: []validation.Constraint{{Target: "parameters.Properties", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.Properties.CustomProfile", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.Properties.CustomProfile.Orchestrator", Name: validation.Null, Rule: true, Chain: nil}}},
{Target: "parameters.Properties.ServicePrincipalProfile", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.Properties.ServicePrincipalProfile.ClientID", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Properties.ServicePrincipalProfile.Secret", Name: validation.Null, Rule: true, Chain: nil},
}},
{Target: "parameters.Properties.MasterProfile", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.MasterProfile.DNSPrefix", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Properties.MasterProfile.Fqdn", Name: validation.ReadOnly, Rule: true, Chain: nil},
}},
{Target: "parameters.Properties.AgentPoolProfiles", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Properties.WindowsProfile", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.Properties.WindowsProfile.AdminUsername", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.WindowsProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-zA-Z0-9]+([._]?[a-zA-Z0-9]+)*$`, Chain: nil}}},
{Target: "parameters.Properties.WindowsProfile.AdminPassword", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.WindowsProfile.AdminPassword", Name: validation.Pattern, Rule: `^(?=.*[a-z])(?=.*[A-Z])(?=.*[!@#$%\^&\*\(\)])[a-zA-Z\d!@#$%\^&\*\(\)]{12,123}$`, Chain: nil}}},
}},
{Target: "parameters.Properties.LinuxProfile", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.LinuxProfile.AdminUsername", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.LinuxProfile.AdminUsername", Name: validation.Pattern, Rule: `^[a-z][a-z0-9_-]*$`, Chain: nil}}},
{Target: "parameters.Properties.LinuxProfile.SSH", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.LinuxProfile.SSH.PublicKeys", Name: validation.Null, Rule: true, Chain: nil}}},
}},
{Target: "parameters.Properties.DiagnosticsProfile", Name: validation.Null, Rule: false,
Chain: []validation.Constraint{{Target: "parameters.Properties.DiagnosticsProfile.VMDiagnostics", Name: validation.Null, Rule: true,
Chain: []validation.Constraint{{Target: "parameters.Properties.DiagnosticsProfile.VMDiagnostics.Enabled", Name: validation.Null, Rule: true, Chain: nil},
{Target: "parameters.Properties.DiagnosticsProfile.VMDiagnostics.StorageURI", Name: validation.ReadOnly, Rule: true, Chain: nil},
}},
}},
{Target: "parameters.Properties.ProvisioningState", Name: validation.ReadOnly, Rule: true, Chain: nil},
}}}}}); err != nil {
return result, validation.NewErrorWithValidationError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate")
}
req, err := client.CreateOrUpdatePreparer(resourceGroupName, containerServiceName, parameters, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", nil, "Failure preparing request")
}
resp, err := client.CreateOrUpdateSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure sending request")
}
result, err = client.CreateOrUpdateResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "CreateOrUpdate", resp, "Failure responding to request")
}
return
}
// CreateOrUpdatePreparer prepares the CreateOrUpdate request.
func (client ContainerServicesClient) CreateOrUpdatePreparer(resourceGroupName string, containerServiceName string, parameters ContainerService, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"containerServiceName": autorest.Encode("path", containerServiceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsJSON(),
autorest.AsPut(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
autorest.WithJSON(parameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// CreateOrUpdateSender sends the CreateOrUpdate request. The method will close the
// http.Response Body if it receives an error.
func (client ContainerServicesClient) CreateOrUpdateSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// CreateOrUpdateResponder handles the response to the CreateOrUpdate request. The method always
// closes the http.Response Body.
func (client ContainerServicesClient) CreateOrUpdateResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusCreated, http.StatusAccepted),
autorest.ByClosing())
result.Response = resp
return
}
// Delete deletes the specified container service in the specified
// subscription and resource group. The operation does not delete other
// resources created as part of creating a container service, including
// storage accounts, VMs, and availability sets. All the other resources
// created with the container service are part of the same resource group and
// can be deleted individually. This method may poll for completion. Polling
// can be canceled by passing the cancel channel argument. The channel will
// be used to cancel polling and any outstanding HTTP requests.
//
// resourceGroupName is the name of the resource group. containerServiceName
// is the name of the container service in the specified subscription and
// resource group.
func (client ContainerServicesClient) Delete(resourceGroupName string, containerServiceName string, cancel <-chan struct{}) (result autorest.Response, err error) {
req, err := client.DeletePreparer(resourceGroupName, containerServiceName, cancel)
if err != nil {
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", nil, "Failure preparing request")
}
resp, err := client.DeleteSender(req)
if err != nil {
result.Response = resp
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure sending request")
}
result, err = client.DeleteResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Delete", resp, "Failure responding to request")
}
return
}
// DeletePreparer prepares the Delete request.
func (client ContainerServicesClient) DeletePreparer(resourceGroupName string, containerServiceName string, cancel <-chan struct{}) (*http.Request, error) {
pathParameters := map[string]interface{}{
"containerServiceName": autorest.Encode("path", containerServiceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsDelete(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{Cancel: cancel})
}
// DeleteSender sends the Delete request. The method will close the
// http.Response Body if it receives an error.
func (client ContainerServicesClient) DeleteSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client,
req,
azure.DoPollForAsynchronous(client.PollingDelay))
}
// DeleteResponder handles the response to the Delete request. The method always
// closes the http.Response Body.
func (client ContainerServicesClient) DeleteResponder(resp *http.Response) (result autorest.Response, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK, http.StatusAccepted, http.StatusNoContent),
autorest.ByClosing())
result.Response = resp
return
}
// Get gets the properties of the specified container service in the specified
// subscription and resource group. The operation returns the properties
// including state, orchestrator, number of masters and agents, and FQDNs of
// masters and agents.
//
// resourceGroupName is the name of the resource group. containerServiceName
// is the name of the container service in the specified subscription and
// resource group.
func (client ContainerServicesClient) Get(resourceGroupName string, containerServiceName string) (result ContainerService, err error) {
req, err := client.GetPreparer(resourceGroupName, containerServiceName)
if err != nil {
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", nil, "Failure preparing request")
}
resp, err := client.GetSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", resp, "Failure sending request")
}
result, err = client.GetResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "Get", resp, "Failure responding to request")
}
return
}
// GetPreparer prepares the Get request.
func (client ContainerServicesClient) GetPreparer(resourceGroupName string, containerServiceName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"containerServiceName": autorest.Encode("path", containerServiceName),
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices/{containerServiceName}", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// GetSender sends the Get request. The method will close the
// http.Response Body if it receives an error.
func (client ContainerServicesClient) GetSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// GetResponder handles the response to the Get request. The method always
// closes the http.Response Body.
func (client ContainerServicesClient) GetResponder(resp *http.Response) (result ContainerService, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// List gets a list of container services in the specified subscription. The
// operation returns properties of each container service including state,
// orchestrator, number of masters and agents, and FQDNs of masters and
// agents.
func (client ContainerServicesClient) List() (result ListResult, err error) {
req, err := client.ListPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", nil, "Failure preparing request")
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure sending request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure responding to request")
}
return
}
// ListPreparer prepares the List request.
func (client ContainerServicesClient) ListPreparer() (*http.Request, error) {
pathParameters := map[string]interface{}{
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/providers/Microsoft.ContainerService/containerServices", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListSender sends the List request. The method will close the
// http.Response Body if it receives an error.
func (client ContainerServicesClient) ListSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListResponder handles the response to the List request. The method always
// closes the http.Response Body.
func (client ContainerServicesClient) ListResponder(resp *http.Response) (result ListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListNextResults retrieves the next set of results, if any.
func (client ContainerServicesClient) ListNextResults(lastResults ListResult) (result ListResult, err error) {
req, err := lastResults.ListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure sending next results request")
}
result, err = client.ListResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "List", resp, "Failure responding to next results request")
}
return
}
// ListByResourceGroup gets a list of container services in the specified
// subscription and resource group. The operation returns properties of each
// container service including state, orchestrator, number of masters and
// agents, and FQDNs of masters and agents.
//
// resourceGroupName is the name of the resource group.
func (client ContainerServicesClient) ListByResourceGroup(resourceGroupName string) (result ListResult, err error) {
req, err := client.ListByResourceGroupPreparer(resourceGroupName)
if err != nil {
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing request")
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending request")
}
result, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure responding to request")
}
return
}
// ListByResourceGroupPreparer prepares the ListByResourceGroup request.
func (client ContainerServicesClient) ListByResourceGroupPreparer(resourceGroupName string) (*http.Request, error) {
pathParameters := map[string]interface{}{
"resourceGroupName": autorest.Encode("path", resourceGroupName),
"subscriptionId": autorest.Encode("path", client.SubscriptionID),
}
queryParameters := map[string]interface{}{
"api-version": client.APIVersion,
}
preparer := autorest.CreatePreparer(
autorest.AsGet(),
autorest.WithBaseURL(client.BaseURI),
autorest.WithPathParameters("/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ContainerService/containerServices", pathParameters),
autorest.WithQueryParameters(queryParameters))
return preparer.Prepare(&http.Request{})
}
// ListByResourceGroupSender sends the ListByResourceGroup request. The method will close the
// http.Response Body if it receives an error.
func (client ContainerServicesClient) ListByResourceGroupSender(req *http.Request) (*http.Response, error) {
return autorest.SendWithSender(client, req)
}
// ListByResourceGroupResponder handles the response to the ListByResourceGroup request. The method always
// closes the http.Response Body.
func (client ContainerServicesClient) ListByResourceGroupResponder(resp *http.Response) (result ListResult, err error) {
err = autorest.Respond(
resp,
client.ByInspecting(),
azure.WithErrorUnlessStatusCode(http.StatusOK),
autorest.ByUnmarshallingJSON(&result),
autorest.ByClosing())
result.Response = autorest.Response{Response: resp}
return
}
// ListByResourceGroupNextResults retrieves the next set of results, if any.
func (client ContainerServicesClient) ListByResourceGroupNextResults(lastResults ListResult) (result ListResult, err error) {
req, err := lastResults.ListResultPreparer()
if err != nil {
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", nil, "Failure preparing next results request")
}
if req == nil {
return
}
resp, err := client.ListByResourceGroupSender(req)
if err != nil {
result.Response = autorest.Response{Response: resp}
return result, autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure sending next results request")
}
result, err = client.ListByResourceGroupResponder(resp)
if err != nil {
err = autorest.NewErrorWithError(err, "containerservice.ContainerServicesClient", "ListByResourceGroup", resp, "Failure responding to next results request")
}
return
}

View File

@ -0,0 +1,257 @@
package containerservice
// 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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"github.com/Azure/go-autorest/autorest"
"github.com/Azure/go-autorest/autorest/to"
"net/http"
)
// OchestratorTypes enumerates the values for ochestrator types.
type OchestratorTypes string
const (
// Custom specifies the custom state for ochestrator types.
Custom OchestratorTypes = "Custom"
// DCOS specifies the dcos state for ochestrator types.
DCOS OchestratorTypes = "DCOS"
// Kubernetes specifies the kubernetes state for ochestrator types.
Kubernetes OchestratorTypes = "Kubernetes"
// Swarm specifies the swarm state for ochestrator types.
Swarm OchestratorTypes = "Swarm"
)
// VMSizeTypes enumerates the values for vm size types.
type VMSizeTypes string
const (
// StandardA0 specifies the standard a0 state for vm size types.
StandardA0 VMSizeTypes = "Standard_A0"
// StandardA1 specifies the standard a1 state for vm size types.
StandardA1 VMSizeTypes = "Standard_A1"
// StandardA10 specifies the standard a10 state for vm size types.
StandardA10 VMSizeTypes = "Standard_A10"
// StandardA11 specifies the standard a11 state for vm size types.
StandardA11 VMSizeTypes = "Standard_A11"
// StandardA2 specifies the standard a2 state for vm size types.
StandardA2 VMSizeTypes = "Standard_A2"
// StandardA3 specifies the standard a3 state for vm size types.
StandardA3 VMSizeTypes = "Standard_A3"
// StandardA4 specifies the standard a4 state for vm size types.
StandardA4 VMSizeTypes = "Standard_A4"
// StandardA5 specifies the standard a5 state for vm size types.
StandardA5 VMSizeTypes = "Standard_A5"
// StandardA6 specifies the standard a6 state for vm size types.
StandardA6 VMSizeTypes = "Standard_A6"
// StandardA7 specifies the standard a7 state for vm size types.
StandardA7 VMSizeTypes = "Standard_A7"
// StandardA8 specifies the standard a8 state for vm size types.
StandardA8 VMSizeTypes = "Standard_A8"
// StandardA9 specifies the standard a9 state for vm size types.
StandardA9 VMSizeTypes = "Standard_A9"
// StandardD1 specifies the standard d1 state for vm size types.
StandardD1 VMSizeTypes = "Standard_D1"
// StandardD11 specifies the standard d11 state for vm size types.
StandardD11 VMSizeTypes = "Standard_D11"
// StandardD11V2 specifies the standard d11v2 state for vm size types.
StandardD11V2 VMSizeTypes = "Standard_D11_v2"
// StandardD12 specifies the standard d12 state for vm size types.
StandardD12 VMSizeTypes = "Standard_D12"
// StandardD12V2 specifies the standard d12v2 state for vm size types.
StandardD12V2 VMSizeTypes = "Standard_D12_v2"
// StandardD13 specifies the standard d13 state for vm size types.
StandardD13 VMSizeTypes = "Standard_D13"
// StandardD13V2 specifies the standard d13v2 state for vm size types.
StandardD13V2 VMSizeTypes = "Standard_D13_v2"
// StandardD14 specifies the standard d14 state for vm size types.
StandardD14 VMSizeTypes = "Standard_D14"
// StandardD14V2 specifies the standard d14v2 state for vm size types.
StandardD14V2 VMSizeTypes = "Standard_D14_v2"
// StandardD1V2 specifies the standard d1v2 state for vm size types.
StandardD1V2 VMSizeTypes = "Standard_D1_v2"
// StandardD2 specifies the standard d2 state for vm size types.
StandardD2 VMSizeTypes = "Standard_D2"
// StandardD2V2 specifies the standard d2v2 state for vm size types.
StandardD2V2 VMSizeTypes = "Standard_D2_v2"
// StandardD3 specifies the standard d3 state for vm size types.
StandardD3 VMSizeTypes = "Standard_D3"
// StandardD3V2 specifies the standard d3v2 state for vm size types.
StandardD3V2 VMSizeTypes = "Standard_D3_v2"
// StandardD4 specifies the standard d4 state for vm size types.
StandardD4 VMSizeTypes = "Standard_D4"
// StandardD4V2 specifies the standard d4v2 state for vm size types.
StandardD4V2 VMSizeTypes = "Standard_D4_v2"
// StandardD5V2 specifies the standard d5v2 state for vm size types.
StandardD5V2 VMSizeTypes = "Standard_D5_v2"
// StandardDS1 specifies the standard ds1 state for vm size types.
StandardDS1 VMSizeTypes = "Standard_DS1"
// StandardDS11 specifies the standard ds11 state for vm size types.
StandardDS11 VMSizeTypes = "Standard_DS11"
// StandardDS12 specifies the standard ds12 state for vm size types.
StandardDS12 VMSizeTypes = "Standard_DS12"
// StandardDS13 specifies the standard ds13 state for vm size types.
StandardDS13 VMSizeTypes = "Standard_DS13"
// StandardDS14 specifies the standard ds14 state for vm size types.
StandardDS14 VMSizeTypes = "Standard_DS14"
// StandardDS2 specifies the standard ds2 state for vm size types.
StandardDS2 VMSizeTypes = "Standard_DS2"
// StandardDS3 specifies the standard ds3 state for vm size types.
StandardDS3 VMSizeTypes = "Standard_DS3"
// StandardDS4 specifies the standard ds4 state for vm size types.
StandardDS4 VMSizeTypes = "Standard_DS4"
// StandardG1 specifies the standard g1 state for vm size types.
StandardG1 VMSizeTypes = "Standard_G1"
// StandardG2 specifies the standard g2 state for vm size types.
StandardG2 VMSizeTypes = "Standard_G2"
// StandardG3 specifies the standard g3 state for vm size types.
StandardG3 VMSizeTypes = "Standard_G3"
// StandardG4 specifies the standard g4 state for vm size types.
StandardG4 VMSizeTypes = "Standard_G4"
// StandardG5 specifies the standard g5 state for vm size types.
StandardG5 VMSizeTypes = "Standard_G5"
// StandardGS1 specifies the standard gs1 state for vm size types.
StandardGS1 VMSizeTypes = "Standard_GS1"
// StandardGS2 specifies the standard gs2 state for vm size types.
StandardGS2 VMSizeTypes = "Standard_GS2"
// StandardGS3 specifies the standard gs3 state for vm size types.
StandardGS3 VMSizeTypes = "Standard_GS3"
// StandardGS4 specifies the standard gs4 state for vm size types.
StandardGS4 VMSizeTypes = "Standard_GS4"
// StandardGS5 specifies the standard gs5 state for vm size types.
StandardGS5 VMSizeTypes = "Standard_GS5"
)
// AgentPoolProfile is profile for the container service agent pool.
type AgentPoolProfile struct {
Name *string `json:"name,omitempty"`
Count *int32 `json:"count,omitempty"`
VMSize VMSizeTypes `json:"vmSize,omitempty"`
DNSPrefix *string `json:"dnsPrefix,omitempty"`
Fqdn *string `json:"fqdn,omitempty"`
}
// ContainerService is container service.
type ContainerService struct {
autorest.Response `json:"-"`
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
*Properties `json:"properties,omitempty"`
}
// CustomProfile is properties to configure a custom container service cluster.
type CustomProfile struct {
Orchestrator *string `json:"orchestrator,omitempty"`
}
// DiagnosticsProfile is
type DiagnosticsProfile struct {
VMDiagnostics *VMDiagnostics `json:"vmDiagnostics,omitempty"`
}
// LinuxProfile is profile for Linux VMs in the container service cluster.
type LinuxProfile struct {
AdminUsername *string `json:"adminUsername,omitempty"`
SSH *SSHConfiguration `json:"ssh,omitempty"`
}
// ListResult is the response from the List Container Services operation.
type ListResult struct {
autorest.Response `json:"-"`
Value *[]ContainerService `json:"value,omitempty"`
NextLink *string `json:"nextLink,omitempty"`
}
// ListResultPreparer prepares a request to retrieve the next set of results. It returns
// nil if no more results exist.
func (client ListResult) ListResultPreparer() (*http.Request, error) {
if client.NextLink == nil || len(to.String(client.NextLink)) <= 0 {
return nil, nil
}
return autorest.Prepare(&http.Request{},
autorest.AsJSON(),
autorest.AsGet(),
autorest.WithBaseURL(to.String(client.NextLink)))
}
// MasterProfile is profile for the container service master.
type MasterProfile struct {
Count *int32 `json:"count,omitempty"`
DNSPrefix *string `json:"dnsPrefix,omitempty"`
Fqdn *string `json:"fqdn,omitempty"`
}
// OrchestratorProfile is profile for the container service orchestrator.
type OrchestratorProfile struct {
OrchestratorType OchestratorTypes `json:"orchestratorType,omitempty"`
}
// Properties is properties of the container service.
type Properties struct {
ProvisioningState *string `json:"provisioningState,omitempty"`
OrchestratorProfile *OrchestratorProfile `json:"orchestratorProfile,omitempty"`
CustomProfile *CustomProfile `json:"customProfile,omitempty"`
ServicePrincipalProfile *ServicePrincipalProfile `json:"servicePrincipalProfile,omitempty"`
MasterProfile *MasterProfile `json:"masterProfile,omitempty"`
AgentPoolProfiles *[]AgentPoolProfile `json:"agentPoolProfiles,omitempty"`
WindowsProfile *WindowsProfile `json:"windowsProfile,omitempty"`
LinuxProfile *LinuxProfile `json:"linuxProfile,omitempty"`
DiagnosticsProfile *DiagnosticsProfile `json:"diagnosticsProfile,omitempty"`
}
// Resource is the resource model definition.
type Resource struct {
ID *string `json:"id,omitempty"`
Name *string `json:"name,omitempty"`
Type *string `json:"type,omitempty"`
Location *string `json:"location,omitempty"`
Tags *map[string]*string `json:"tags,omitempty"`
}
// ServicePrincipalProfile is information about a service principal identity
// for the cluster to use for manipulating Azure APIs.
type ServicePrincipalProfile struct {
ClientID *string `json:"clientId,omitempty"`
Secret *string `json:"secret,omitempty"`
}
// SSHConfiguration is sSH configuration for Linux-based VMs running on Azure.
type SSHConfiguration struct {
PublicKeys *[]SSHPublicKey `json:"publicKeys,omitempty"`
}
// SSHPublicKey is contains information about SSH certificate public key data.
type SSHPublicKey struct {
KeyData *string `json:"keyData,omitempty"`
}
// VMDiagnostics is profile for diagnostics on the container service VMs.
type VMDiagnostics struct {
Enabled *bool `json:"enabled,omitempty"`
StorageURI *string `json:"storageUri,omitempty"`
}
// WindowsProfile is profile for Windows VMs in the container service cluster.
type WindowsProfile struct {
AdminUsername *string `json:"adminUsername,omitempty"`
AdminPassword *string `json:"adminPassword,omitempty"`
}

View File

@ -0,0 +1,43 @@
package containerservice
// 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 0.17.0.0
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
import (
"fmt"
)
const (
major = "7"
minor = "0"
patch = "1"
// Always begin a "tag" with a dash (as per http://semver.org)
tag = "-beta"
semVerFormat = "%s.%s.%s%s"
userAgentFormat = "Azure-SDK-for-Go/%s arm-%s/%s"
)
// UserAgent returns the UserAgent string to use when sending http.Requests.
func UserAgent() string {
return fmt.Sprintf(userAgentFormat, Version(), "containerservice", "2016-09-30")
}
// Version returns the semantic version (see http://semver.org) of the client.
func Version() string {
return fmt.Sprintf(semVerFormat, major, minor, patch, tag)
}

9
vendor/vendor.json vendored
View File

@ -41,6 +41,15 @@
"version": "v7.0.1-beta", "version": "v7.0.1-beta",
"versionExact": "v7.0.1-beta" "versionExact": "v7.0.1-beta"
}, },
{
"checksumSHA1": "NJGBM6QQwUQEhaCBZlN9sCoaBZE=",
"comment": "v2.1.1-beta-8-gca4d906",
"path": "github.com/Azure/azure-sdk-for-go/arm/containerservice",
"revision": "0984e0641ae43b89283223034574d6465be93bf4",
"revisionTime": "2016-11-30T22:29:01Z",
"version": "v7.0.1-beta",
"versionExact": "v7.0.1-beta"
},
{ {
"checksumSHA1": "NJGBM6QQwUQEhaCBZlN9sCoaBZE=", "checksumSHA1": "NJGBM6QQwUQEhaCBZlN9sCoaBZE=",
"comment": "v2.1.1-beta-8-gca4d906", "comment": "v2.1.1-beta-8-gca4d906",

View File

@ -0,0 +1,216 @@
---
layout: "azurerm"
page_title: "Azure Resource Manager: azurerm_container_service"
sidebar_current: "docs-azurerm-resource-container-service"
description: |-
Creates an Azure Container Service instance.
---
# azurerm\_container\_service
Creates an Azure Container Service Instance
## Example Usage (DCOS)
```
resource "azurerm_resource_group" "test" {
name = "acctestRG1"
location = "West US"
}
resource "azurerm_container_service" "test" {
name = "acctestcontservice1"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
orchestration_platform = "DCOS"
master_profile {
count = 1
dns_prefix = "acctestmaster1"
}
linux_profile {
admin_username = "acctestuser1"
ssh_keys {
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"
fqdn = "you.demo.com"
vm_size = "Standard_A0"
}
diagnostics_profile {
enabled = false
}
tags {
Environment = "Production"
}
}
```
## Example Usage (Kubernetes)
```
resource "azurerm_resource_group" "test" {
name = "acctestRG1"
location = "West US"
}
resource "azurerm_container_service" "test" {
name = "acctestcontservice1"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
orchestration_platform = "Kubernetes"
master_profile {
count = 1
dns_prefix = "acctestmaster1"
}
linux_profile {
admin_username = "acctestuser1"
ssh_keys {
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"
fqdn = "you.demo.com"
vm_size = "Standard_A0"
}
service_principal {
client_id = "00000000-0000-0000-0000-000000000000"
client_secret = "00000000000000000000000000000000"
}
diagnostics_profile {
enabled = false
}
tags {
Environment = "Production"
}
}
```
## Example Usage (Swarm)
```
resource "azurerm_resource_group" "test" {
name = "acctestRG1"
location = "West US"
}
resource "azurerm_container_service" "test" {
name = "acctestcontservice1"
location = "${azurerm_resource_group.test.location}"
resource_group_name = "${azurerm_resource_group.test.name}"
orchestration_platform = "Swarm"
master_profile {
count = 1
dns_prefix = "acctestmaster1"
}
linux_profile {
admin_username = "acctestuser1"
ssh_keys {
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"
fqdn = "you.demo.com"
vm_size = "Standard_A0"
}
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) One or more 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. The certificate must be in PEM format with or without headers.
`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 FQDN associated with the Master Profile.

View File

@ -52,6 +52,10 @@
<a href="/docs/providers/azurerm/r/container_registry.html">azurerm_container_registry</a> <a href="/docs/providers/azurerm/r/container_registry.html">azurerm_container_registry</a>
</li> </li>
<li<%= sidebar_current("docs-azurerm-resource-container-service") %>>
<a href="/docs/providers/azurerm/r/container_service.html">azurerm_container_service</a>
</li>
</ul> </ul>
</li> </li>