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

providers/aws: Add support for S3 website redirect #1909

Merged
merged 1 commit into from
May 15, 2015

Conversation

justincampbell
Copy link
Contributor

This adds support for redirecting all requests for an S3 website endpoint to another hostname.

The API supports both a hostname and protocol, but this only adds the hostname field.

redirectAllRequestsTo := website["redirect_all_requests_to"].(string)

if indexDocument == "" && redirectAllRequestsTo == "" {
return fmt.Errorf("Must specify either index_document or redirect_all_requests_to.")
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Is there a way to enforce this in the schema?

Copy link
Contributor

Choose a reason for hiding this comment

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

Not at the moment

@justincampbell
Copy link
Contributor Author

I'd be happy to add protocol field as well, I just didn't know how often it's used, and how to name the variables:

website {
  redirect_all_requests_to_hostname = "hashicorp.com"
  redirect_all_requests_to_protocol = "https"
}

@justincampbell
Copy link
Contributor Author

It's also worth mentioning that the AWS console UI doesn't expose the protocol portion of the API:

https://docs.aws.amazon.com/AmazonS3/latest/dev/website-hosting-custom-domain-walkthrough.html

ConflictsWith: []string{
"website.0.index_document",
"website.0.error_document",
},
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The build is failing because InternalValidate in helper/schema/schema.go doesn't support this nested notation for ConflictsWith, even though in usage it seems to work correctly.

Copy link
Member

Choose a reason for hiding this comment

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

Being the original author of ConflictsWith, I know about this limitation, but I was finding it hard to create any nested schema (can't remember what was the problem exactly though), putting aside ConflictsWith.

Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't the website actually be TypeSet?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@radeksimko we settled on list vs set for this, but I forget why

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed with #1926!

phinze added a commit that referenced this pull request May 12, 2015
The runtime impl of ConfictsWith uses Resource.Get(), which makes it
work with any other attribute of the resource - the InternalValidate was
only checking against the local schemaMap though, preventing subResource
from using ConflictsWith properly.

It's a lot of wiring and it's a bit ugly, but it's not runtime code, so
I'm a bit less concerned about that aspect.

This should take care of the problem mentioned in #1909
@catsby
Copy link
Contributor

catsby commented May 15, 2015

LGTM

justincampbell added a commit that referenced this pull request May 15, 2015
providers/aws: Add support for S3 website redirect
@justincampbell justincampbell merged commit e68dd5a into hashicorp:master May 15, 2015
@justincampbell justincampbell deleted the s3-redirect branch May 15, 2015 13:32
@justincampbell justincampbell restored the s3-redirect branch April 5, 2016 15:10
@ghost
Copy link

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

4 participants