Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/cognito_user_pool: support user_migration in lambda_config #4301

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions aws/resource_aws_cognito_user_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,11 @@ func resourceAwsCognitoUserPool() *schema.Resource {
Optional: true,
ValidateFunc: validateArn,
},
"user_migration": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateArn,
},
"verify_auth_challenge_response": {
Type: schema.TypeString,
Optional: true,
Expand Down
4 changes: 4 additions & 0 deletions aws/resource_aws_cognito_user_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ func TestAccAWSCognitoUserPool_withLambdaConfig(t *testing.T) {
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.pre_authentication"),
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.pre_sign_up"),
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.pre_token_generation"),
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.user_migration"),
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.verify_auth_challenge_response"),
),
},
Expand All @@ -362,6 +363,7 @@ func TestAccAWSCognitoUserPool_withLambdaConfig(t *testing.T) {
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.pre_authentication"),
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.pre_sign_up"),
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.pre_token_generation"),
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.user_migration"),
resource.TestCheckResourceAttrSet("aws_cognito_user_pool.main", "lambda_config.0.verify_auth_challenge_response"),
),
},
Expand Down Expand Up @@ -808,6 +810,7 @@ resource "aws_cognito_user_pool" "main" {
pre_authentication = "${aws_lambda_function.main.arn}"
pre_sign_up = "${aws_lambda_function.main.arn}"
pre_token_generation = "${aws_lambda_function.main.arn}"
user_migration = "${aws_lambda_function.main.arn}"
verify_auth_challenge_response = "${aws_lambda_function.main.arn}"
}
}`, name)
Expand Down Expand Up @@ -862,6 +865,7 @@ resource "aws_cognito_user_pool" "main" {
pre_authentication = "${aws_lambda_function.second.arn}"
pre_sign_up = "${aws_lambda_function.second.arn}"
pre_token_generation = "${aws_lambda_function.second.arn}"
user_migration = "${aws_lambda_function.second.arn}"
verify_auth_challenge_response = "${aws_lambda_function.second.arn}"
}
}`, name)
Expand Down
8 changes: 8 additions & 0 deletions aws/structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -2353,6 +2353,10 @@ func expandCognitoUserPoolLambdaConfig(config map[string]interface{}) *cognitoid
configs.PreTokenGeneration = aws.String(v.(string))
}

if v, ok := config["user_migration"]; ok && v.(string) != "" {
configs.UserMigration = aws.String(v.(string))
}

if v, ok := config["verify_auth_challenge_response"]; ok && v.(string) != "" {
configs.VerifyAuthChallengeResponse = aws.String(v.(string))
}
Expand Down Expand Up @@ -2399,6 +2403,10 @@ func flattenCognitoUserPoolLambdaConfig(s *cognitoidentityprovider.LambdaConfigT
m["pre_token_generation"] = *s.PreTokenGeneration
}

if s.UserMigration != nil {
m["user_migration"] = *s.UserMigration
}

if s.VerifyAuthChallengeResponse != nil {
m["verify_auth_challenge_response"] = *s.VerifyAuthChallengeResponse
}
Expand Down
1 change: 1 addition & 0 deletions examples/cognito-user-pool/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ resource "aws_cognito_user_pool" "pool" {
pre_authentication = "${aws_lambda_function.main.arn}"
pre_sign_up = "${aws_lambda_function.main.arn}"
pre_token_generation = "${aws_lambda_function.main.arn}"
user_migration = "${aws_lambda_function.main.arn}"
verify_auth_challenge_response = "${aws_lambda_function.main.arn}"
}

Expand Down
1 change: 1 addition & 0 deletions website/docs/r/cognito_user_pool.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The following arguments are supported:
* `pre_authentication` (Optional) - A pre-authentication AWS Lambda trigger.
* `pre_sign_up` (Optional) - A pre-registration AWS Lambda trigger.
* `pre_token_generation` (Optional) - Allow to customize identity token claims before token generation.
* `user_migration` (Optional) - The user migration Lambda config type.
* `verify_auth_challenge_response` (Optional) - Verifies the authentication challenge response.

#### Password Policy
Expand Down