@aws/nx-plugin 1.0.0-rc.76 → 1.0.0-rc.77
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/migrations.json +11 -1
- package/package.json +1 -1
- package/src/migrations/latest/dynamodb-configurable-encryption/__snapshots__/migration.spec.ts.snap +429 -0
- package/src/migrations/latest/dynamodb-configurable-encryption/metadata.json +3 -0
- package/src/migrations/latest/dynamodb-configurable-encryption/migration.d.ts +6 -0
- package/src/migrations/latest/dynamodb-configurable-encryption/migration.js +325 -0
- package/src/migrations/latest/dynamodb-configurable-encryption/migration.js.map +1 -0
- package/src/migrations/latest/user-identity-configurable-mfa/metadata.json +3 -0
- package/src/migrations/latest/user-identity-configurable-mfa/migration.d.ts +6 -0
- package/src/migrations/latest/user-identity-configurable-mfa/migration.js +362 -0
- package/src/migrations/latest/user-identity-configurable-mfa/migration.js.map +1 -0
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +90 -9
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +90 -9
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.spec.ts.snap +37 -7
- package/src/ts/react-website/cognito-auth/__snapshots__/generator.terraform.spec.ts.snap +26 -0
- package/src/utils/dynamodb-constructs/files/cdk/core/dynamodb.ts.template +23 -3
- package/src/utils/dynamodb-constructs/files/terraform/app/dynamodb/__nameKebabCase__/__nameKebabCase__.tf.template +27 -1
- package/src/utils/dynamodb-constructs/files/terraform/core/dynamodb/dynamodb.tf.template +39 -5
- package/src/utils/identity-constructs/files/cdk/core/user-identity.ts.template +41 -7
- package/src/utils/identity-constructs/files/terraform/core/user-identity/identity/identity.tf.template +48 -13
- package/src/utils/identity-constructs/files/terraform/core/user-identity/main.tf.template +26 -0
|
@@ -28,6 +28,29 @@ variable "enable_waf" {
|
|
|
28
28
|
default = true
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
+
variable "mfa" {
|
|
32
|
+
description = "Whether users must configure MFA, may optionally configure MFA, or cannot use MFA at all"
|
|
33
|
+
type = string
|
|
34
|
+
default = "ON"
|
|
35
|
+
|
|
36
|
+
validation {
|
|
37
|
+
condition = contains(["OFF", "OPTIONAL", "ON"], var.mfa)
|
|
38
|
+
error_message = "mfa must be one of OFF, OPTIONAL, ON"
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
variable "mfa_second_factor_otp" {
|
|
43
|
+
description = "Whether users can use a time-based one time password (TOTP), generated by a hardware or software token, as an MFA method"
|
|
44
|
+
type = bool
|
|
45
|
+
default = true
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
variable "mfa_second_factor_sms" {
|
|
49
|
+
description = "Whether users can use SMS to their verified phone numbers as an MFA method. Due to a Terraform AWS provider limitation, disabling this also disables SMS-based phone number verification, unlike the equivalent CDK construct prop"
|
|
50
|
+
type = bool
|
|
51
|
+
default = true
|
|
52
|
+
}
|
|
53
|
+
|
|
31
54
|
variable "callback_urls" {
|
|
32
55
|
description = "Additional callback URLs for the user pool client"
|
|
33
56
|
type = list(string)
|
|
@@ -58,10 +81,14 @@ resource "random_id" "unique_suffix" {
|
|
|
58
81
|
}
|
|
59
82
|
|
|
60
83
|
# Generate a random external ID for SMS role security
|
|
61
|
-
resource "random_uuid" "sms_external_id" {
|
|
84
|
+
resource "random_uuid" "sms_external_id" {
|
|
85
|
+
count = var.mfa_second_factor_sms ? 1 : 0
|
|
86
|
+
}
|
|
62
87
|
|
|
63
88
|
# IAM role for SMS MFA
|
|
64
89
|
resource "aws_iam_role" "cognito_sms_role" {
|
|
90
|
+
count = var.mfa_second_factor_sms ? 1 : 0
|
|
91
|
+
|
|
65
92
|
name = "cognito-sms-role-${random_id.unique_suffix.hex}"
|
|
66
93
|
|
|
67
94
|
assume_role_policy = jsonencode({
|
|
@@ -75,7 +102,7 @@ resource "aws_iam_role" "cognito_sms_role" {
|
|
|
75
102
|
}
|
|
76
103
|
Condition = {
|
|
77
104
|
StringEquals = {
|
|
78
|
-
"sts:ExternalId" = random_uuid.sms_external_id.result
|
|
105
|
+
"sts:ExternalId" = random_uuid.sms_external_id[0].result
|
|
79
106
|
"aws:SourceAccount" = data.aws_caller_identity.current.account_id
|
|
80
107
|
}
|
|
81
108
|
ArnLike = {
|
|
@@ -90,8 +117,10 @@ resource "aws_iam_role" "cognito_sms_role" {
|
|
|
90
117
|
resource "aws_iam_role_policy" "cognito_sms_policy" {
|
|
91
118
|
# checkov:skip=CKV_AWS_290:Cognito SMS requires sns:Publish with wildcard resource
|
|
92
119
|
# checkov:skip=CKV_AWS_355:Cognito SMS requires sns:Publish with wildcard resource
|
|
120
|
+
count = var.mfa_second_factor_sms ? 1 : 0
|
|
121
|
+
|
|
93
122
|
name = "cognito-sms-policy-${random_id.unique_suffix.hex}"
|
|
94
|
-
role = aws_iam_role.cognito_sms_role.id
|
|
123
|
+
role = aws_iam_role.cognito_sms_role[0].id
|
|
95
124
|
|
|
96
125
|
policy = jsonencode({
|
|
97
126
|
Version = "2012-10-17"
|
|
@@ -127,18 +156,23 @@ resource "aws_cognito_user_pool" "user_pool" {
|
|
|
127
156
|
}
|
|
128
157
|
|
|
129
158
|
# MFA configuration
|
|
130
|
-
mfa_configuration =
|
|
159
|
+
mfa_configuration = var.mfa
|
|
131
160
|
|
|
132
161
|
# Software token MFA configuration
|
|
133
162
|
software_token_mfa_configuration {
|
|
134
|
-
enabled =
|
|
163
|
+
enabled = var.mfa_second_factor_otp
|
|
135
164
|
}
|
|
136
165
|
|
|
137
|
-
# SMS MFA configuration
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
166
|
+
# SMS MFA configuration. Due to a Terraform AWS provider limitation, this also gates
|
|
167
|
+
# SMS-based phone number verification below - see the mfa_second_factor_sms variable.
|
|
168
|
+
dynamic "sms_configuration" {
|
|
169
|
+
for_each = var.mfa_second_factor_sms ? [1] : []
|
|
170
|
+
|
|
171
|
+
content {
|
|
172
|
+
external_id = random_uuid.sms_external_id[0].result
|
|
173
|
+
sns_caller_arn = aws_iam_role.cognito_sms_role[0].arn
|
|
174
|
+
sns_region = data.aws_region.current.region
|
|
175
|
+
}
|
|
142
176
|
}
|
|
143
177
|
|
|
144
178
|
depends_on = [aws_iam_role_policy.cognito_sms_policy]
|
|
@@ -158,8 +192,9 @@ resource "aws_cognito_user_pool" "user_pool" {
|
|
|
158
192
|
}
|
|
159
193
|
}
|
|
160
194
|
|
|
161
|
-
# Auto verification
|
|
162
|
-
|
|
195
|
+
# Auto verification. Phone number verification requires sms_configuration above, so it
|
|
196
|
+
# follows mfa_second_factor_sms - see that variable's description.
|
|
197
|
+
auto_verified_attributes = var.mfa_second_factor_sms ? ["email", "phone_number"] : ["email"]
|
|
163
198
|
|
|
164
199
|
# User pool tier (equivalent to FeaturePlan.PLUS)
|
|
165
200
|
user_pool_tier = "PLUS"
|
|
@@ -220,7 +255,7 @@ resource "aws_cognito_user_pool" "user_pool" {
|
|
|
220
255
|
|
|
221
256
|
# User attribute update settings - require verification before update
|
|
222
257
|
user_attribute_update_settings {
|
|
223
|
-
attributes_require_verification_before_update = ["email", "phone_number"]
|
|
258
|
+
attributes_require_verification_before_update = var.mfa_second_factor_sms ? ["email", "phone_number"] : ["email"]
|
|
224
259
|
}
|
|
225
260
|
|
|
226
261
|
# Verification message templates
|
|
@@ -4,12 +4,38 @@ variable "enable_waf" {
|
|
|
4
4
|
default = true
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
+
variable "mfa" {
|
|
8
|
+
description = "Whether users must configure MFA, may optionally configure MFA, or cannot use MFA at all"
|
|
9
|
+
type = string
|
|
10
|
+
default = "ON"
|
|
11
|
+
|
|
12
|
+
validation {
|
|
13
|
+
condition = contains(["OFF", "OPTIONAL", "ON"], var.mfa)
|
|
14
|
+
error_message = "mfa must be one of OFF, OPTIONAL, ON"
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
variable "mfa_second_factor_otp" {
|
|
19
|
+
description = "Whether users can use a time-based one time password (TOTP), generated by a hardware or software token, as an MFA method"
|
|
20
|
+
type = bool
|
|
21
|
+
default = true
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
variable "mfa_second_factor_sms" {
|
|
25
|
+
description = "Whether users can use SMS to their verified phone numbers as an MFA method. Due to a Terraform AWS provider limitation, disabling this also disables SMS-based phone number verification, unlike the equivalent CDK construct prop"
|
|
26
|
+
type = bool
|
|
27
|
+
default = true
|
|
28
|
+
}
|
|
29
|
+
|
|
7
30
|
module "identity" {
|
|
8
31
|
source = "./identity"
|
|
9
32
|
|
|
10
33
|
user_pool_domain_prefix = "<%= cognitoDomain %>"
|
|
11
34
|
allow_signup = <%= allowSignup %>
|
|
12
35
|
enable_waf = var.enable_waf
|
|
36
|
+
mfa = var.mfa
|
|
37
|
+
mfa_second_factor_otp = var.mfa_second_factor_otp
|
|
38
|
+
mfa_second_factor_sms = var.mfa_second_factor_sms
|
|
13
39
|
}
|
|
14
40
|
|
|
15
41
|
# Outputs
|