-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathr_cognito.tf
65 lines (56 loc) · 1.96 KB
/
r_cognito.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
resource "aws_cognito_user_pool" "this" {
name = var.name
username_attributes = ["email"]
auto_verified_attributes = ["email"]
admin_create_user_config {
invite_message_template {
email_subject = "Moot User Signup"
email_message = file("${path.module}/terraform_assets/cognito_invite_template.html")
sms_message = <<-MESSAGE
username: {username}
password: {####}
MESSAGE
}
}
account_recovery_setting {
recovery_mechanism {
name = "admin_only"
priority = 1
}
}
password_policy {
minimum_length = 36
require_lowercase = true
require_numbers = true
require_symbols = false
require_uppercase = true
temporary_password_validity_days = 1
}
tags = var.tags
}
resource "aws_cognito_user_pool_client" "this" {
name = var.name
user_pool_id = aws_cognito_user_pool.this.id
generate_secret = true
allowed_oauth_flows = ["code", "implicit"]
allowed_oauth_flows_user_pool_client = true
allowed_oauth_scopes = ["email", "openid"]
supported_identity_providers = ["COGNITO"]
callback_urls = [var.hosted_zone_name != "" && var.fqdn_alias != "" ? "https://${var.fqdn_alias}" : "https://${module.cloudfront.cloudfront_distribution_domain_name}"]
explicit_auth_flows = [
"ALLOW_ADMIN_USER_PASSWORD_AUTH",
"ALLOW_CUSTOM_AUTH",
"ALLOW_REFRESH_TOKEN_AUTH",
"ALLOW_USER_PASSWORD_AUTH",
"ALLOW_USER_SRP_AUTH",
]
}
resource "aws_cognito_identity_pool" "this" {
identity_pool_name = var.name
allow_unauthenticated_identities = false
cognito_identity_providers {
client_id = aws_cognito_user_pool_client.this.id
provider_name = aws_cognito_user_pool.this.endpoint
}
tags = var.tags
}