From 2cae81ed3f650dc5e90f33b6ab9744ec7fc9b7eb Mon Sep 17 00:00:00 2001 From: "xiaowei.wang" Date: Sat, 21 Apr 2018 11:19:30 +0200 Subject: [PATCH] r/cognito_user_pool: support user_migration in lambda_config --- aws/resource_aws_cognito_user_pool.go | 5 +++++ aws/resource_aws_cognito_user_pool_test.go | 4 ++++ aws/structure.go | 8 ++++++++ examples/cognito-user-pool/main.tf | 1 + website/docs/r/cognito_user_pool.markdown | 1 + 5 files changed, 19 insertions(+) diff --git a/aws/resource_aws_cognito_user_pool.go b/aws/resource_aws_cognito_user_pool.go index 25ef24a9b974..ba9891b93d74 100644 --- a/aws/resource_aws_cognito_user_pool.go +++ b/aws/resource_aws_cognito_user_pool.go @@ -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, diff --git a/aws/resource_aws_cognito_user_pool_test.go b/aws/resource_aws_cognito_user_pool_test.go index de730b2a25a2..d20787e175ee 100644 --- a/aws/resource_aws_cognito_user_pool_test.go +++ b/aws/resource_aws_cognito_user_pool_test.go @@ -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"), ), }, @@ -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"), ), }, @@ -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) @@ -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) diff --git a/aws/structure.go b/aws/structure.go index ddfb94b7b65b..26b9c70afb6d 100644 --- a/aws/structure.go +++ b/aws/structure.go @@ -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)) } @@ -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 } diff --git a/examples/cognito-user-pool/main.tf b/examples/cognito-user-pool/main.tf index 74c65c62f0dd..53316fa5c697 100644 --- a/examples/cognito-user-pool/main.tf +++ b/examples/cognito-user-pool/main.tf @@ -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}" } diff --git a/website/docs/r/cognito_user_pool.markdown b/website/docs/r/cognito_user_pool.markdown index 093e9fe611f9..31e295d350a3 100644 --- a/website/docs/r/cognito_user_pool.markdown +++ b/website/docs/r/cognito_user_pool.markdown @@ -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