Menu
  • Home
  • About Me
  • Blog
  • Github
  • LinkedIn

Request to create Service Principals and Resource Groups for microservice in Multiple Regions

November 14, 2022November 14, 2022

The client is planning to deploy DFMessage microservice in Canada Central and Australia East regions. As a part of this initiative, the client wants me to create the Service principals and Resource Groups as shown below:

Canada Central Pre-Prod: (high priority)

  • Region: Canada Central
  • Subscription: app341 US PreProd
  • Resource group:
    • Name: app341-dfmessage-cancen-preprod-rg
  • Service Principal:
    • Name: app341-dfmessage-cancen-deploy-appreg
  • Service Principal roles:
    • Owner role in resource group app341-dfmessage-cancen-preprod-rg

개발자 팀에게 클라우드 호스팅 의뢰가 들어왔다. 마이크로서비스 기반 앱을 배포할 계획이라 초기에 필요한 클라우드 셋팅이 필요한 것 같다.

클라우드에 앱을 배포하기 위해서 일단 지역과 네트워크 리소스를 보관할 구독(subscription)이 필요하다. 네트워크 리소스에는 3가지가 필요한데, 이것을 일일이 수동으로 만들수 있지만, 우리 개발자들은 수동보단 자동을 아주 좋아하기 때문에 코드 하나로 이 모든것을 한번에 만들수 있는 도구(툴) 가 있다. 그것을 Infrastructure as Code (IaC)라고 부르고 코드로 위에 요구사항을 한번에 만들수 있다. 간단하게 예를들어:

resource "azurerm_resource_group" "rg" {
  resource_group_name  = "app341-dfmessage-cancen-preprod-rg"
  location             = "eastus2"
  tags                 = var.tags
  role_definition_name = var.role_definition_name
  spn_appid            = var.spn_appid
}

resource "azurerm_role_assignment" "azuread_group" {
  scope                            = azurerm_resource_group.rg.id
  role_definition_name             = "owner"
}

data "azuread_service_principal" "azuread_spn" {
  for_each       = var.spn_appid != null ? toset(var.spn_appid) : []
  application_id = each.key
}

resource "azurerm_role_assignment" "azuread_spn" {
  scope                            = azurerm_resource_group.rg.id
  role_definition_name             = var.role_definition_name
  principal_id                     = 
}

이 코드를 컴퓨터에 작성하고 실행하는 커맨드를 누르면 컴퓨터가 이 언어를 읽고, 위에 있는 요구사항을 모두 충족시킬 수 있는 네트워크를 만든다.

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts
  • ChinguTalkBot v0.1.0: Setting up AWS Cognito with CDK for User Authentication
  • Phoenix & Elixir: Fix PostgreSQL connection refused
  • Demo: Git Log with Shell script to create a release notes
  • Metasploit
  • CyberSecurity Lab – Online Password Attack

Archives
  • March 2024
  • May 2023
  • April 2023
  • February 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
Categories
  • Amazon Interview (3)
  • Ansible (3)
  • AWS (9)
  • Azure (9)
  • Certification (2)
  • ChinguTalkBot Project (1)
  • cybersecurity (3)
  • Data analytics (6)
  • Demo Videos (6)
  • Docker (5)
  • Git (1)
  • GitLab (1)
  • Golang (3)
  • JavaScript (2)
  • Jenkins (4)
  • PowerShell (1)
  • Python (10)
  • Terraform (11)
  • Uncategorized (9)

©2025 | Powered by WordPress and Superb Themes!