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

Add allow_empty attribute to aws_ami and aws_ebs_snapshot data sources #12231

Closed
wants to merge 1 commit into from
Closed

Add allow_empty attribute to aws_ami and aws_ebs_snapshot data sources #12231

wants to merge 1 commit into from

Conversation

joshuaspence
Copy link
Contributor

Fixes #12081.

@@ -228,7 +234,13 @@ func dataSourceAwsAmiRead(d *schema.ResourceData, meta interface{}) error {

var image *ec2.Image
if len(filteredImages) < 1 {
return fmt.Errorf("Your query returned no results. Please change your search criteria and try again.")
if d.Get("allow_empty").(bool) {
d.SetId("-")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm not really really sure if this is necessary or if there is a better null value.

@joshuaspence
Copy link
Contributor Author

make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccAWS\(AmiDataSource\|EbsSnapshotDataSource\)_emptyPass' 
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/03/22 09:10:21 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccAWS\(AmiDataSource\|EbsSnapshotDataSource\)_emptyPass -timeout 120m
=== RUN   TestAccAWSAmiDataSource_emptyPass
--- PASS: TestAccAWSAmiDataSource_emptyPass (36.18s)
=== RUN   TestAccAWSEbsSnapshotDataSource_emptyPass
--- PASS: TestAccAWSEbsSnapshotDataSource_emptyPass (36.25s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	72.439s

@joshuaspence
Copy link
Contributor Author

> make testacc TEST=./builtin/providers/aws TESTARGS='-run=TestAccDataSourceAws\(Ami\|EbsSnapshot\)Ids' 
==> Checking that code complies with gofmt requirements...
go generate $(go list ./... | grep -v /terraform/vendor/)
2017/04/21 07:53:41 Generated command/internal_plugin_list.go
TF_ACC=1 go test ./builtin/providers/aws -v -run=TestAccDataSourceAws\(Ami\|EbsSnapshot\)Ids -timeout 120m
=== RUN   TestAccDataSourceAwsAmiIds_basic
--- PASS: TestAccDataSourceAwsAmiIds_basic (46.85s)
=== RUN   TestAccDataSourceAwsAmiIds_empty
--- PASS: TestAccDataSourceAwsAmiIds_empty (41.59s)
=== RUN   TestAccDataSourceAwsEbsSnapshotIds_basic
--- PASS: TestAccDataSourceAwsEbsSnapshotIds_basic (77.45s)
=== RUN   TestAccDataSourceAwsEbsSnapshotIds_empty
--- PASS: TestAccDataSourceAwsEbsSnapshotIds_empty (35.59s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	201.492s

@joshuaspence
Copy link
Contributor Author

Actually, let me open a new pull request given that I've changed the implementation a fair bit.

@ghost
Copy link

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

[Feature Request] data "aws_ami" - add "allow_empty" flag
2 participants