From 9fa3c46de92fd32b69463aebfe53169d5a5641d8 Mon Sep 17 00:00:00 2001 From: John Paulo Rodriguez Date: Sat, 23 Jan 2021 13:35:45 +0800 Subject: [PATCH] rename create_user_pool var to enabled --- README.md | 6 +++--- client.tf | 2 +- domain.tf | 2 +- main.tf | 2 +- outputs.tf | 24 ++++++++++++------------ resource-server.tf | 2 +- user-group.tf | 2 +- variables.tf | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index f949cc4..1896c71 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ module "aws_cognito_user_pool_simple" { ### Example (conditional creation) -Sometimes you need to have a way to create Cognito User Pool resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `create_user_pool`. +Sometimes you need to have a way to create Cognito User Pool resources conditionally but Terraform does not allow to use `count` inside `module` block, so the solution is to specify argument `enabled`. ``` # This Cognito User Pool will not be created @@ -38,7 +38,7 @@ module "aws_cognito_user_pool_conditional_creation" { source = "lgallard/cognito-user-pool/aws" user_pool_name = "conditional_user_pool" - create_user_pool = false + enabled = false } ``` @@ -163,7 +163,6 @@ module "aws_cognito_user_pool_complete" { | client\_supported\_identity\_providers | List of provider names for the identity providers that are supported on this client | `list` | `[]` | no | | client\_write\_attributes | List of user pool attributes the application client can write to | `list` | `[]` | no | | clients | A container with the clients definitions | `list` | `[]` | no | -| create_user_pool | Controls if Cognito User Pool should be created | `bool` | `false` | no | | device\_configuration | The configuration for the user pool's device tracking | `map` | `{}` | no | | device\_configuration\_challenge\_required\_on\_new\_device | Indicates whether a challenge is required on a new device. Only applicable to a new device | `bool` | `false` | no | | device\_configuration\_device\_only\_remembered\_on\_user\_prompt | If true, a device is only remembered on user prompt | `bool` | `false` | no | @@ -176,6 +175,7 @@ module "aws_cognito_user_pool_complete" { | email\_configuration\_source\_arn | The ARN of the email source | `string` | `""` | no | | email\_verification\_message | A string representing the email verification message | `string` | `null` | no | | email\_verification\_subject | A string representing the email verification subject | `string` | `null` | no | +| enabled | Controls if Cognito User Pool should be created | `bool` | `false` | no | | lambda\_config | A container for the AWS Lambda triggers associated with the user pool | `map` | `null` | no | | lambda\_config\_create\_auth\_challenge | The ARN of the lambda creating an authentication challenge. | `string` | `""` | no | | lambda\_config\_custom\_message | A custom Message AWS Lambda trigger. | `string` | `""` | no | diff --git a/client.tf b/client.tf index db0f06d..c3b337f 100644 --- a/client.tf +++ b/client.tf @@ -1,5 +1,5 @@ resource "aws_cognito_user_pool_client" "client" { - count = var.create_user_pool ? length(local.clients) : 0 + count = var.enabled ? length(local.clients) : 0 allowed_oauth_flows = lookup(element(local.clients, count.index), "allowed_oauth_flows", null) allowed_oauth_flows_user_pool_client = lookup(element(local.clients, count.index), "allowed_oauth_flows_user_pool_client", null) allowed_oauth_scopes = lookup(element(local.clients, count.index), "allowed_oauth_scopes", null) diff --git a/domain.tf b/domain.tf index 3750bfa..cd6bdac 100644 --- a/domain.tf +++ b/domain.tf @@ -1,5 +1,5 @@ resource "aws_cognito_user_pool_domain" "domain" { - count = ! var.create_user_pool || var.domain == null || var.domain == "" ? 0 : 1 + count = ! var.enabled || var.domain == null || var.domain == "" ? 0 : 1 domain = var.domain certificate_arn = var.domain_certificate_arn user_pool_id = aws_cognito_user_pool.pool[0].id diff --git a/main.tf b/main.tf index 648901d..1e46008 100644 --- a/main.tf +++ b/main.tf @@ -1,5 +1,5 @@ resource "aws_cognito_user_pool" "pool" { - count = var.create_user_pool ? 1 : 0 + count = var.enabled ? 1 : 0 alias_attributes = var.alias_attributes auto_verified_attributes = var.auto_verified_attributes diff --git a/outputs.tf b/outputs.tf index 26224bf..2f5606d 100644 --- a/outputs.tf +++ b/outputs.tf @@ -1,26 +1,26 @@ output "id" { description = "The id of the user pool" - value = var.create_user_pool ? aws_cognito_user_pool.pool[0].id : null + value = var.enabled ? aws_cognito_user_pool.pool[0].id : null } output "arn" { description = "The ARN of the user pool" - value = var.create_user_pool ? aws_cognito_user_pool.pool[0].arn : null + value = var.enabled ? aws_cognito_user_pool.pool[0].arn : null } output "endpoint" { description = "The endpoint name of the user pool. Example format: cognito-idp.REGION.amazonaws.com/xxxx_yyyyy" - value = var.create_user_pool ? aws_cognito_user_pool.pool[0].endpoint : null + value = var.enabled ? aws_cognito_user_pool.pool[0].endpoint : null } output "creation_date" { description = "The date the user pool was created" - value = var.create_user_pool ? aws_cognito_user_pool.pool[0].creation_date : null + value = var.enabled ? aws_cognito_user_pool.pool[0].creation_date : null } output "last_modified_date" { description = "The date the user pool was last modified" - value = var.create_user_pool ? aws_cognito_user_pool.pool[0].last_modified_date : null + value = var.enabled ? aws_cognito_user_pool.pool[0].last_modified_date : null } # @@ -28,22 +28,22 @@ output "last_modified_date" { # output "domain_aws_account_id" { description = "The AWS account ID for the user pool owner" - value = var.create_user_pool ? join("", aws_cognito_user_pool_domain.domain.*.aws_account_id) : null + value = var.enabled ? join("", aws_cognito_user_pool_domain.domain.*.aws_account_id) : null } output "domain_cloudfront_distribution_arn" { description = "The ARN of the CloudFront distribution" - value = var.create_user_pool ? join("", aws_cognito_user_pool_domain.domain.*.cloudfront_distribution_arn) : null + value = var.enabled ? join("", aws_cognito_user_pool_domain.domain.*.cloudfront_distribution_arn) : null } output "domain_s3_bucket" { description = "The S3 bucket where the static files for this domain are stored" - value = var.create_user_pool ? join("", aws_cognito_user_pool_domain.domain.*.s3_bucket) : null + value = var.enabled ? join("", aws_cognito_user_pool_domain.domain.*.s3_bucket) : null } output "domain_app_version" { description = "The app version" - value = var.create_user_pool ? join("", aws_cognito_user_pool_domain.domain.*.version) : null + value = var.enabled ? join("", aws_cognito_user_pool_domain.domain.*.version) : null } # @@ -51,12 +51,12 @@ output "domain_app_version" { # output "client_ids" { description = "The ids of the user pool clients" - value = var.create_user_pool ? aws_cognito_user_pool_client.client.*.id : null + value = var.enabled ? aws_cognito_user_pool_client.client.*.id : null } output "client_secrets" { description = " The client secrets of the user pool clients" - value = var.create_user_pool ? aws_cognito_user_pool_client.client.*.client_secret : null + value = var.enabled ? aws_cognito_user_pool_client.client.*.client_secret : null } # @@ -64,5 +64,5 @@ output "client_secrets" { # output "resource_servers_scope_identifiers" { description = " A list of all scopes configured in the format identifier/scope_name" - value = var.create_user_pool ? aws_cognito_resource_server.resource.*.scope_identifiers : null + value = var.enabled ? aws_cognito_resource_server.resource.*.scope_identifiers : null } diff --git a/resource-server.tf b/resource-server.tf index 13e2311..487cff1 100644 --- a/resource-server.tf +++ b/resource-server.tf @@ -1,5 +1,5 @@ resource "aws_cognito_resource_server" "resource" { - count = var.create_user_pool ? length(local.resource_servers) : 0 + count = var.enabled ? length(local.resource_servers) : 0 name = lookup(element(local.resource_servers, count.index), "name") identifier = lookup(element(local.resource_servers, count.index), "identifier") diff --git a/user-group.tf b/user-group.tf index f106575..c21cdf9 100644 --- a/user-group.tf +++ b/user-group.tf @@ -1,5 +1,5 @@ resource "aws_cognito_user_group" "main" { - count = var.create_user_pool ? length(local.groups) : 0 + count = var.enabled ? length(local.groups) : 0 name = lookup(element(local.groups, count.index), "name") description = lookup(element(local.groups, count.index), "description") precedence = lookup(element(local.groups, count.index), "precedence") diff --git a/variables.tf b/variables.tf index 11ce83b..d41a90b 100644 --- a/variables.tf +++ b/variables.tf @@ -1,7 +1,7 @@ # # aws_cognito_user_pool # -variable "create_user_pool" { +variable "enabled" { description = "Controls if Cognito User Pool should be created" type = bool default = false