fix 201-aks-acr-identity

This commit is contained in:
hezijie 2023-02-21 10:14:26 +08:00
parent 30ab022102
commit ed79d1aa3b
5 changed files with 31 additions and 22 deletions

View File

@ -2,9 +2,9 @@ locals {
acr_name = "${replace(var.dns_prefix, "-", "")}${replace(var.name, "-", "")}acr"
}
resource "azurerm_container_registry" "default" {
name = "${local.acr_name}"
resource_group_name = "${azurerm_resource_group.default.name}"
location = "${azurerm_resource_group.default.location}"
name = local.acr_name
resource_group_name = azurerm_resource_group.default.name
location = azurerm_resource_group.default.location
sku = "Standard"
admin_enabled = false
}

View File

@ -1,7 +1,7 @@
resource "azurerm_kubernetes_cluster" "default" {
name = "${var.name}-aks"
location = "${azurerm_resource_group.default.location}"
resource_group_name = "${azurerm_resource_group.default.name}"
location = azurerm_resource_group.default.location
resource_group_name = azurerm_resource_group.default.name
dns_prefix = "${var.dns_prefix}-${var.name}-aks-${var.environment}"
depends_on = ["azurerm_role_assignment.aks_network", "azurerm_role_assignment.aks_acr"]

View File

@ -3,7 +3,7 @@ resource "azuread_application" "default" {
}
resource "azuread_service_principal" "default" {
application_id = "${azuread_application.default.application_id}"
application_id = azuread_application.default.application_id
}
resource "random_string" "password" {

View File

@ -1,18 +1,27 @@
# The Azure Active Resource Manager Terraform provider
provider "azurerm" {
version = "=1.36.0"
}
# The Azure Active Directory Terraform provider
provider "azuread" {
version = "=0.6.0"
terraform {
required_version = ">= 1.3"
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "1.36.0"
}
azuread = {
source = "hashicorp/azuread"
version = "0.6.0"
}
}
}
# Reference to the current subscription. Used when creating role assignments
data "azurerm_subscription" "current" {}
resource "random_pet" "rg" {
length = 1
prefix = var.name
}
# The main resource group for this deployment
resource "azurerm_resource_group" "default" {
name = "${var.name}-${var.environment}-rg"
location = "${var.location}"
name = "${random_pet.rg.id}-${var.environment}-rg"
location = var.location
}

View File

@ -1,12 +1,12 @@
// Naming
variable "name" {
type = "string"
type = string
description = "Location of the azure resource group."
default = "demo-tfquickstart"
}
variable "environment" {
type = "string"
type = string
description = "Name of the deployment environment"
default = "dev"
}
@ -14,7 +14,7 @@ variable "environment" {
// Resource information
variable "location" {
type = "string"
type = string
description = "Location of the azure resource group."
default = "WestUS2"
}
@ -22,19 +22,19 @@ variable "location" {
// Node type information
variable "node_count" {
type = "string"
type = number
description = "The number of K8S nodes to provision."
default = 3
}
variable "node_type" {
type = "string"
type = string
description = "The size of each node."
default = "Standard_D1_v2"
}
variable "dns_prefix" {
type = "string"
type = string
description = "DNS Prefix"
default = "tfq"
}