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

New Resource: aws_cognito_user_group #3010

Merged
merged 7 commits into from
Feb 6, 2018

Conversation

tomelliff
Copy link
Contributor

@tomelliff tomelliff commented Jan 16, 2018

Added support for AWS Cognito User Groups.

Should close #2865 and I think might be the last thing left on #232

@tomelliff
Copy link
Contributor Author

$ make testacc TEST=./aws TESTARGS="-run=TestAccAWSCognitoUserGroup_"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCognitoUserGroup_ -timeout 120m
=== RUN   TestAccAWSCognitoUserGroup_basic
--- PASS: TestAccAWSCognitoUserGroup_basic (91.23s)
=== RUN   TestAccAWSCognitoUserGroup_complex
--- PASS: TestAccAWSCognitoUserGroup_complex (75.06s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	166.304s

@bflad bflad added new-resource Introduces a new resource. service/cognito labels Jan 16, 2018
@radeksimko radeksimko changed the title New resource: Cognito user group New Resource: aws_cognito_user_group Jan 17, 2018
@GreenSmile
Copy link

Hi, thanks for adding cognito groups!

I was preparing similar pull request (#3025). Please consider possibility to apply the following changes to your PR:

  1. Please add documentation
  2. Please add fields validation to match AWS requirements
  3. I believe debug output before every AWS call could be rather useful
  4. I think resource should be named "aws_cognito_user_pool_group", similarly to "aws_cognito_user_pool_client" and "aws_cognito_user_pool_domain". However, I'd like to hear comments from core members on this one
  5. It maybe useful to include UserPoolId to resource ID, because group name is not unique. Resource ID like us-east-1_esGpht5Fh/Admins looks self-explanatory.
  6. It would be really nice to have possibility to import existent group like
    terraform import aws_cognito_user_pool_group.admin_group us-east-1_esGpht5Fh/Admins. Not sure, however, how difficult it is.

Please check my PR for example of all points, except the very last one.

@tomelliff
Copy link
Contributor Author

@GreenSmile Hey, sorry, I had added the docs and validation during the week but while I was on the train without internet and apparently forgot to push until I just saw your comment.

I'll go through your review comments now, thanks for the comments, particularly on the Id which is a good catch that I didn't think about clearly enough because the API docs states that it has to be unique but in hindsight it clearly means unique for the user pool.

Also added debug output as per pull request feedback.
@tomelliff
Copy link
Contributor Author

tomelliff commented Jan 21, 2018

@GreenSmile I think I've covered everything you talked about but some in slightly different ways to how you approached things by the looks of it, especially around the import.

I'm unsure about changing from user_group to user_pool_group but happy to change if others feel it's more obvious that way.

Tests seem okay and I've done a bit of manual testing as well:

$ make testacc TEST=./aws TESTARGS="-run=TestAccAWSCognitoUserGroup_"
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAWSCognitoUserGroup_ -timeout 120m
=== RUN   TestAccAWSCognitoUserGroup_basic
--- PASS: TestAccAWSCognitoUserGroup_basic (91.41s)
=== RUN   TestAccAWSCognitoUserGroup_complex
--- PASS: TestAccAWSCognitoUserGroup_complex (79.48s)
=== RUN   TestAccAWSCognitoUserGroup_importBasic
--- PASS: TestAccAWSCognitoUserGroup_importBasic (49.76s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	220.668s

I've seen the merge conflict on the validators but will leave it for now until there's been a review and then I'll fix that merge conflict.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

Hi @tomelliff
thanks for this PR.

This is looking pretty good! Just a few comments, two of which (about names used in tests) I'd certainly want to be addressed prior to merging.

func TestAccAWSCognitoUserGroup_basic(t *testing.T) {
poolName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
groupName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
updatedGroupName := acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum)
Copy link
Member

Choose a reason for hiding this comment

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

Do you mind prepending a unique fixed prefix to each name? e.g. tf_acc_? This is to make it easy/possible to cleanup any potentially leaked resources from the test and make it easier to identify those leaks in general.

func TestAccAWSCognitoUserGroup_complex(t *testing.T) {
poolName := fmt.Sprintf("%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
groupName := fmt.Sprintf("%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
updatedGroupName := fmt.Sprintf("%s", acctest.RandStringFromCharSet(10, acctest.CharSetAlphaNum))
Copy link
Member

Choose a reason for hiding this comment

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

^ likewise

}

resource "aws_cognito_user_group" "main" {
name = "user-group-%s"
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: It's usually better to keep the whole name (incl. the prefix like user-group- here) in the test body as we may then reference it in checks, instead of rebuilding it again. 😉


"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/cognitoidentityprovider"
"github.com/hashicorp/errwrap"
Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: I know it's used all over the AWS provider at the moment, but in most places for no particular reason. The library is intended to address the problem of wrapping errors into errors so that we can retain all data about the original error. Here we're just wrapping errors to print them out later. In other words I think we don't need this library unless we use Contains() or ContainsType() per https://github.com/hashicorp/errwrap#usage

@radeksimko radeksimko added the waiting-response Maintainers are waiting on response from community or contributor. label Feb 4, 2018
@ghost ghost added the size/XL Managed by automation to categorize the size of a PR. label Feb 6, 2018
@tomelliff
Copy link
Contributor Author

@radeksimko Thanks for the review. Think I've covered those points now and I've fixed the merge conflict on the validators_test as well.

Copy link
Member

@radeksimko radeksimko left a comment

Choose a reason for hiding this comment

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

LGTM, thanks.

@radeksimko radeksimko merged commit 3b1e883 into hashicorp:master Feb 6, 2018
@tomelliff tomelliff deleted the cognito-user-group branch February 6, 2018 11:26
@bflad
Copy link
Contributor

bflad commented Feb 9, 2018

This has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

@bflad bflad added this to the v1.9.0 milestone Feb 9, 2018
@jayanderson
Copy link

https://www.terraform.io/docs/providers/aws/r/cognito_user_group.html - the documentation page looks a bit messed up for this feature. It isn't rendering the index sidebar and has some raw text at the top.

@radeksimko
Copy link
Member

@jayanderson Thanks for noticing. See #3411

@ghost
Copy link

ghost commented Apr 7, 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 7, 2020
@breathingdust breathingdust removed the waiting-response Maintainers are waiting on response from community or contributor. label Sep 17, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-resource Introduces a new resource. size/XL Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for aws_cognito_user_pool_group
6 participants