Skip to content

Instantly share code, notes, and snippets.

@heoelri
Created February 28, 2022 14:13
Show Gist options
  • Save heoelri/de952e3bdf05eaa13f30e5554e4f82a5 to your computer and use it in GitHub Desktop.
Save heoelri/de952e3bdf05eaa13f30e5554e4f82a5 to your computer and use it in GitHub Desktop.
Deploy Azure Red Hat OpenShift via Terraform azurerm
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "2.98.0"
}
azuread = {
source = "hashicorp/azuread"
version = "~> 2.18.0"
}
}
}
provider "azurerm" {
skip_provider_registration = false
features {}
}
data "azuread_client_config" "current" {}
provider "azuread" {
tenant_id = "72f988bf-86f1-41af-91ab-2d7cd011db47"
}
resource "azurerm_resource_group" "example" {
name = "issue9022"
location = "West Europe"
}
resource "azurerm_virtual_network" "example" {
name = "example-vnet"
address_space = ["10.0.0.0/16"]
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_subnet" "aro-master" {
name = "aro-master-subnet"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.1.0/24"]
}
resource "azurerm_subnet" "aro-worker" {
name = "aro-worker-subnet"
resource_group_name = azurerm_resource_group.example.name
virtual_network_name = azurerm_virtual_network.example.name
address_prefixes = ["10.0.2.0/24"]
}
resource "azuread_application" "example" {
display_name = "example"
owners = [data.azuread_client_config.current.object_id]
}
resource "azuread_service_principal" "example" {
application_id = azuread_application.example.application_id
app_role_assignment_required = false
owners = [data.azuread_client_config.current.object_id]
}
resource "azuread_service_principal_password" "example" {
service_principal_id = azuread_service_principal.example.object_id
}
resource "azurerm_redhatopenshift_cluster" "arocluster" {
name = "arosamplecluster"
resource_group_name = azurerm_resource_group.example.name
location = azurerm_resource_group.example.location
service_principal {
client_id = azuread_service_principal.example.id
client_secret = azuread_service_principal_password.example.value
}
master_profile {
subnet_id = azurerm_subnet.aro-master.id
}
worker_profile {
subnet_id = azurerm_subnet.aro-worker.id
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment