Skip to content

Instantly share code, notes, and snippets.

@saml
Created April 29, 2019 21:43
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 saml/0fb62228c3bd767db25d73e2b1b897ad to your computer and use it in GitHub Desktop.
Save saml/0fb62228c3bd767db25d73e2b1b897ad to your computer and use it in GitHub Desktop.
nginx:
pkg:
- installed
service.running:
- watch:
- file: /etc/nginx/nginx.conf
- cmd: /etc/nginx/cloudfront.conf
/etc/aws/ip-ranges.json:
file.managed:
- source: https://ip-ranges.amazonaws.com/ip-ranges.json
- source_hash: sha256
/etc/nginx/cloudfront.conf:
cmd.run:
- name: jq -r '"set_real_ip_from " + (.prefixes[] | select(.service=="CLOUDFRONT") | .ip_prefix) + ";"' /etc/aws/ip-ranges.json > /etc/nginx/cloudfront.conf
- onchanges:
- file: /etc/aws/ip-ranges.json
@waynew
Copy link

waynew commented Apr 29, 2019

this will work perfect if you can actually provide the source_hash (and you're OK with the state failing when it updates)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment