Skip to content

Commit 248f6c3

Browse files
committed
azure: pass MSI auth info through to terraform
Configure the managed identity within the provider block as per the provider docs [1] [1] https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/guides/managed_service_identity#configuring-with-the-provider-block
1 parent 4c53890 commit 248f6c3

File tree

6 files changed

+13
-0
lines changed

6 files changed

+13
-0
lines changed

data/data/azure/bootstrap/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ provider "azurerm" {
1313
client_certificate_path = var.azure_certificate_path
1414
tenant_id = var.azure_tenant_id
1515
environment = var.azure_environment
16+
use_msi = var.azure_use_msi
1617
}
1718

1819
data "azurerm_storage_account" "storage_account" {

data/data/azure/cluster/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ provider "azurerm" {
1212
client_certificate_password = var.azure_certificate_password
1313
client_certificate_path = var.azure_certificate_path
1414
tenant_id = var.azure_tenant_id
15+
use_msi = var.azure_use_msi
1516
environment = var.azure_environment
1617
}
1718

data/data/azure/variables-azure.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ variable "azure_subscription_id" {
9999
variable "azure_client_id" {
100100
type = string
101101
description = "The app ID that should be used to interact with Azure API"
102+
default = ""
102103
}
103104

104105
variable "azure_client_secret" {
@@ -124,6 +125,12 @@ variable "azure_tenant_id" {
124125
description = "The tenant ID that should be used to interact with Azure API"
125126
}
126127

128+
variable "azure_use_msi" {
129+
type = bool
130+
default = false
131+
description = "Specifies if we are to use a managed identity for authentication"
132+
}
133+
127134
variable "azure_master_availability_zones" {
128135
type = list(string)
129136
description = "The availability zones in which to create the masters. The length of this list must match master_count."

data/data/azure/vnet/main.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ provider "azurerm" {
1919
client_certificate_password = var.azure_certificate_password
2020
client_certificate_path = var.azure_certificate_path
2121
tenant_id = var.azure_tenant_id
22+
use_msi = var.azure_use_msi
2223
environment = var.azure_environment
2324
}
2425

pkg/asset/cluster/tfvars.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,13 +315,15 @@ func (t *TerraformVariables) Generate(parents asset.Parents) error {
315315
if err != nil {
316316
return err
317317
}
318+
318319
auth := azuretfvars.Auth{
319320
SubscriptionID: session.Credentials.SubscriptionID,
320321
ClientID: session.Credentials.ClientID,
321322
ClientSecret: session.Credentials.ClientSecret,
322323
TenantID: session.Credentials.TenantID,
323324
ClientCertificatePath: session.Credentials.ClientCertificatePath,
324325
ClientCertificatePassword: session.Credentials.ClientCertificatePassword,
326+
UseMSI: session.AuthType == aztypes.ManagedIdentityAuth,
325327
}
326328
masters, err := mastersAsset.Machines()
327329
if err != nil {

pkg/tfvars/azure/azure.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ type Auth struct {
2222
TenantID string `json:"azure_tenant_id,omitempty"`
2323
ClientCertificatePath string `json:"azure_certificate_path,omitempty"`
2424
ClientCertificatePassword string `json:"azure_certificate_password,omitempty"`
25+
UseMSI bool `json:"azure_use_msi,omitempty"`
2526
}
2627

2728
type config struct {

0 commit comments

Comments
 (0)