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: Add aws_instance data source #11272

Merged
merged 2 commits into from
Jan 18, 2017
Merged

Conversation

grubernaut
Copy link
Contributor

@grubernaut grubernaut commented Jan 18, 2017

Adds the aws_instance data source, tests, and documentation.

==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/01/18 11:49:09 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSInstanceDataSource -timeout 120m
=== RUN   TestAccAWSInstanceDataSource_basic
--- PASS: TestAccAWSInstanceDataSource_basic (106.24s)
=== RUN   TestAccAWSInstanceDataSource_AzUserData
--- PASS: TestAccAWSInstanceDataSource_AzUserData (108.52s)
=== RUN   TestAccAWSInstanceDataSource_gp2IopsDevice
--- PASS: TestAccAWSInstanceDataSource_gp2IopsDevice (80.71s)
=== RUN   TestAccAWSInstanceDataSource_blockDevices
--- PASS: TestAccAWSInstanceDataSource_blockDevices (94.07s)
=== RUN   TestAccAWSInstanceDataSource_rootInstanceStore
--- PASS: TestAccAWSInstanceDataSource_rootInstanceStore (95.17s)
=== RUN   TestAccAWSInstanceDataSource_privateIP
--- PASS: TestAccAWSInstanceDataSource_privateIP (241.75s)
=== RUN   TestAccAWSInstanceDataSource_keyPair
--- PASS: TestAccAWSInstanceDataSource_keyPair (208.77s)
=== RUN   TestAccAWSInstanceDataSource_VPC
--- PASS: TestAccAWSInstanceDataSource_VPC (109.89s)
=== RUN   TestAccAWSInstanceDataSource_SecurityGroups
--- PASS: TestAccAWSInstanceDataSource_SecurityGroups (118.66s)
=== RUN   TestAccAWSInstanceDataSource_VPCSecurityGroups
--- PASS: TestAccAWSInstanceDataSource_VPCSecurityGroups (136.79s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    1300.625s

Fixes: #11172

Adds the `aws_instance` data source, tests, and documentation.

```
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/01/18 11:49:09 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWSInstanceDataSource -timeout 120m
=== RUN   TestAccAWSInstanceDataSource_basic
--- PASS: TestAccAWSInstanceDataSource_basic (106.24s)
=== RUN   TestAccAWSInstanceDataSource_AzUserData
--- PASS: TestAccAWSInstanceDataSource_AzUserData (108.52s)
=== RUN   TestAccAWSInstanceDataSource_gp2IopsDevice
--- PASS: TestAccAWSInstanceDataSource_gp2IopsDevice (80.71s)
=== RUN   TestAccAWSInstanceDataSource_blockDevices
--- PASS: TestAccAWSInstanceDataSource_blockDevices (94.07s)
=== RUN   TestAccAWSInstanceDataSource_rootInstanceStore
--- PASS: TestAccAWSInstanceDataSource_rootInstanceStore (95.17s)
=== RUN   TestAccAWSInstanceDataSource_privateIP
--- PASS: TestAccAWSInstanceDataSource_privateIP (241.75s)
=== RUN   TestAccAWSInstanceDataSource_keyPair
--- PASS: TestAccAWSInstanceDataSource_keyPair (208.77s)
=== RUN   TestAccAWSInstanceDataSource_VPC
--- PASS: TestAccAWSInstanceDataSource_VPC (109.89s)
=== RUN   TestAccAWSInstanceDataSource_SecurityGroups
--- PASS: TestAccAWSInstanceDataSource_SecurityGroups (118.66s)
=== RUN   TestAccAWSInstanceDataSource_VPCSecurityGroups
--- PASS: TestAccAWSInstanceDataSource_VPCSecurityGroups (136.79s)
PASS
ok      github.com/hashicorp/terraform/builtin/providers/aws    1300.625s
```
@stack72
Copy link
Contributor

stack72 commented Jan 18, 2017

This is awesome :) LGTM!

@grubernaut grubernaut merged commit de80ebd into master Jan 18, 2017
@grubernaut grubernaut deleted the f-add-instance-datasource branch January 18, 2017 23:30
@cemo
Copy link

cemo commented Jan 25, 2017

I was almost filed an issue for this. Thank you so much for your work.

@cemo
Copy link

cemo commented Jan 30, 2017

@grubernaut before opening an issue I wanted to be sure. It seems that aws_instance can not support multiple instances. My use case including a scenario to get instances from aws_autoscaling_groups. I would like to reach instances and include in load balancer in a dynamic way. Is limitation coming from Aws API?

@cemo
Copy link

cemo commented Jan 30, 2017

BTW https://www.terraform.io/docs/providers/aws/d/instance.html is not listed at side menu as well. :) I will add tonight.

@cemo
Copy link

cemo commented Jan 30, 2017

I have just seen your comment.

// Possibly with a different data source that returns a list of individual instance data sources

@kaii-zen
Copy link

Just a heads up, this is still not listed in the documentation side menu under data sources. I've written a lot of ugliness in order to work around the lack of an aws_instance datasource 😅

Also, it seems like this data source doesn't map the tags properly and leaves them in the form they were received from amazon. For comparison, see the state from the resource vs the data source:

tags.#                                    = 3
tags.2220489295.key                       = Name
tags.2220489295.value                     = core-001
tags.3171833312.key                       = Terraform
tags.3171833312.value                     = 1
tags.982453103.key                        = Consul
tags.982453103.value                      = Server
tags.%                                            = 3
tags.Consul                                       = Server
tags.Name                                         = core-001
tags.Terraform                                    = 1

I tried to work around this with interpolations but haven't been successful.

@ghost
Copy link

ghost commented Apr 16, 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 16, 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.

Is there aws ec2 instance datasource?
4 participants