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

Changed admin_username and key_data to require a new resource. #904

Merged
merged 1 commit into from
Feb 28, 2018
Merged
Show file tree
Hide file tree
Changes from all 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
10 changes: 7 additions & 3 deletions azurerm/resource_arm_kubernetes_cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,13 @@ func resourceArmKubernetesCluster() *schema.Resource {
"admin_username": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
"ssh_key": {
Type: schema.TypeList,
Required: true,
ForceNew: true,

Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"key_data": {
Expand Down Expand Up @@ -376,9 +379,10 @@ func expandAzureRmKubernetesClusterLinuxProfile(d *schema.ResourceData) containe
adminUsername := config["admin_username"].(string)
linuxKeys := config["ssh_key"].([]interface{})

key := linuxKeys[0].(map[string]interface{})
keyData := key["key_data"].(string)

keyData := ""
if key, ok := linuxKeys[0].(map[string]interface{}); ok {
keyData = key["key_data"].(string)
}
sshPublicKey := containerservice.SSHPublicKey{
KeyData: &keyData,
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor this'd probably be simpler as:

sshPublicKey := containerservice.SSHPublicKey{}
if key, ok := linuxKeys[0].(map[string]interface{}); ok {
  keyData = key["key_data"].(string)
  sshPublicKey.KeyData = &keyData
}

Expand Down
2 changes: 1 addition & 1 deletion examples/aci-linux-multi/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ resource "azurerm_resource_group" "aci-rg" {
location = "${var.resource_group_location}"
}

#an attempt to keep the aci container group name (an dns label) somewhat omunique
#an attempt to keep the aci container group name (and dns label) somewhat unique
resource "random_integer" "random_int" {
min = 100
max = 999
Expand Down
39 changes: 39 additions & 0 deletions examples/kubernetes-cluster/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
resource "azurerm_resource_group" "akc-rg" {
name = "${var.resource_group_name}"
location = "${var.resource_group_location}"
}

#an attempt to keep the aci container group name (and dns label) somewhat unique
resource "random_integer" "random_int" {
min = 100
max = 999
}

resource "azurerm_kubernetes_cluster" "aks_container" {
name = "akc-${random_integer.random_int.result}"
location = "${var.resource_group_location}"
dns_prefix = "akc-${random_integer.random_int.result}"

resource_group_name = "${azurerm_resource_group.akc-rg.name}"
kubernetes_version = "1.8.7"


linux_profile {
admin_username = "${var.linux_admin_username}"
ssh_key {
key_data = "${var.linux_admin_ssh_publickey}"
}
}

agent_pool_profile {
name = "agentpool"
count = "2"
vm_size = "Standard_DS2_v2"
os_type = "Linux"
}

service_principal {
client_id = "${var.client_id}"
client_secret = "${var.client_secret}"
}
}
4 changes: 4 additions & 0 deletions examples/kubernetes-cluster/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

output "id" {
value = "${azurerm_kubernetes_cluster.aks_container.id}"
}
37 changes: 37 additions & 0 deletions examples/kubernetes-cluster/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
variable "name" {
type = "string"
description = "Name of this cluster."
default = "akc-example"
}

variable "client_id" {
type = "string"
description = "Client ID"
}

variable "client_secret" {
type = "string"
description = "Client secret."
}

variable "resource_group_name" {
type = "string"
description = "Name of the azure resource group."
default = "akc-rg"
}

variable "resource_group_location" {
type = "string"
description = "Location of the azure resource group."
default = "eastus"
}

variable "linux_admin_username" {
type = "string"
description = "User name for authentication to the Kubernetes linux agent virtual machines in the cluster."
}

variable "linux_admin_ssh_publickey" {
type = "string"
description = "Configure all the linux virtual machines in the cluster with the SSH RSA public key string. The key should include three parts, for example 'ssh-rsa AAAAB...snip...UcyupgH azureuser@linuxvm'"
}
6 changes: 3 additions & 3 deletions website/docs/r/kubernetes_cluster.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,12 @@ The following arguments are supported:

`linux_profile` supports the following:

* `admin_username` - (Required) The Admin Username for the Cluster.
* `admin_username` - (Required) The Admin Username for the Cluster. Changing this forces a new resource to be created.
* `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.
* `key_data` - (Required) The Public SSH Key used to access the cluster. Changing this forces a new resource to be created.

`agent_pool_profile` supports the following:

Expand All @@ -105,7 +105,7 @@ The following attributes are exported:

* `id` - The Kubernetes Managed Cluster ID.

* `fqdn` - The FQDN of the Azure Kubernetes Managed Cluster.
* `agent_pool_profile.#.fqdn` - The FQDN of the Azure Kubernetes Managed Cluster.

## Import

Expand Down