-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
infra: separate IAM from AKS and image
Co-authored-by: Paul Meyer <[email protected]>
- Loading branch information
1 parent
a84a9cb
commit d48ca25
Showing
10 changed files
with
235 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,5 +22,4 @@ id_rsa* | |
kube.conf | ||
out.env | ||
infra/**/kustomization.yaml | ||
infra/**/workload-identity.yaml | ||
uplosi.conf* |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
terraform { | ||
required_providers { | ||
azurerm = { | ||
source = "hashicorp/azurerm" | ||
version = "4.5.0" | ||
} | ||
azuread = { | ||
source = "hashicorp/azuread" | ||
version = "3.0.2" | ||
} | ||
local = { | ||
source = "hashicorp/local" | ||
version = "2.5.2" | ||
} | ||
} | ||
} | ||
|
||
provider "azurerm" { | ||
subscription_id = var.subscription_id | ||
features { | ||
resource_group { | ||
prevent_deletion_if_contains_resources = false | ||
} | ||
} | ||
} | ||
|
||
data "azurerm_subscription" "current" {} | ||
|
||
data "azuread_client_config" "current" {} | ||
|
||
provider "azuread" { | ||
tenant_id = data.azurerm_subscription.current.tenant_id | ||
} | ||
|
||
locals { | ||
name = var.resource_group | ||
} | ||
|
||
resource "azurerm_resource_group" "rg" { | ||
name = var.resource_group | ||
location = var.location | ||
} | ||
|
||
resource "azuread_application" "app" { | ||
display_name = "${local.name}-app" | ||
owners = [data.azuread_client_config.current.object_id] | ||
} | ||
|
||
resource "azuread_service_principal" "sp" { | ||
client_id = azuread_application.app.client_id | ||
app_role_assignment_required = false | ||
owners = [data.azuread_client_config.current.object_id] | ||
} | ||
|
||
resource "azurerm_role_assignment" "ra_vm_contributor" { | ||
scope = azurerm_resource_group.rg.id | ||
role_definition_name = "Virtual Machine Contributor" | ||
principal_id = azuread_service_principal.sp.object_id | ||
} | ||
|
||
resource "azurerm_role_assignment" "ra_reader" { | ||
scope = azurerm_resource_group.rg.id | ||
role_definition_name = "Reader" | ||
principal_id = azuread_service_principal.sp.object_id | ||
} | ||
|
||
resource "azurerm_role_assignment" "ra_network_contributor" { | ||
scope = azurerm_resource_group.rg.id | ||
role_definition_name = "Network Contributor" | ||
principal_id = azuread_service_principal.sp.object_id | ||
} | ||
|
||
resource "azuread_application_password" "pw" { | ||
application_id = azuread_application.app.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
output "client_secret_env" { | ||
value = <<EOF | ||
client_id = "${azuread_application.app.client_id}" | ||
tenant_id = "${data.azurerm_subscription.current.tenant_id}" | ||
client_secret = "${azuread_application_password.pw.value}" | ||
EOF | ||
sensitive = true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
variable "resource_group" { | ||
type = string | ||
} | ||
|
||
variable "location" { | ||
type = string | ||
} | ||
|
||
variable "subscription_id" { | ||
type = string | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.