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

provider/aws: Update calling_identity #13092

Merged
merged 3 commits into from
Apr 3, 2017
Merged

Conversation

grubernaut
Copy link
Contributor

Updates aws_caller_identity data source to actually include the correct attributes from the GetCallerIdentity API function.

$ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSCallerIdentity_basic'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/27 09:26:13 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSCallerIdentity_basic -timeout 120m
=== RUN   TestAccAWSCallerIdentity_basic
--- PASS: TestAccAWSCallerIdentity_basic (12.74s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    12.767s

Fixes: #13084

Updates `aws_caller_identity` data source to actually include the correct attributes from the `GetCallerIdentity` API function.

```
$ make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWSCallerIdentity_basic'
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/27 09:26:13 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSCallerIdentity_basic -timeout 120m
=== RUN   TestAccAWSCallerIdentity_basic
--- PASS: TestAccAWSCallerIdentity_basic (12.74s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    12.767s
```
log.Printf("[DEBUG] Setting AWS Account ID to %s.", *res.Account)
d.Set("account_id", *res.Account)
d.Set("arn", *res.Arn)
d.Set("user_id", *res.UserId)
Copy link
Contributor

Choose a reason for hiding this comment

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

A pattern I've seen elsewhere is to just pass in the pointer without dereferencing it, since d.Set will automatically unwrap it safely, and thus we avoid crashes if for some reason AWS ends up returning nil for any of these.

Copy link
Contributor

@apparentlymart apparentlymart left a comment

Choose a reason for hiding this comment

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

Small feedback on the docs but otherwise this looks reasonable to me!

@@ -32,4 +40,6 @@ There are no arguments available for this data source.

## Attributes Reference

`account_id` is set to the ID of the AWS account.
`account_id` - The AWS Account ID number of the account that owns or contains the calling entity.
Copy link
Contributor

Choose a reason for hiding this comment

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

I guess this wasn't a list before because there was only one item, but our usual style is for the exported attributes to be a bullet list using *.

@grubernaut grubernaut merged commit 5cce6b9 into master Apr 3, 2017
@grubernaut grubernaut deleted the f-update-sts-caller-identity branch April 3, 2017 18:29
@ghost
Copy link

ghost commented Apr 14, 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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 14, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add ARN and UserID to AWS_CALLER_IDENTITY data source
3 participants