Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Fixes for handling the dns_prefix property of an AKS cluster #2611

Merged
merged 4 commits into from
Jan 8, 2019
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions azurerm/resource_arm_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ func resourceArmKubernetesCluster() *schema.Resource {
"resource_group_name": resourceGroupNameSchema(),

"dns_prefix": {
Type: schema.TypeString,
Required: true,
Type: schema.TypeString,
Required: true,
ForceNew: true,
ValidateFunc: validateKubernetesClusterDnsPrefix(),
},

"kubernetes_version": {
Expand Down Expand Up @@ -1123,6 +1125,13 @@ func validateKubernetesClusterAgentPoolName() schema.SchemaValidateFunc {
)
}

func validateKubernetesClusterDnsPrefix() schema.SchemaValidateFunc {
return validation.StringMatch(
regexp.MustCompile("^[a-zA-Z][a-zA-Z0-9\\-]{0,43}[a-zA-Z0-9]$"),
"The DNS name must contain between 3 and 45 characters. The name can contain only letters, numbers, and hyphens. The name must start with a letter and must end with a letter or a number.",
)
}

func flattenKubernetesClusterKubeConfig(config kubernetes.KubeConfig) []interface{} {
values := make(map[string]interface{})

Expand Down
4 changes: 3 additions & 1 deletion website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ The following arguments are supported:

* `agent_pool_profile` - (Required) One or more `agent_pool_profile` blocks as documented below.

* `dns_prefix` - (Required) DNS prefix specified when creating the managed cluster.
* `dns_prefix` - (Required) DNS prefix specified when creating the managed cluster. Changing this forces a new resource to be created.

-> **NOTE:** The `dns_prefix` must contain between 3 and 45 characters, and can contain only letters, numbers, and hyphens. It must start with a letter and must end with a letter or a number.

* `service_principal` - (Required) A `service_principal` block as documented below.

Expand Down