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 aws_ami_ids and aws_ebs_snapshot_ids resources #13844

Merged
merged 1 commit into from
Apr 21, 2017
Merged

Add aws_ami_ids and aws_ebs_snapshot_ids resources #13844

merged 1 commit into from
Apr 21, 2017

Conversation

joshuaspence
Copy link
Contributor

Fixes #12081. Adds new aws_ami_ids and aws_ebs_snapshot_ids resources.

@joshuaspence
Copy link
Contributor Author

One thing that I wasn't sure of is whether the ids output should be sorted in any particular way. For example, it wasn't completely clear to me how you would uses the resources to obtain the most-recent EBS snapshot, whilst also allowing for the snapshot to not exist. I was thinking that if we sort the output ids by age then you could do something like this (I'm not sure how Terraform handles accessing an index of an array that doesn't exist, I'm assuming that it returns some sort of null value here):

data "aws_ebs_snapshot_ids" "test" {
  # filter { ... }
}

resource "aws_ebs_volume" "test" {
  availability_zone = "us-west-2a"
  size              = 40
  snapshot_id       = "${data.aws_ebs_snapshot_ids.test.ids[0]}"
}

@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 21:48:34 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 (89.93s)
=== RUN   TestAccDataSourceAwsAmiIds_empty
--- PASS: TestAccDataSourceAwsAmiIds_empty (68.24s)
=== RUN   TestAccDataSourceAwsEbsSnapshotIds_basic
--- PASS: TestAccDataSourceAwsEbsSnapshotIds_basic (95.20s)
=== RUN   TestAccDataSourceAwsEbsSnapshotIds_empty
--- PASS: TestAccDataSourceAwsEbsSnapshotIds_empty (43.34s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	296.724s

@joshuaspence
Copy link
Contributor Author

One other issue is that there is a fair bit of code duplication between the existing aws_ami and aws_ebs_snapshot resources and the aws_ami_ids and aws_ebs_snapshot resources and I'm not sure how best to consolidate the shared code.

Fixes #12081. Adds new `aws_ami_ids` and `aws_ebs_snapshot_ids` resources.
@stack72
Copy link
Contributor

stack72 commented Apr 21, 2017

This LGTM! Thanks for this @joshuaspence :) I am presuming those now closes #12081 ?

% 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 16:33:43 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 (36.55s)
=== RUN   TestAccDataSourceAwsAmiIds_empty
--- PASS: TestAccDataSourceAwsAmiIds_empty (26.25s)
=== RUN   TestAccDataSourceAwsEbsSnapshotIds_basic
--- PASS: TestAccDataSourceAwsEbsSnapshotIds_basic (61.11s)
=== RUN   TestAccDataSourceAwsEbsSnapshotIds_empty
--- PASS: TestAccDataSourceAwsEbsSnapshotIds_empty (22.90s)
PASS
ok  	github.com/hashicorp/terraform/builtin/providers/aws	146.842s

@stack72 stack72 merged commit 2aac8fb into hashicorp:master Apr 21, 2017
@tamsky
Copy link
Contributor

tamsky commented Apr 22, 2017

Thanks very much for this @joshuaspence indeed!

apparentlymart pushed a commit that referenced this pull request Apr 25, 2017
As a follow up to #13844, this pull request sorts the AMIs and snapshots returned from the aws_ami_ids and aws_ebs_snapshot_ids data sources, respectively.
@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
3 participants