Skip to content

Instantly share code, notes, and snippets.

@tsertkov
Created January 2, 2018 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsertkov/af99420d26dba62d275e0616f4358971 to your computer and use it in GitHub Desktop.
Save tsertkov/af99420d26dba62d275e0616f4358971 to your computer and use it in GitHub Desktop.
Generate AWS S3 redirecting routing rules
console.log('<RoutingRules>')
;[
['/url1/', '/url2/'],
['/url11/', '/url22/']
].forEach(([source, target]) => console.log(`
<RoutingRule>
<Condition>
<KeyPrefixEquals>${source}</KeyPrefixEquals>
</Condition>
<Redirect>
<ReplaceKeyWith>${target}</ReplaceKeyWith>
</Redirect>
</RoutingRule>
`))
console.log('</RoutingRules>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment