-
Notifications
You must be signed in to change notification settings - Fork 9.3k
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
Replace 'testAccPreCheckOffersEc2InstanceType' with 'aws_ec2_instance_type_offering' data source #13076
Replace 'testAccPreCheckOffersEc2InstanceType' with 'aws_ec2_instance_type_offering' data source #13076
Conversation
…_type_offering' data source.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's do it! 🚀 We can consider adding an AvailabilityZone equivalent, maybe something that takes it in as an argument that can take in a reference, e.g.
// testAccAvailableEc2InstanceTypeForAvailabilityZone returns the configuration for a data source that describes
// the first available EC2 instance type offering in the current availability zone from a list of preferred instance types.
// The first argument is either an Availability Zone name or Terraform configuration reference to one, e.g.
// * data.aws_availability_zones.available.names[0]
// * aws_subnet.test.availability_zone
// * us-west-2a
// The data source is named 'available'.
func testAccAvailableEc2InstanceTypeForAvailabilityZone(availabilityZoneName string, preferredInstanceTypes ...string) string {
if !string.Contains(availabilityZoneName, ".") {
availabilityZoneName = strconv.Quote(availabilityZoneName)
}
return fmt.Sprintf(`
data "aws_ec2_instance_type_offering" "available" {
filter {
name = "instance-type"
values = ["%[2]v"]
}
filter {
name = "location"
values = [%[1]s]
}
location_type = "availability-zone"
preferred_instance_types = ["%[2]v"]
}
`, availabilityZoneName, strings.Join(preferredInstanceTypes, "\", \""))
}
And possibly moving these to their own file for now (until we come up with a good shared package structure).
Output from acceptance testing:
--- PASS: TestAccAWSInstance_metadataOptions (62.08s)
--- PASS: TestAccAWSInstanceDataSource_metadataOptions (316.81s)
Followup tracking issue: #13083 |
This has been released in version 2.60.0 of the Terraform AWS provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template for triage. Thanks! |
…_type_offering' data source. (hashicorp#13076) Output from acceptance testing: ``` --- PASS: TestAccAWSInstance_metadataOptions (62.08s) --- PASS: TestAccAWSInstanceDataSource_metadataOptions (316.81s) ```
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! |
Community Note
Following up from this comment:
Remove
testAccPreCheckOffersEc2InstanceType
and use theaws_ec2_instance_type_offering
data source to select an EC2 instance type.Relates #12491.
Release note for CHANGELOG:
Output from acceptance testing: