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

data/aws_iam_user: Add a data source for IAM user #1805

Merged
merged 3 commits into from
Oct 9, 2017

Conversation

slaunay
Copy link
Contributor

@slaunay slaunay commented Oct 3, 2017

New feature

This data source can be used to fetch information about a specific IAM user.
By using this data source, you can reference IAM user properties without having to hard code ARNs or unique IDs as input (e.g. referencing a user aws:userId when creating an IAM policy).

Code change

  • adding aws_iam_user data source
  • adding acceptance test cases (existing user and non existing user)
  • adding documentation for the new data source

Testing done

TF_ACC=1 go test -run=TestAccAWSDataSourceIAMUser_basic -v
=== RUN   TestAccAWSDataSourceIAMUser_basic
--- PASS: TestAccAWSDataSourceIAMUser_basic (11.09s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	11.118s

Misc

The code of this contribution was based a lot on #1140, thanks @stack72.

This data source can be used to fetch information about a specific
IAM user. By using this data source, you can reference IAM user
properties without having to hard code ARNs or unique IDs as input.
@radeksimko radeksimko added the new-data-source Introduces a new data source. label Oct 9, 2017
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 @slaunay
we rarely test for negative cases (that something doesn't exist), because such tests tend to be very fragile. We should make no assumptions about the AWS account and IAM users (and their names) if possible.

For that reason I took the liberty and removed that test before merging as the PR looked otherwise simple and I thought it's worth merging straight away.

I also added a missing link to the sidebar. I hope you don't mind.

@radeksimko radeksimko merged commit d7be4e7 into hashicorp:master Oct 9, 2017
@slaunay
Copy link
Contributor Author

slaunay commented Oct 9, 2017

👍 @radeksimko Thanks for making those changes and merging them.

The failure test helped me find out that the resp variable is never nil (after cloning the d/iam_group feature) when looking at the code coverage:
https://github.com/terraform-providers/terraform-provider-aws/blob/5815c0d72834326f2315c6e9ceaab460f93d1b77/aws/data_source_aws_iam_group.go#L46-L52

But I agree that the regexp makes the test brittle.

@slaunay slaunay deleted the feature/data-iam-user branch October 9, 2017 23:55
@ghost
Copy link

ghost commented Apr 10, 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 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
new-data-source Introduces a new data source.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants