hashicorp / terraform-provider-aws

The AWS Provider enables Terraform to manage AWS resources.
https://registry.terraform.io/providers/hashicorp/aws
Mozilla Public License 2.0
9.62k stars 9.01k forks source link

Terraform Cognito resource server- how to pass scopes to a module #19686

Closed Nimsgs closed 1 month ago

Nimsgs commented 3 years ago

How can I pass the scopes if aws_cognito_resource_server is created in a module and we have to pass the scopes to that module. eg: I created a module for creating the cognito resources and I have to pass the scopes to that module. Tried passing the scope as a variable but it doesn't recognize the scope name and description in the module.

variable "application-scopes" {
  type = map(string)
  default = {
    scope1 = {
      "scope_name" : "get"
      "scope_description" : "can make get request"
    },
    scope2 = {
      "scope_name" : "post"
      "scope_description" : "can make post request "
    } 
  }
}

module "cognito" {
  source = "./cognito"
  scopes = var.application-scopes
}

Resource Server defined in Module:

resource "aws_cognito_resource_server" "application-resource-server" {
  identifier = var.cognito_rs_id
  name = var.cognito_rs_name
  user_pool_id = aws_cognito_user_pool.application-pool.id

  dynamic "scope" {
    for_each = [for key, value in var.scopes : {
      scope_name = value.scope_name
      scope_description = value.scope_description
    }]

    content {
      scope_name        = scope.value.scope_name
      scope_description = scope.value.scope_description
    }
  }
}
github-actions[bot] commented 2 months ago

Marking this issue as stale due to inactivity. This helps our maintainers find and focus on the active issues. If this issue receives no comments in the next 30 days it will automatically be closed. Maintainers can also remove the stale label.

If this issue was automatically closed and you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thank you!

github-actions[bot] commented 3 weeks ago

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.