Nmbrs / tf-modules

:star: Contains all the Terraform modules that abstracts Nmbrs® infrastructure.
Apache License 2.0
3 stars 0 forks source link

Feature(app_service): add managed identity to app service #277

Closed pmmluis closed 8 months ago

pmmluis commented 8 months ago

Description

This PR serves the purpose of adding the managed identity to the app service plan and to the app settings of that app service plan. This way when creating an app service if a managed identity is created along with it, it will automatically be assigned to the service.

PR Checklist

Please ensure the following before submitting this PR:

PR Type

What kind of change does this PR introduce?

What is the new behavior?

How to test it

Create the module for the managed identity:

module "managed_identity" {
  for_each            = { for identity in var.managed_identities : identity.workload => identity }
  source              = "git::github.com/Nmbrs/tf-modules//azure/managed_identity?ref=v7.15.0"
  workload            = each.value.workload
  resource_group_name = each.value.resource_group_name
  location            = each.value.location
  environment         = each.value.environment

  depends_on = [module.resource_group]
}

variable "managed_identities" {
  description = "List of managed identities."
  type = list(object({
    workload            = string
    location            = string
    environment         = string
    resource_group_name = string
  }))
  default = [
    {
      workload = "testidentity"
      location = "westeurope",
      environment = "test",
      resource_group_name = "rg-testidentity-test"
    }
  ]
}

and then use the following block

module "app_service_plan" { 
    source = "git::github.com/Nmbrs/tf-modules//azure/app_service" 
    service_plan_name = "testidentity" 
    resource_group_name = "rg-myapp" 
    environment = "dev" 
    location = "westeurope" 
    sku = "P2v3" 
    stack = "dotnet" 
    dotnet_version = "v4.0" 
    client_affinity_enabled = true 
    network_settings = { 
        vnet_resource_group_name = "rg-myvnet" 
        vnet_name = "vnet-myvnet-dev-001" 
        subnet_name = "snet-appservices-001" } 
    app_service_names = ["web"] 
    user_assigned_identity_id        = module.managed_identity[each.value.workload].id
    user_assigned_identity_client_id = module.managed_identity[each.value.workload].client_id
    } 

Does this PR introduce a breaking change?

Other information

github-actions[bot] commented 8 months ago

Pull Request Validation Report

This comment is automatically generated by Conventional PR

Whitelist Report

Whitelist Active Result
Pull request is a draft and should be ignored
Pull request is made by a whitelisted user and should be ignored
Pull request is submitted by a bot and should be ignored
Pull request is submitted by administrators and should be ignored

Result

Pull request does not satisfy any enabled whitelist criteria. Pull request will be validated.

Validation Report

Validation Active Result
All commits in this pull request come from verified users
All commits in this pull request has valid messages
Pull request does not introduce too many changes
Pull request has a valid title
Pull request has mentioned issues
Pull request has valid branch name
Pull request should have a non-empty body

Result

Pull request satisfies all enabled pull request rules.

github-actions[bot] commented 8 months ago

Pull Request Validation Report

This comment is automatically generated by Conventional PR

Whitelist Report

Whitelist Active Result
Pull request is a draft and should be ignored
Pull request is made by a whitelisted user and should be ignored
Pull request is submitted by a bot and should be ignored
Pull request is submitted by administrators and should be ignored

Result

Pull request does not satisfy any enabled whitelist criteria. Pull request will be validated.

Validation Report

Validation Active Result
All commits in this pull request come from verified users
All commits in this pull request has valid messages
Pull request does not introduce too many changes
Pull request has a valid title
Pull request has mentioned issues
Pull request has valid branch name
Pull request should have a non-empty body

Result

Pull request satisfies all enabled pull request rules.

github-actions[bot] commented 8 months ago

Pull Request Validation Report

This comment is automatically generated by Conventional PR

Whitelist Report

Whitelist Active Result
Pull request is a draft and should be ignored
Pull request is made by a whitelisted user and should be ignored
Pull request is submitted by a bot and should be ignored
Pull request is submitted by administrators and should be ignored

Result

Pull request does not satisfy any enabled whitelist criteria. Pull request will be validated.

Validation Report

Validation Active Result
All commits in this pull request come from verified users
All commits in this pull request has valid messages
Pull request does not introduce too many changes
Pull request has a valid title
Pull request has mentioned issues
Pull request has valid branch name
Pull request should have a non-empty body

Result

Pull request satisfies all enabled pull request rules.

github-actions[bot] commented 8 months ago

Pull Request Validation Report

This comment is automatically generated by Conventional PR

Whitelist Report

Whitelist Active Result
Pull request is a draft and should be ignored
Pull request is made by a whitelisted user and should be ignored
Pull request is submitted by a bot and should be ignored
Pull request is submitted by administrators and should be ignored

Result

Pull request does not satisfy any enabled whitelist criteria. Pull request will be validated.

Validation Report

Validation Active Result
All commits in this pull request come from verified users
All commits in this pull request has valid messages
Pull request does not introduce too many changes
Pull request has a valid title
Pull request has mentioned issues
Pull request has valid branch name
Pull request should have a non-empty body

Result

Pull request satisfies all enabled pull request rules.

github-actions[bot] commented 8 months ago

Pull Request Validation Report

This comment is automatically generated by Conventional PR

Whitelist Report

Whitelist Active Result
Pull request is a draft and should be ignored
Pull request is made by a whitelisted user and should be ignored
Pull request is submitted by a bot and should be ignored
Pull request is submitted by administrators and should be ignored

Result

Pull request does not satisfy any enabled whitelist criteria. Pull request will be validated.

Validation Report

Validation Active Result
All commits in this pull request come from verified users
All commits in this pull request has valid messages
Pull request does not introduce too many changes
Pull request has a valid title
Pull request has mentioned issues
Pull request has valid branch name
Pull request should have a non-empty body

Result

Pull request satisfies all enabled pull request rules.

github-actions[bot] commented 8 months ago

Pull Request Validation Report

This comment is automatically generated by Conventional PR

Whitelist Report

Whitelist Active Result
Pull request is a draft and should be ignored
Pull request is made by a whitelisted user and should be ignored
Pull request is submitted by a bot and should be ignored
Pull request is submitted by administrators and should be ignored

Result

Pull request does not satisfy any enabled whitelist criteria. Pull request will be validated.

Validation Report

Validation Active Result
All commits in this pull request come from verified users
All commits in this pull request has valid messages
Pull request does not introduce too many changes
Pull request has a valid title
Pull request has mentioned issues
Pull request has valid branch name
Pull request should have a non-empty body

Result

Pull request satisfies all enabled pull request rules.