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 change unexpected attributes every apply #3389

Closed
atsushi-ishibashi opened this issue Feb 15, 2018 · 7 comments · Fixed by #3458
Closed

resource/cognito_user_pool change unexpected attributes every apply #3389

atsushi-ishibashi opened this issue Feb 15, 2018 · 7 comments · Fixed by #3458
Labels
bug Addresses a defect in current functionality.
Milestone

Comments

@atsushi-ishibashi
Copy link
Contributor

atsushi-ishibashi commented Feb 15, 2018

@Ninir @radeksimko @bflad (Sorry for mentioning, but we have a serious problem with this bug🙇)
Maybe Related: #3009

Problem

Everytime you apply, aws_cognito_user_pool.auto_verified_attributes was removed.

Reason

cognitoidentityprovider.UpdateUserPoolInput seems to require every param if it doesn't change. So the current updates with nil and aws updates user pool with default value.
(The below example is about MfaConfiguration )

upinput := &cognitoidentityprovider.UpdateUserPoolInput{
	UserPoolId:             aws.String("user_pool_id"),
	AutoVerifiedAttributes: []*string{aws.String("email")},
	MfaConfiguration:       aws.String("OPTIONAL"),
}
_, err := svc.UpdateUserPool(upinput)
if err != nil {
	fmt.Println(err)
}
descinput := &cognitoidentityprovider.DescribeUserPoolInput{
	UserPoolId: aws.String("user_pool_id"),
}
descresp, err := svc.DescribeUserPool(descinput)
fmt.Println("AutoVerifiedAttributes: ", *descresp.UserPool.AutoVerifiedAttributes[0])
fmt.Println("MfaConfiguration: ", *descresp.UserPool.MfaConfiguration)

//console log
AutoVerifiedAttributes:  email
MfaConfiguration:  OPTIONAL

next update the same user pool

upinput := &cognitoidentityprovider.UpdateUserPoolInput{
	UserPoolId:             aws.String("user_pool_id"),
	AutoVerifiedAttributes: []*string{aws.String("email")},
}
_, err := svc.UpdateUserPool(upinput)
if err != nil {
	fmt.Println(err)
}
descinput := &cognitoidentityprovider.DescribeUserPoolInput{
	UserPoolId: aws.String("user_pool_id"),
}
descresp, err := svc.DescribeUserPool(descinput)
fmt.Println("AutoVerifiedAttributes: ", *descresp.UserPool.AutoVerifiedAttributes[0])
fmt.Println("MfaConfiguration: ", *descresp.UserPool.MfaConfiguration)

//console log
AutoVerifiedAttributes:  email
MfaConfiguration:  OFF

By filtering HasChange, every apply change the real resource.
So far I couldn't confirm which params work in the same way...

And I couldn't understand why acceptance test catch this one 🤔 The behavior of aws has changed??

The cause may be go-sdk?

PS:

The cause may be go-sdk?

cli works the same.

And I couldn't understand why acceptance test catch this one

Because only attributes which changed were checked.

@atsushi-ishibashi atsushi-ishibashi changed the title resource/cognito_user_pool change attributes every apply resource/cognito_user_pool change unexpected attributes every apply Feb 15, 2018
@atsushi-ishibashi
Copy link
Contributor Author

auto_verified_attributes example

upinput := &cognitoidentityprovider.UpdateUserPoolInput{
	UserPoolId:             aws.String("user_pool_id"),
	AutoVerifiedAttributes: []*string{aws.String("email")},
	MfaConfiguration:       aws.String("OPTIONAL"),
}
_, err := svc.UpdateUserPool(upinput)
if err != nil {
	fmt.Println(err)
}
descinput := &cognitoidentityprovider.DescribeUserPoolInput{
	UserPoolId: aws.String("user_pool_id"),
}
descresp, err := svc.DescribeUserPool(descinput)
if len(descresp.UserPool.AutoVerifiedAttributes) > 0 {
	fmt.Println("AutoVerifiedAttributes: ", *descresp.UserPool.AutoVerifiedAttributes[0])
} else {
	fmt.Println("AutoVerifiedAttributes: null")
}
fmt.Println("MfaConfiguration: ", *descresp.UserPool.MfaConfiguration)

//log
AutoVerifiedAttributes:  email
MfaConfiguration:  OPTIONAL

next

upinput := &cognitoidentityprovider.UpdateUserPoolInput{
	UserPoolId:             aws.String("user_pool_id"),
	MfaConfiguration:       aws.String("OPTIONAL"),
}
_, err := svc.UpdateUserPool(upinput)
if err != nil {
	fmt.Println(err)
}
descinput := &cognitoidentityprovider.DescribeUserPoolInput{
	UserPoolId: aws.String("user_pool_id"),
}
descresp, err := svc.DescribeUserPool(descinput)
if len(descresp.UserPool.AutoVerifiedAttributes) > 0 {
	fmt.Println("AutoVerifiedAttributes: ", *descresp.UserPool.AutoVerifiedAttributes[0])
} else {
	fmt.Println("AutoVerifiedAttributes: null")
}
fmt.Println("MfaConfiguration: ", *descresp.UserPool.MfaConfiguration)

//log
AutoVerifiedAttributes:  null
MfaConfiguration:  OPTIONAL

@atsushi-ishibashi
Copy link
Contributor Author

According to aws, the behaviour of update-user-pool is a specification.

@radeksimko radeksimko added bug Addresses a defect in current functionality. service/cognito labels Feb 15, 2018
@radeksimko
Copy link
Member

Hey @atsushi-ishibashi
can you provide a repro case with config attached and expected/actual output/outcome?

Thanks.

@radeksimko radeksimko added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 15, 2018
@atsushi-ishibashi
Copy link
Contributor Author

atsushi-ishibashi commented Feb 15, 2018

@radeksimko Sure👍
At the beginning

resource "aws_cognito_user_pool" "pool" {
  name                     = "mypool"
  auto_verified_attributes = ["email"]
  mfa_configuration        = "OFF"
}

cli output

$ aws cognito-idp describe-user-pool --user-pool-id hogehoge --query 'UserPool.MfaConfiguration' 
"OFF"
$ aws cognito-idp describe-user-pool --user-pool-id hogehoge --query 'UserPool.AutoVerifiedAttributes'
[
    "email"
]

Next update tf and apply.

resource "aws_cognito_user_pool" "pool" {
  name                     = "mypool"
  auto_verified_attributes = ["email"]
  mfa_configuration        = "OPTIONAL"
}

cli output

$ aws cognito-idp describe-user-pool --user-pool-id hogehoge --query 'UserPool.MfaConfiguration' 
"OFF"
$ aws cognito-idp describe-user-pool --user-pool-id hogehoge --query 'UserPool.AutoVerifiedAttributes'
null

Expected Outcome

Only MfaConfiguration changed.
AutoVerifiedAttributes remained ["email"]

Actual

AutoVerifiedAttributes changed

@radeksimko radeksimko removed the waiting-response Maintainers are waiting on response from community or contributor. label Feb 15, 2018
@bflad bflad added this to the v1.32.0 milestone Aug 9, 2018
@bflad
Copy link
Contributor

bflad commented Aug 9, 2018

The fix to properly pass all defined attributes during update of aws_cognito_user_pool has been merged and will release with version 1.32.0 of the AWS provider, likely middle of next week.

@bflad
Copy link
Contributor

bflad commented Aug 16, 2018

This has been released in version 1.32.0 of the AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@ghost
Copy link

ghost commented Apr 4, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Apr 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Addresses a defect in current functionality.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants