Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add terraform for Azure community image gallery #7461

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions infra/azure/terraform/capz/cluster-api-gallery/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
Copyright 2024 The Kubernetes Authors.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

variable "resource_group_name" {
type = string
}

variable "location" {
type = string
}

# Create the "cluster-api-gallery" resource group
resource "azurerm_resource_group" "cluster-api-gallery" {
location = var.location
name = var.resource_group_name
tags = {
DO-NOT-DELETE = "UpstreamInfra"
creationTimestamp = "2024-10-24T00:00:00Z"
}
}

# Create the shared image gallery with community permissions
resource "azurerm_shared_image_gallery" "community_gallery" {
description = "Shared image gallery for Cluster API Provider Azure"
location = var.location
name = "community_gallery"
resource_group_name = "cluster-api-gallery"
tags = {
creationTimestamp = "2024-10-24T00:00:00Z"
jobName = "image-builder-sig-ubuntu-2404"
mboersma marked this conversation as resolved.
Show resolved Hide resolved
}
sharing {
permission = "Community"
community_gallery {
eula = "https://raw.githubusercontent.com/kubernetes-sigs/cluster-api-provider-azure/main/LICENSE"
prefix = "ClusterAPI"
publisher_email = "[email protected]"
publisher_uri = "https://github.com/kubernetes-sigs/cluster-api-provider-azure"
}
}
depends_on = [
azurerm_resource_group.cluster-api-gallery,
]
}

# Create the user-assigned identity for publishing with ADO pipelines
resource "azurerm_user_assigned_identity" "pipelines_user_identity" {
location = var.location
name = "ado-pipeline-mi"
resource_group_name = var.resource_group_name
tags = {
creationTimestamp = "2024-10-24T00:00:00Z"
}
depends_on = [
azurerm_resource_group.cluster-api-gallery,
]
}
8 changes: 8 additions & 0 deletions infra/azure/terraform/capz/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,11 @@ module "role_assignments" {
module.container_registry
]
}

# Import Cluster API gallery module
module "cluster_api_gallery" {
source = "./cluster-api-gallery"
resource_group_name = var.resource_group_name
location = var.location
depends_on = module.role_assignments
}