Skip to content

Commit be1fc5b

Browse files
authored
Merge pull request #7461 from mboersma/capz-gallery-as-terraform
Add terraform for Azure community image gallery
2 parents d652182 + 7aa54e9 commit be1fc5b

File tree

2 files changed

+78
-0
lines changed

2 files changed

+78
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
Copyright 2024 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
variable "resource_group_name" {
18+
type = string
19+
}
20+
21+
variable "location" {
22+
type = string
23+
}
24+
25+
# Create the "cluster-api-gallery" resource group
26+
resource "azurerm_resource_group" "cluster-api-gallery" {
27+
location = var.location
28+
name = var.resource_group_name
29+
tags = {
30+
DO-NOT-DELETE = "UpstreamInfra"
31+
creationTimestamp = "2024-10-24T00:00:00Z"
32+
}
33+
}
34+
35+
# Create the shared image gallery with community permissions
36+
resource "azurerm_shared_image_gallery" "community_gallery" {
37+
description = "Shared image gallery for Cluster API Provider Azure"
38+
location = var.location
39+
name = "community_gallery"
40+
resource_group_name = "cluster-api-gallery"
41+
tags = {
42+
creationTimestamp = "2024-10-24T00:00:00Z"
43+
jobName = "image-builder-sig-ubuntu-2404"
44+
}
45+
sharing {
46+
permission = "Community"
47+
community_gallery {
48+
eula = "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api-provider-azure/main/LICENSE"
49+
prefix = "ClusterAPI"
50+
publisher_email = "[email protected]"
51+
publisher_uri = "https://github.com/kubernetes-sigs/cluster-api-provider-azure"
52+
}
53+
}
54+
depends_on = [
55+
azurerm_resource_group.cluster-api-gallery,
56+
]
57+
}
58+
59+
# Create the user-assigned identity for publishing with ADO pipelines
60+
resource "azurerm_user_assigned_identity" "pipelines_user_identity" {
61+
location = var.location
62+
name = "ado-pipeline-mi"
63+
resource_group_name = var.resource_group_name
64+
tags = {
65+
creationTimestamp = "2024-10-24T00:00:00Z"
66+
}
67+
depends_on = [
68+
azurerm_resource_group.cluster-api-gallery,
69+
]
70+
}

infra/azure/terraform/capz/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,11 @@ module "role_assignments" {
125125
module.container_registry
126126
]
127127
}
128+
129+
# Import Cluster API gallery module
130+
module "cluster_api_gallery" {
131+
source = "./cluster-api-gallery"
132+
resource_group_name = var.resource_group_name
133+
location = var.location
134+
depends_on = module.role_assignments
135+
}

0 commit comments

Comments
 (0)