Skip to content

Commit 5e144d8

Browse files
dploegerDennis Ploeger
authored andcommitted
feat: Support attaching the AKS to an ACR
1 parent 4bb0138 commit 5e144d8

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ The following resources are used by this module:
5353
- [azurerm_kubernetes_cluster.k8s](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster) (resource)
5454
- [azurerm_kubernetes_cluster_node_pool.additional](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/kubernetes_cluster_node_pool) (resource)
5555
- [azurerm_public_ip.public-ip-outbound](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/public_ip) (resource)
56+
- [azurerm_role_assignment.aksacr](https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/role_assignment) (resource)
5657
- [azuread_group.ownersgroup](https://registry.terraform.io/providers/hashicorp/azuread/latest/docs/data-sources/group) (data source)
5758

5859
## Required Inputs
@@ -143,6 +144,14 @@ Type: `list(number)`
143144

144145
Default: `[]`
145146

147+
### azure\_container\_registry\_ids
148+
149+
Description: IDs of the azure container registries that the AKS should have pull access to
150+
151+
Type: `list(string)`
152+
153+
Default: `[]`
154+
146155
### default\_node\_pool\_name
147156

148157
Description: Name of the default node pool

acr_attach.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
resource "azurerm_role_assignment" "aksacr" {
2+
for_each = var.azure_container_registry_ids
3+
principal_id = azurerm_kubernetes_cluster.k8s.kubelet_identity[0].object_id
4+
role_definition_name = "AcrPull"
5+
scope = each.value
6+
skip_service_principal_aad_check = true
7+
}

vars.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,4 +180,12 @@ variable "managed_identity_security_group" {
180180
* Group.Read.All
181181
* Group.ReadWrite.All
182182
EOF
183+
}
184+
185+
variable "azure_container_registry_ids" {
186+
type = list(string)
187+
default = []
188+
description = <<-EOF
189+
IDs of the azure container registries that the AKS should have pull access to
190+
EOF
183191
}

0 commit comments

Comments
 (0)