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 Data Source: aws_instances #2266

Merged
merged 1 commit into from
Nov 15, 2017
Merged

New Data Source: aws_instances #2266

merged 1 commit into from
Nov 15, 2017

Conversation

radeksimko
Copy link
Member

Closes #574
Replaces hashicorp/terraform#12856

Test Results

TF_ACC=1 go test ./aws -v -run=TestAccAWSInstancesDataSource_ -timeout 120m
=== RUN   TestAccAWSInstancesDataSource_basic
--- PASS: TestAccAWSInstancesDataSource_basic (163.70s)
=== RUN   TestAccAWSInstancesDataSource_tags
--- PASS: TestAccAWSInstancesDataSource_tags (155.65s)
PASS
ok  	github.com/terraform-providers/terraform-provider-aws/aws	319.375s

@radeksimko radeksimko added the new-data-source Introduces a new data source. label Nov 13, 2017
@radeksimko radeksimko added the size/L Managed by automation to categorize the size of a PR. label Nov 15, 2017
Copy link
Contributor

@catsby catsby left a comment

Choose a reason for hiding this comment

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

👍 nit/questions likely carryover from the original PR, I won't block it as-is


var instanceIds, privateIps, publicIps []string
err := conn.DescribeInstancesPages(params, func(resp *ec2.DescribeInstancesOutput, isLast bool) bool {
// loop through reservations, and remove terminated instances, populate instance slice
Copy link
Contributor

Choose a reason for hiding this comment

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

Option: could always use a filter on instance-state-name and append user filters to it, to save you this looping and possibly entire API pagination calls

Copy link
Member Author

Choose a reason for hiding this comment

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

Ha, very valid point, I'll change that 👍


log.Printf("[DEBUG] Found %d instances via given filter", len(instanceIds))

d.SetId(time.Now().String())
Copy link
Contributor

Choose a reason for hiding this comment

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

Optional/question: is there an advantage or reason to use time.Now() here for the id instead of using resource.UniqueId()?

Copy link
Member Author

Choose a reason for hiding this comment

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

UniqueID sounds safer, I'll change it - good point.

@radeksimko radeksimko merged commit b6b32d5 into master Nov 15, 2017
@radeksimko radeksimko deleted the f-d-instances branch November 15, 2017 19:27
@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. size/L Managed by automation to categorize the size of a PR.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

aws_instances data source
2 participants