Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

188
Views
How do I configure the routing rules in a cloudformation yaml?

I'm trying to configure this website routing rule for my static s3 bucket website using serverless yaml which uses cloudformation.

<RoutingRules>
  <RoutingRule>
    <Condition>
      <KeyPrefixEquals/>
      <HttpErrorCodeReturnedEquals>404</HttpErrorCodeReturnedEquals>
    </Condition>
    <Redirect>
      <Protocol>https</Protocol>
      <HostName>foo.amazonaws.com</HostName>
      <ReplaceKeyPrefixWith>prod/photos/resize?key=</ReplaceKeyPrefixWith>
      <HttpRedirectCode>307</HttpRedirectCode>
    </Redirect>
  </RoutingRule>
</RoutingRules>

How do I translate that to my yaml below?

resources:
  Resources:
    UploadBucket:
      Type: AWS::S3::Bucket
      Properties:
        BucketName: ${file(./serverless.env.yml):${opt:stage}.BucketName}
        AccessControl: PublicRead
        WebsiteConfiguration:
          IndexDocument: index.html
          RoutingRule: //What's the format that goes here?
about 4 years ago · Santiago Trujillo
2 answers
Answer question

0

RoutingRules is a list of Amazon S3 Website Configuration Routing Rules Property.

E.g.

RoutingRules:
  - RedirectRule:
      HostName: foo.amazonaws.com
      HttpRedirectCode: "307"
      Protocol: https
      ReplaceKeyPrefixWith: prod/photos/resize?key=
    RoutingRuleCondition:
      HttpErrorCodeReturnedEquals: "404"
about 4 years ago · Santiago Trujillo Report

0

If anyone interested, here is the JSON representation of the same settings

"WebsiteConfiguration" : {
 "IndexDocument": "index.html",
 "ErrorDocument": "error.html",
 "RoutingRules": [{
   "RedirectRule": {
      "HostName": {
        "foo.amazonaws.com"
      },
      "HttpRedirectCode": "307",
      "ReplaceKeyPrefixWith": "prod/photos/resize?key="
    },
    "RoutingRuleCondition": {
      "HttpErrorCodeReturnedEquals": "404"
    }
  }]
}
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!