-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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
d/elastic_beanstalk_hosted_zones - new data source #3208
Conversation
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.
@sjauld I think this is a valid addition for the reason you mentioned. We want this provider to be helpful even when AWS isn't (they should really provide these easier than a documentation webpage 😉 ). We already maintain these lists for other IDs like ELB Hosted Zone IDs so the burden of maintenance is not that much higher.
So with that said, thanks for the contribution! I left some mostly minor notes below. We should definitely add a line item to the New Regions section of CONTRIBUTING.md
for maintainers or others to help add support for new regions when they do come online.
"github.com/hashicorp/terraform/helper/schema" | ||
) | ||
|
||
const unsupportedElasticBeanstalkRegion = "UnsupportedRegion" |
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.
We can skip something like this. 😄 I'll explain below
const unsupportedElasticBeanstalkRegion = "UnsupportedRegion" | ||
|
||
// See # http://docs.aws.amazon.com/general/latest/gr/rande.html#elasticbeanstalk_region | ||
var elasticBeanstalkHostedZoneIds = map[string]string{ |
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.
Minor nitpick: can this map be arranged alphabetically please?
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.
Can do. My approach was based on mirroring the ordering in the AWS docs, but given the low-frequency at which updates will be required I prefer alphabetical too.
region = v.(string) | ||
} | ||
|
||
zoneID := elasticBeanstalkHostedZoneIds[region] |
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.
While we appreciate the distinction between unknown and unsupported regions at the current moment this is being developed, I think we should simplify this so we do not need to maintain the difference in the future. Recently we switched the provider so AWS SDK updates with new regions will automatically validate them. We can add manually checking the Regions and Endpoints documentation for this EB Hosted Zone data source to the CONTRIBUTING.md
New Regions section of our documentation.
zoneID, ok := elasticBeanstalkHostedZoneIds[region]
if !ok {
return fmt.Errorf("Unsupported region: %s", region)
}
Providers: testAccProviders, | ||
Steps: []resource.TestStep{ | ||
{ | ||
Config: testAccCheckAwsElasticBeanstalkHostedZoneDataSource_currentRegion, |
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.
Can you please add a check for an unsupported region please?
{
Config: testAccCheckAwsElasticBeanstalkHostedZoneDataSource_region("does-not-exist"),
ExpectError: regexp.MustCompile(`Unsupported region`),
},
|
||
# Data Source: aws_elastic_beanstalk_hosted_zone | ||
|
||
Use this data source to get the ID of an elastic beanstalk hosted zone. |
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.
Did you mean to use the link at the bottom? If not, could you use it please? 😄
Done!
|
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.
Thanks @sjauld! This looks great! 🚀
make testacc TEST=./aws TESTARGS='-run=TestAccAwsDataSourceElasticBeanstalkHostedZone'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test ./aws -v -run=TestAccAwsDataSourceElasticBeanstalkHostedZone -timeout 120m
=== RUN TestAccAwsDataSourceElasticBeanstalkHostedZone
--- PASS: TestAccAwsDataSourceElasticBeanstalkHostedZone (19.66s)
PASS
ok github.com/terraform-providers/terraform-provider-aws/aws 19.716s
This has been released in terraform-provider-aws version 1.9.0. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading. |
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! |
Ref #2952
I know the above issue was closed, but I think it makes sense for this mapping of elasticbeanstalk zones to be here as a resource rather than everyone maintaining their own sets of maps.
The big update to aws/provider.go is from
go fmt
- not sure if it was deliberately like this and I should revert (my editorgo fmt
s automatically)?