<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Stephan Schroevers on Medium]]></title>
        <description><![CDATA[Stories by Stephan Schroevers on Medium]]></description>
        <link>https://medium.com/@stephan202?source=rss-f691c947a256------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*XcyJ57AU8vKZfFfX.</url>
            <title>Stories by Stephan Schroevers on Medium</title>
            <link>https://medium.com/@stephan202?source=rss-f691c947a256------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 10:49:53 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@stephan202/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Pingdom probes and AWS security groups]]></title>
            <link>https://medium.com/picnic-engineering/pingdom-probes-and-aws-security-groups-f276d73ea0df?source=rss-f691c947a256------2</link>
            <guid isPermaLink="false">https://medium.com/p/f276d73ea0df</guid>
            <category><![CDATA[pingdom]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Stephan Schroevers]]></dc:creator>
            <pubDate>Fri, 31 Mar 2017 11:46:45 GMT</pubDate>
            <atom:updated>2017-03-31T16:29:25.284Z</atom:updated>
            <content:encoded><![CDATA[<p>At Picnic we use various infrastructure and service monitoring tools. In order to ascertain service availability and be notified of downtime we use <a href="https://www.pingdom.com/">Pingdom</a>. This service uses so-called <em>probes</em> to send predefined requests to selected services at regular intervals, verifying that the responses match preconfigured criteria.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*SPSvs51FTnlvh0XlNSbkWQ.png" /></figure><h4>A simple task</h4><p>Recently we wanted to enable Pingdom for a service which is only externally available to a small number of public IP addresses. Naturally, such configuration prevented Pingdom from accessing this service. Opening up the service to the whole world was not an option.</p><p>Luckily, Pingdom publishes a <a href="https://help.pingdom.com/hc/en-us/articles/203682601-Pingdom-probes-public-IP-addresses">list</a> of all IP addresses from which its probe requests may originate. So we decided to extend our IP whitelist to include just those IPs. As we use AWS (Amazon Web Services), this entails transcribing the aforementioned list to the appropriate <a href="https://docs.aws.amazon.com/opsworks/latest/userguide/best-practices-groups.html">security groups</a>.</p><h4>Challenges</h4><p>Doing so comes with a number of challenges:</p><ul><li>It’s very cumbersome and error-prone to manually add the IPs to a security group.</li><li>AWS limits security group rules to 50 entries, while Pingdom publishes around 100 IP addresses.</li><li>Over time the set of IPs to be whitelisted changes. This means that the security groups must be kept in sync. Not doing so is a security risk (in case of IPs over which Pingdom cedes control) and a source of false positive downtime alerts (in case of new non-whitelisted IPs).</li></ul><p>Furthermore, it’s advisable to configure the Pingdom IP whitelist using separate security groups, so that the addresses can be told apart from other whitelisted IPs.</p><h4>Third-party solutions</h4><p>So we looked into ways of “doing it right”. We found two partial solutions, both of which provided inspiration for the solution on which we eventually settled:</p><ol><li><a href="https://github.com/akremer/pingdom-ec2-security">akremer/pingdom-ec2-security</a>. This Ruby-based script allows the one-time population of a security group. It fetches the probe IP list through the Pingdom API, thus requiring authentication. Unfortunately it only populates a single security group. This was probably good enough back when the script was first written, but as mentioned above, support for multiple security groups is now a must.</li><li><a href="https://github.com/degiere/pingdom-ec2-security-group-updater">degiere/pingdom-ec2-security-group-updater</a>. This bash script queries the public Pingom probe list using curl and thus does not require Pingdom credentials. It also modifies just a single security group, this time using the <a href="https://aws.amazon.com/cli/">AWS CLI</a> (command line interface). Upon each invocation the security group is completely emptied and then repopulated. This is an improvement over the other script, but does mean that an update to the IP whitelist will temporarily block valid IP addresses.</li></ol><h4>Our solution</h4><p>We considered extending either of the aforementioned solutions in order to add the functionality we missed. But after some Python-based prototyping it seemed that a complete rewrite was actually easier, while at the same time yielding more robust code.</p><p>The result is a script which:</p><ol><li>Accepts an arbitrary number of security groups.</li><li>Transcribes the Pingdom probe IP list into the least number of provided security groups.</li><li>Efficiently keeps the security groups synchronized with the probe list.</li><li>Does not temporarily remove whitelisted IP addresses, preventing false positive downtime alerts during its execution.</li><li>Is idempotent; invoking the script repeatedly while the security groups are already synchronized is a “NO-OP”.</li></ol><p>The following is an example run of the script, at a moment when Pingdom published four fewer IP addresses than it did at the time of the previous run (the security group IDs were anonymized):</p><pre>$ ./sync-pingdom-ec2-security-groups.sh sg-12345678 sg-23456789 sg-34567890<br>Dropping from SG sg-12345678: Permission tcp:78.31.69.179/32:80–80<br>Dropping from SG sg-12345678: Permission tcp:76.72.171.180/32:80–80<br>Dropping from SG sg-12345678: Permission tcp:158.58.173.160/32:80–80<br>Dropping from SG sg-12345678: Permission tcp:72.46.140.186/32:80–80<br>Adding to SG sg-12345678: Permission tcp:54.70.202.58/32:80–80<br>Adding to SG sg-12345678: Permission tcp:52.197.224.235/32:80–80<br>Adding to SG sg-12345678: Permission tcp:52.63.164.147/32:80–80<br>Adding to SG sg-12345678: Permission tcp:23.111.152.74/32:80–80<br>Dropping from SG sg-23456789: Permission tcp:54.70.202.58/32:80–80<br>Dropping from SG sg-23456789: Permission tcp:52.197.224.235/32:80–80<br>Dropping from SG sg-23456789: Permission tcp:52.63.164.147/32:80–80<br>Dropping from SG sg-23456789: Permission tcp:23.111.152.74/32:80–80<br>Adding to SG sg-23456789: Permission tcp:52.63.142.2/32:80–80<br>Adding to SG sg-23456789: Permission tcp:52.209.34.226/32:80–80<br>Adding to SG sg-23456789: Permission tcp:178.255.154.2/32:80–80<br>Adding to SG sg-23456789: Permission tcp:54.68.48.199/32:80–80<br>Dropping from SG sg-34567890: Permission tcp:52.63.142.2/32:80–80<br>Dropping from SG sg-34567890: Permission tcp:52.209.34.226/32:80–80<br>Dropping from SG sg-34567890: Permission tcp:178.255.154.2/32:80–80<br>Dropping from SG sg-34567890: Permission tcp:54.68.48.199/32:80–80<br>SUCCESS</pre><p>Running the script once more does not further modify the security groups:</p><pre>$ ./sync-pingdom-ec2-security-groups.sh sg-12345678 sg-23456789 sg-34567890<br>SUCCESS</pre><p>As you can see, the four removed IPs were all contained in the first of the three security groups listed. Once removed, other IP addresses are “shifted” into their place. Note that IP addresses shifted from one security group to another are added at their new destination before being removed from their old location.</p><h4>The code</h4><p>We published the code on <a href="https://github.com/PicnicSupermarket/pingdom-probes-aws-whitelist">Github</a>. Feel free to leave feedback or suggest improvements by filing an issue or pull request.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f276d73ea0df" width="1" height="1" alt=""><hr><p><a href="https://medium.com/picnic-engineering/pingdom-probes-and-aws-security-groups-f276d73ea0df">Pingdom probes and AWS security groups</a> was originally published in <a href="https://medium.com/picnic-engineering">Picnic Engineering</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>