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

Help with defining custom_error_responses #40

Closed
ppawlowski opened this issue Mar 25, 2019 · 5 comments
Closed

Help with defining custom_error_responses #40

ppawlowski opened this issue Mar 25, 2019 · 5 comments

Comments

@ppawlowski
Copy link

Hello Gents,

I am struggling with defining custom_error_responses using your module. Can you please guide how to create custom error response with values kept in one variable:

"error_code" = 404
"response_code" = 200  
"response_page_path" = "/index.html"

Thank you in advance.

@ppawlowski
Copy link
Author

Ok, with the trial-and-error approach I figured it out.
For someone, who will face the same confusion level as I, the module variable should be defined as follows:

custom_error_response = [
    {
      "error_code"          = 500
      "response_code"       = 200
      "response_page_path"  = "/error.html"
    }
]

Multiple error responses should be placed in multiple maps inside the list.

@jcf
Copy link

jcf commented Feb 12, 2021

For anyone coming across this issue in future, you need to include the error_caching_min_ttl too:

custom_error_response = [
  {
    "error_caching_min_ttl" = 3600,
    "error_code"            = 500,
    "response_code"         = 500,
    "response_page_path"    = "/error.html",
  },
  {
    "error_caching_min_ttl" = 3600,
    "error_code"            = 404,
    "response_code"         = 404,
    "response_page_path"    = "/404.html",
  },
]

I've deployed these custom response objects to Cloudfront today without issue. Hope that helps! 🙇

@filipemcg
Copy link

Also valid:

custom_error_response {
        error_caching_min_ttl = 86400
        error_code = 404
        response_code = 200
        response_page_path = "/index.html"
 }

  custom_error_response {
        error_caching_min_ttl = 86400
        error_code = 403
        response_code = 200
        response_page_path = "/index.html"
 }

@Jao-Steven-Rey-C
Copy link

Jao-Steven-Rey-C commented Nov 2, 2024

This is the snippet I am using:

custom_error_response {
    error_code            = 404
    response_page_path    = "/error.html"
    #response_code         = 404
    error_caching_min_ttl = 300
  }

So How to I make Terraform display my error.html file instead of a website that has this message:

Screenshot (238)

@ravirneni
Copy link

When response_page_path is set to "/index.html" what would be the path it looks for?
For example if CloudFront request url is https://s3content.test.com/s3folder/s3path.html => would the error file path is: https://cloufront-1.test.com/index.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants