Skip to content

Instantly share code, notes, and snippets.

@Mikulas
Last active July 27, 2017 09:35
Show Gist options
  • Save Mikulas/f349882a3b5b562200ee74711834fc82 to your computer and use it in GitHub Desktop.
Save Mikulas/f349882a3b5b562200ee74711834fc82 to your computer and use it in GitHub Desktop.
UPDATE "vpc" SET "crosszone" = CASE
-- Get those values from a list of AWS VPC Subnets:
WHEN dstaddr::inet << '172.31.16.0/20' AND srcaddr::inet << '172.31.16.0/20'
THEN 0
WHEN dstaddr::inet << '172.31.0.0/20' AND srcaddr::inet << '172.31.0.0/20'
THEN 0
ELSE 1
END, "external" = CASE
-- This is a combined CIDR of all the subnets. If you can't simplify
-- into a single condition, add more cases.
WHEN dstaddr::inet << '172.31.0.0/16' AND srcaddr::inet << '172.31.0.0/16'
THEN 0
ELSE 1
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment