Skip to content

Commit

Permalink
rename create_user_pool var to enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
pauloapi committed Jan 23, 2021
1 parent 3b1b0c5 commit 9fa3c46
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
```
Expand Down Expand Up @@ -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 |
Expand All @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion client.tf
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion domain.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion main.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down
24 changes: 12 additions & 12 deletions outputs.tf
Original file line number Diff line number Diff line change
@@ -1,68 +1,68 @@
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
}

#
# aws_cognito_user_pool_domain
#
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
}

#
# aws_cognito_user_pool_client
#
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
}

#
# aws_cognito_resource_servers
#
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
}
2 changes: 1 addition & 1 deletion resource-server.tf
Original file line number Diff line number Diff line change
@@ -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")

Expand Down
2 changes: 1 addition & 1 deletion user-group.tf
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
2 changes: 1 addition & 1 deletion variables.tf
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 9fa3c46

Please sign in to comment.