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

r/aws_cognitoidp_user_pool: suppress diff when schema.string_attribute_constraints is omitted #32445

Merged
merged 2 commits into from
Jul 20, 2023

Conversation

jar-b
Copy link
Member

@jar-b jar-b commented Jul 10, 2023

Description

Handles persistent differences when the schema.string_attribute_constraints argument is omitted from configuration for a String attribute type, but returned from the AWS API with default values. Because all of the existing suppression logic was implemented in the flattener function, logic to handle this case was added there as well.

Relations

Closes #21654

References

Output from Acceptance Testing

$ make testacc PKG=cognitoidp TESTS=TestAccCognitoIDPUserPool_schemaAttributes
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cognitoidp/... -v -count 1 -parallel 20 -run='TestAccCognitoIDPUserPool_schemaAttributes'  -timeout 180m

--- PASS: TestAccCognitoIDPUserPool_schemaAttributesRemoved (26.42s)
--- PASS: TestAccCognitoIDPUserPool_schemaAttributesModified (26.87s)
--- PASS: TestAccCognitoIDPUserPool_schemaAttributesStringAttributeConstraints (26.90s)
--- PASS: TestAccCognitoIDPUserPool_schemaAttributes (37.19s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cognitoidp 40.580s
$ make testacc PKG=cognitoidp TESTS=TestAccCognitoIDPUserPool_
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./internal/service/cognitoidp/... -v -count 1 -parallel 20 -run='TestAccCognitoIDPUserPool_'  -timeout 180m

--- PASS: TestAccCognitoIDPUserPool_disappears (45.92s)
=== CONT  TestAccCognitoIDPUserPool_withAdminCreateUserAndPasswordPolicy
--- PASS: TestAccCognitoIDPUserPool_basic (67.04s)
=== CONT  TestAccCognitoIDPUserPool_withDevice
--- PASS: TestAccCognitoIDPUserPool_schemaAttributesStringAttributeConstraints (78.54s)
=== CONT  TestAccCognitoIDPUserPool_schemaAttributes
--- PASS: TestAccCognitoIDPUserPool_schemaAttributesModified (82.49s)
=== CONT  TestAccCognitoIDPUserPool_recovery
--- PASS: TestAccCognitoIDPUserPool_withUserAttributeUpdateSettings (107.02s)
=== CONT  TestAccCognitoIDPUserPool_SMS_snsCallerARN
--- PASS: TestAccCognitoIDPUserPool_withPasswordPolicy (112.56s)
=== CONT  TestAccCognitoIDPUserPool_SMS_externalID
--- PASS: TestAccCognitoIDPUserPool_withAliasAttributes (112.68s)
=== CONT  TestAccCognitoIDPUserPool_SMS_snsRegion
--- PASS: TestAccCognitoIDPUserPool_withVerificationMessageTemplate (113.28s)
=== CONT  TestAccCognitoIDPUserPool_sms
--- PASS: TestAccCognitoIDPUserPool_withAdminCreateUserAndPasswordPolicy (68.60s)
=== CONT  TestAccCognitoIDPUserPool_MFA_softwareTokenMFAToSMS
--- PASS: TestAccCognitoIDPUserPool_smsVerificationMessage (114.54s)
=== CONT  TestAccCognitoIDPUserPool_MFA_softwareTokenMFA
--- PASS: TestAccCognitoIDPUserPool_withEmailVerificationMessage (114.71s)
=== CONT  TestAccCognitoIDPUserPool_MFA_smsToSoftwareTokenMFA
--- PASS: TestAccCognitoIDPUserPool_withAdminCreateUser (115.66s)
=== CONT  TestAccCognitoIDPUserPool_withEmail
--- PASS: TestAccCognitoIDPUserPool_withUsername (116.41s)
=== CONT  TestAccCognitoIDPUserPool_schemaAttributesRemoved
--- PASS: TestAccCognitoIDPUserPool_withTags (156.78s)
=== CONT  TestAccCognitoIDPUserPool_smsAuthenticationMessage
--- PASS: TestAccCognitoIDPUserPool_withAdvancedSecurityMode (157.03s)
=== CONT  TestAccCognitoIDPUserPool_deletionProtection
--- PASS: TestAccCognitoIDPUserPool_MFA_smsAndSoftwareTokenMFA (166.16s)
=== CONT  TestAccCognitoIDPUserPool_withUsernameAttributes
--- PASS: TestAccCognitoIDPUserPool_withDevice (111.58s)
--- PASS: TestAccCognitoIDPUserPool_update (179.24s)
--- PASS: TestAccCognitoIDPUserPool_withEmail (64.27s)
--- PASS: TestAccCognitoIDPUserPool_schemaAttributes (108.57s)
--- PASS: TestAccCognitoIDPUserPool_MFA_sms (187.52s)
--- PASS: TestAccCognitoIDPUserPool_WithLambda_sms (188.98s)
--- PASS: TestAccCognitoIDPUserPool_SMS_snsRegion (78.44s)
--- PASS: TestAccCognitoIDPUserPool_schemaAttributesRemoved (75.03s)
--- PASS: TestAccCognitoIDPUserPool_WithLambda_email (192.20s)
--- PASS: TestAccCognitoIDPUserPool_withLambda (194.18s)
--- PASS: TestAccCognitoIDPUserPool_MFA_smsToSoftwareTokenMFA (95.56s)
--- PASS: TestAccCognitoIDPUserPool_recovery (128.09s)
--- PASS: TestAccCognitoIDPUserPool_SMS_externalID (105.75s)
--- PASS: TestAccCognitoIDPUserPool_MFA_softwareTokenMFAToSMS (107.04s)
--- PASS: TestAccCognitoIDPUserPool_deletionProtection (64.82s)
--- PASS: TestAccCognitoIDPUserPool_smsAuthenticationMessage (65.09s)
--- PASS: TestAccCognitoIDPUserPool_MFA_softwareTokenMFA (107.92s)
--- PASS: TestAccCognitoIDPUserPool_SMS_snsCallerARN (117.01s)
--- PASS: TestAccCognitoIDPUserPool_withUsernameAttributes (59.36s)
--- PASS: TestAccCognitoIDPUserPool_sms (112.84s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cognitoidp 229.399s
$ go test -v -count=1 -run "^(TestUserPoolSchemaAttributeMatchesStandardAttribute|TestSkipFlatteningStringAttributeContraints)$" ./internal/service/cognitoidp/...

--- PASS: TestSkipFlatteningStringAttributeContraints (0.00s)
    --- PASS: TestSkipFlatteningStringAttributeContraints/config_omitted (0.00s)
    --- PASS: TestSkipFlatteningStringAttributeContraints/config_set (0.00s)
    --- PASS: TestSkipFlatteningStringAttributeContraints/config_set_with_diff (0.00s)

--- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute (0.00s)
    --- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute/birthday_non-standard_DeveloperOnlyAttribute (0.00s)
    --- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute/birthday_non-standard_Mutable (0.00s)
    --- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute/non-standard_Name (0.00s)
    --- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute/birthday_non-standard_Required (0.00s)
    --- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute/email_verified_standard (0.00s)
    --- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute/updated_at_standard (0.00s)
    --- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute/birthday_non-standard_StringAttributeConstraints.Max (0.00s)
    --- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute/birthday_non-standard_StringAttributeConstraints.Min (0.00s)
    --- PASS: TestUserPoolSchemaAttributeMatchesStandardAttribute/birthday_standard (0.00s)
PASS
ok      github.com/hashicorp/terraform-provider-aws/internal/service/cognitoidp 3.345s

@github-actions
Copy link

Community Note

Voting for Prioritization

  • Please vote on this pull request by adding a 👍 reaction to the original post to help the community and maintainers prioritize this pull request.
  • Please see our prioritization guide for information on how we prioritize.
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request.

For Submitters

  • Review the contribution guide relating to the type of change you are making to ensure all of the necessary steps have been taken.
  • For new resources and data sources, use skaff to generate scaffolding with comments detailing common expectations.
  • Whether or not the branch has been rebased will not impact prioritization, but doing so is always a welcome surprise.

@github-actions github-actions bot added tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. service/cognitoidp Issues and PRs that pertain to the cognitoidp service. size/L Managed by automation to categorize the size of a PR. labels Jul 10, 2023
@jar-b jar-b force-pushed the b-aws_cognito_user_pool-schema-diff branch from 8b54529 to c5a040a Compare July 11, 2023 14:04
@jar-b jar-b marked this pull request as ready for review July 11, 2023 14:10
@gdavison gdavison self-assigned this Jul 19, 2023
Copy link
Contributor

@gdavison gdavison left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! 🚀

--- PASS: TestAccCognitoIDPUserPool_withAdminCreateUserAndPasswordPolicy (95.76s)
--- PASS: TestAccCognitoIDPUserPool_withEmail (97.44s)
--- PASS: TestAccCognitoIDPUserPool_basic (100.66s)
--- PASS: TestAccCognitoIDPUserPool_smsVerificationMessage (155.89s)
--- PASS: TestAccCognitoIDPUserPool_withEmailVerificationMessage (156.11s)
--- PASS: TestAccCognitoIDPUserPool_withUsername (156.18s)
--- PASS: TestAccCognitoIDPUserPool_withUsernameAttributes (159.00s)
--- PASS: TestAccCognitoIDPUserPool_withPasswordPolicy (159.05s)
--- PASS: TestAccCognitoIDPUserPool_withAliasAttributes (159.05s)
--- PASS: TestAccCognitoIDPUserPool_deletionProtection (159.28s)
--- PASS: TestAccCognitoIDPUserPool_withDevice (162.38s)
--- PASS: TestAccCognitoIDPUserPool_withAdminCreateUser (167.14s)
--- PASS: TestAccCognitoIDPUserPool_schemaAttributesModified (105.39s)
--- PASS: TestAccCognitoIDPUserPool_recovery (210.11s)
--- PASS: TestAccCognitoIDPUserPool_withTags (214.73s)
--- PASS: TestAccCognitoIDPUserPool_withAdvancedSecurityMode (220.97s)
--- PASS: TestAccCognitoIDPUserPool_disappears (65.55s)
--- PASS: TestAccCognitoIDPUserPool_withUserAttributeUpdateSettings (138.95s)
--- PASS: TestAccCognitoIDPUserPool_MFA_smsAndSoftwareTokenMFA (239.82s)
--- PASS: TestAccCognitoIDPUserPool_withVerificationMessageTemplate (147.74s)
--- PASS: TestAccCognitoIDPUserPool_WithLambda_sms (247.88s)
--- PASS: TestAccCognitoIDPUserPool_schemaAttributesStringAttributeConstraints (96.75s)
--- PASS: TestAccCognitoIDPUserPool_schemaAttributesRemoved (94.03s)
--- PASS: TestAccCognitoIDPUserPool_WithLambda_email (254.79s)
--- PASS: TestAccCognitoIDPUserPool_withLambda (255.01s)
--- PASS: TestAccCognitoIDPUserPool_MFA_sms (256.47s)
--- PASS: TestAccCognitoIDPUserPool_schemaAttributes (111.53s)
--- PASS: TestAccCognitoIDPUserPool_SMS_snsRegion (66.25s)
--- PASS: TestAccCognitoIDPUserPool_smsAuthenticationMessage (85.76s)
--- PASS: TestAccCognitoIDPUserPool_SMS_snsCallerARN (130.77s)
--- PASS: TestAccCognitoIDPUserPool_SMS_externalID (124.31s)
--- PASS: TestAccCognitoIDPUserPool_MFA_softwareTokenMFAToSMS (130.21s)
--- PASS: TestAccCognitoIDPUserPool_sms (139.60s)
--- PASS: TestAccCognitoIDPUserPool_MFA_smsToSoftwareTokenMFA (78.15s)
--- PASS: TestAccCognitoIDPUserPool_update (146.29s)
--- PASS: TestAccCognitoIDPUserPool_MFA_softwareTokenMFA (91.13s)

@jar-b jar-b merged commit 334b719 into main Jul 20, 2023
@jar-b jar-b deleted the b-aws_cognito_user_pool-schema-diff branch July 20, 2023 15:07
@github-actions github-actions bot added this to the v5.9.0 milestone Jul 20, 2023
@github-actions
Copy link

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

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@v-greco
Copy link

v-greco commented Jul 20, 2023

Hello,

I just try the new release and seems it is working partially- since the plan continue to evidence a the following needed update:

schema {
+ attribute_data_type = "String"
+ developer_only_attribute = false
+ mutable = true
+ name = "preferred_username"
+ required = true
}

Thanks for your support,

Vincenzo.

@github-actions
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
service/cognitoidp Issues and PRs that pertain to the cognitoidp service. size/L Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cognito User Pool: cannot modify or remove schema items
3 participants