-
Notifications
You must be signed in to change notification settings - Fork 71
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
Allow user to set redirect options for the bucket #23
Conversation
@linusmarco It's taken me a while to get to this, sorry about that! I'll try to review this over the weekend. |
No problem at all. That sounds good to me! |
@linusmarco oh nice, I didn't realize this CloudFormation option was available. What's the use case for In the indexDoc/errorDoc PR I submitted, I originally had a Sorry if this is a little off-topic from the PR itself! |
@evanseeds -- I'm honestly not sure what a real-world use case would be for the Using routingRules:
- redirect:
hostName: www.my-website.com
httpRedirectCode: 300
protocol: https
replaceKeyPrefixWith: '#/'
condition:
httpErrorCodeReturnedEquals: 404 The big use case for routingRules:
...
- redirect:
hostName: gatewayhash.execute-api.us-east-1.amazonaws.com
httpRedirectCode: 300
protocol: https
replaceKeyPrefixWith: 'production/'
condition:
keyPrefixEquals: 'api/' But there's a bunch of other useful stuff you can do with these options too! |
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.
I few general suggestions on how we can improve the structure. Address those and I'll try to test this for merge Wednesday.
README.md
Outdated
indexDocument: index.html # (Optional) The name of your index document inside your distributionFolder. Defaults to index.html | ||
errorDocument: error.html # (Optional) The name of your error document inside your distributionFolder. Defaults to error.html | ||
redirectAllRequestsTo: # (Optional) If specified, all requests will redirect to specified endpoint | ||
hostName: [hostName] # (Required) Name of the host where requests are redirected (e.g. www.google.com) | ||
protocol: [http|http] # (Optional) Protocol for redirect |
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.
Fix - http|http
--> http|https
?
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.
good catch!
README.md
Outdated
routingRules: # (Optional) Redirect routing rules | ||
- redirect: # (Required) Redirect options for this rule | ||
hostName: [hostName] # (Optional) Name of the host where requests are redirected (e.g. www.google.com) | ||
httpRedirectCode: [CODE] # (Optional) HTTP status code for redirect |
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.
add example codes? Or is this all covered in the AWS docs. I'm fine with linking to that in multiple places this if it is.
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.
I don't think they spell it out in the AWS docs, so I'll give some examples here
README.md
Outdated
- redirect: # (Required) Redirect options for this rule | ||
hostName: [hostName] # (Optional) Name of the host where requests are redirected (e.g. www.google.com) | ||
httpRedirectCode: [CODE] # (Optional) HTTP status code for redirect | ||
protocol: [http|http] # (Optional) Protocol for redirect |
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.
Same fix as above. one should be https?
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.
👍
index.js
Outdated
|
||
} | ||
|
||
function confirm(expr, error) { |
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.
This is kinda awkward and uses the same name as the built-in browser function confirm().
What do you think about using something like this - https://github.com/arasatasaygin/is.js
Might still need a little custom work to implement it but seems like it might save us defining a bunch of custom checks. If we're going to define those they should be broken out of an already unwieldy index.js
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.
Whoops, I had completely forgotten that confirm was a built-in...I never really use it. The library you linked looks like a great option for the kind of stuff that I was rolling-my-own on. I'm happy to switch to that. Thanks!
@fernando-mc - I addressed your comments. Thanks for the review! |
@linusmarco awesome! Last thing, can you please update to conform with the style guidelines PR you put in? I figured it would be better to get the style guidelines in sooner since they would basically make everything have a merge conflict. |
@fernando-mc - updated coding and docs style to comply with recently merged PR. Should be ready to merge. |
@fernando-mc - Updated to fix merge conflicts resulting from #42 Tested and should be ready to merge |
Just updated this PR to merge to the new development branch rather than master |
@linusmarco, awesome work! I’ll take a look at everything tomorrow. Hoping to run a set of tests on all PRs that are ready for it then we can merge into development! |
@linusmarco I think I dropped the ball on this. Can we salvage the code changes from this and move forward on this again after I merge up v2? |
@fernando-mc I actually worked these changes into the refactor (#43), so no need to do anythong with this PR. I'll close it. |
This PR implements the feature I described in #21.
Specifically, the user is now allowed to set all redirect/routing options supported by the CloudFormation API:
https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-s3-websiteconfiguration.html
Note that I had to slightly change the implementation of the recent error/index document options because CloudFormation does not allow the optional RedirectAllRequestsTo property to be specified with any other WebsiteConfiguration options. Therefore, we cannot set IndexDocument and ErrorDocument by default; instead those now get set only if RedirectAllRequestsTo is not specified. Existing behavior is unchanged (for these options and everything else).
Thanks!