<?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 Olivier Butterbach on Medium]]></title>
        <description><![CDATA[Stories by Olivier Butterbach on Medium]]></description>
        <link>https://medium.com/@obutterbach?source=rss-d4a06db01174------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*8MPb4ha_sAlqPRcQuX6rvA.jpeg</url>
            <title>Stories by Olivier Butterbach on Medium</title>
            <link>https://medium.com/@obutterbach?source=rss-d4a06db01174------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 00:39:14 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@obutterbach/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[TL;DR Password Managers]]></title>
            <link>https://obutterbach.medium.com/tl-dr-password-managers-d130eaaf0257?source=rss-d4a06db01174------2</link>
            <guid isPermaLink="false">https://medium.com/p/d130eaaf0257</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[2fa-authentication]]></category>
            <category><![CDATA[site-reliability-engineer]]></category>
            <category><![CDATA[password-management]]></category>
            <category><![CDATA[team-collaboration]]></category>
            <dc:creator><![CDATA[Olivier Butterbach]]></dc:creator>
            <pubDate>Sat, 28 Nov 2020 16:14:00 GMT</pubDate>
            <atom:updated>2021-08-14T00:07:22.172Z</atom:updated>
            <content:encoded><![CDATA[<p>As a SRE Engineer Background, I was shopping around for finding some potential good candidates for holding passwords / 2FA, and sharing them easily with my Family or Teams.</p><p>I also keep my blog updated with new articles with my consulting company, you can check at <a href="https://cdcloudlogix.com/blog">https://cdcloudlogix.com/blog</a> for more information :)</p><h3>I. Goals</h3><p>This document just give a quick overview of some of the password managers out there, here’s my list of my personal requirements:</p><ul><li><strong>Team / Family management:</strong> Adding and sharing made easy.</li><li><strong>Pricing:</strong> Not excessive for a small group of people</li><li><strong>Expose Public API:</strong> <em>Useful for CI/CD Pipelines / system users</em></li><li><strong>2FA integration:</strong> <em>Handy when you can share 2FA with your Team / Family directly.</em></li><li><strong>Audit Logs usage:</strong> <em>Who did what</em></li><li><strong>“Cloud” solution</strong> <em>without files management (KeePassX for instance)</em>.</li><li><strong>Mobile App</strong></li><li><strong>Browser Extension</strong></li><li><strong>Reddit Community Feeling reviews</strong> <em>(Very subjective to my personal review)</em></li></ul><h3><strong>II. Results</strong></h3><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2582ee3bbc3645db5a9f0b86ec269d29/href">https://medium.com/media/2582ee3bbc3645db5a9f0b86ec269d29/href</a></iframe><h3>III. Conclusion</h3><p>There are many Password Managers out there, and this tab just outlined the main one. I hope that would also be useful for you out there :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d130eaaf0257" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Enforcing Public Block Access on S3 Bucket automatically]]></title>
            <link>https://obutterbach.medium.com/enforcing-public-block-access-on-s3-bucket-automatically-9b4a167ce650?source=rss-d4a06db01174------2</link>
            <guid isPermaLink="false">https://medium.com/p/9b4a167ce650</guid>
            <category><![CDATA[s3-bucket]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[automation]]></category>
            <dc:creator><![CDATA[Olivier Butterbach]]></dc:creator>
            <pubDate>Tue, 28 Apr 2020 21:17:08 GMT</pubDate>
            <atom:updated>2021-08-14T00:08:34.848Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*VcorXBK15wqo8VnV3zyezQ.png" /><figcaption>Overview</figcaption></figure><p>Here is a quick guide on how to implement a lambda function which would <strong>scan all of your S3 Buckets</strong> and <strong>enforce Public Block Access ACLs</strong> automatically if they’re missing. Once completed, <strong>an email would be triggered</strong> to indicate which S3 Bucket was modified. This configuration is using Terraform 0.12 version to deploy this project.</p><p>This documentation is based on this following GitHub repository, any questions, don’t hesitate to raise it.</p><p>I also keep my blog updated with new articles with my consulting company, you can check at <a href="https://cdcloudlogix.com/blog">https://cdcloudlogix.com/blog</a> for more information :)</p><p><a href="https://github.com/cdcloudlogix/terraform_s3_public_notifications">cdcloudlogix/terraform_s3_public_notifications</a></p><h3>I. Terraform Providers</h3><p>Start by configuring your main AWS account as a Terraform provider as follow:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/93df738b08a9383520a61612770081db/href">https://medium.com/media/93df738b08a9383520a61612770081db/href</a></iframe><p>Once completed, add your Terraform backend:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/78be67ea34486ebcfb86297f3246343b/href">https://medium.com/media/78be67ea34486ebcfb86297f3246343b/href</a></iframe><p>Don’t forget to modify the S3 bucket name as well as the key name based on your situation.</p><h3>II. Modules</h3><p>This project is using a unique module:</p><ul><li>s3-scan-public</li></ul><p>This module would install the following resources:</p><ul><li>IAM roles and policies</li><li>CloudWatch Events</li><li>Lambda</li><li>SNS Notification</li></ul><h3>III. Lambda function</h3><p>This project is using a bash script for installing / testing and zipping our lambda function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e8c23feec9f3e620a3b3d451354d67d/href">https://medium.com/media/2e8c23feec9f3e620a3b3d451354d67d/href</a></iframe><p>Before applying Terraform plan, the zip file would have to be present on the local file system.</p><p>Prepare a virtual environment for python before running this on your terminal:</p><pre>$ virtualenv -p python3 venv<br>Running virtualenv with interpreter /usr/local/bin/python3<br>Using base prefix &#39;/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7&#39;<br>New python executable in /Users/oli/Documents/venv/bin/python3.7<br>Also creating executable in /Users/oli/Documents/venv/bin/python<br>Installing setuptools, pip, wheel...<br>done.$ source venv/bin/activate</pre><h3>IV. SSM Parameters</h3><p>To avoid exposing email addresses in a GitHub repository, this project is making the use of the following SSM parameters:</p><ul><li><strong><em>s3-public-exception-list: </em></strong>List of S3 Buckets excluded from Scan(StringList type)</li><li><strong><em>default-source-email</em></strong>: Default name used as a source (String type)</li><li><strong><em>default-destination-emails</em></strong>: List of email recipients (StringList type)</li></ul><p>Regarding the configuration of each of these SSM parameters, have a look below on these screenshots:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*urnI1H0r8O2i9Y0ujykt5Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*8vpB9b2iRxVv9oGx7prNew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*9QtrRB4etDYElZdGmXPyCg.png" /><figcaption>SSM Parameters configuration</figcaption></figure><h3>V. Deploy</h3><p>Package your lambda script first (Truncated output):</p><pre>21:12 $ ./python_packages.sh<br>Requirement already satisfied: pytest in /Users/oli/Documents/terraform_s3_public_notifications/venv/lib/python3.7/site-packages </pre><pre>[...]</pre><pre>~/Documents/terraform_s3_public_notifications/modules/s3-scan-public ~/Documents/terraform_s3_public_notifications/modules</pre><pre>-------------------------------------------------------------------<br>Your code has been rated at 10.00/10 (previous run: 9.22/10, +0.78)</pre><pre>~/Documents/terraform_s3_public_notifications/modules<br>~/Documents/terraform_s3_public_notifications/modules/s3-scan-public ~/Documents/terraform_s3_public_notifications/modules<br>  adding: s3_public.py (deflated 70%)<br>~/Documents/terraform_s3_public_notifications/modules</pre><p>Then execute terraform init command (Truncated output):</p><pre>21:13 $ terraform init<br>Initializing modules...</pre><pre>Initializing the backend...</pre><pre>Initializing provider plugins...</pre><pre>The following providers do not have any version constraints in configuration,<br>so the latest version was installed.<br>[...]</pre><p>Finally, apply Terraform (Truncated output):</p><pre>(venv) ✔ ~/Documents/terraform_s3_public_notifications [master|✔]<br>21:51 $ terraform apply<br>module.s3-public-lambda.data.aws_ssm_parameter.s3_public_emails: Refreshing state...<br>module.s3-public-lambda.data.aws_caller_identity.current: Refreshing state...<br>module.s3-public-lambda.data.aws_ssm_parameter.display_name: Refreshing state...<br>module.s3-public-lambda.data.template_file.cloudformation_sns_stack: Refreshing state...</pre><pre>[...]</pre><pre>Plan: 15 to add, 0 to change, 0 to destroy.</pre><pre>Do you want to perform these actions?<br>  Terraform will perform the actions described above.<br>  Only &#39;yes&#39; will be accepted to approve.</pre><pre>Enter a value: yes</pre><pre>module.s3-public-lambda.aws_iam_policy.s3_public_log_policy: Creating...<br>module.s3-public-lambda.aws_cloudwatch_event_rule.schedule: Creating...<br>module.s3-public-lambda.aws_iam_policy.access_ssm_policy: Creating...<br>module.s3-public-lambda.aws_iam_policy.access_s3_policy: Creating...<br>module.s3-public-lambda.aws_iam_role.lambda_s3_public_role: Creating...<br>module.s3-public-lambda.aws_cloudformation_stack.sns_topic: Creating...<br>[...]</pre><p>If you’re happy with this configuration, just confirm by typing<strong><em> yes</em></strong></p><p>After deploying, each recipient would receive the following email from AWS, don’t forget to confirm that you wish to subscribe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VYFgBp0MMZotas5RdnUlLA.png" /><figcaption>Confirmation email of subscription</figcaption></figure><h3>VI. Details of this repository</h3><p>The following lambda function will:</p><ul><li>List all your existing buckets</li><li>Compare this list with the exempt list of S3 Buckets present in your SSM parameter</li><li>Check if Public Access Block ACL is applied on each of your bucket</li><li>Apply Public Access Block ACL on your bucket if it wasn’t apply</li><li>Notify by SNS notification</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2bdd80eb53bf49ad4e35ca08b396f001/href">https://medium.com/media/2bdd80eb53bf49ad4e35ca08b396f001/href</a></iframe><p>This lambda would be run from Monday to Friday each week:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/5850826f023236f40150186fd3d68808/href">https://medium.com/media/5850826f023236f40150186fd3d68808/href</a></iframe><p>Terraform doesn’t support SNS Email configuration natively, hence, the reason why we need to use a Cloudformation template for this purpose:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2ae4687f0415ffdf04686404ffe6b65d/href">https://medium.com/media/2ae4687f0415ffdf04686404ffe6b65d/href</a></iframe><p>Combine with the following template file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2e11dc0ec41ad32d8f7475616e552bf5/href">https://medium.com/media/2e11dc0ec41ad32d8f7475616e552bf5/href</a></iframe><h3>VII. Testing</h3><p>You can test your lambda by using the <strong><em>Test</em></strong> button as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/934/1*2EDJOzI4WwIaNZ5SitEvaw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*L27KDG9qRqViBlc5Uaig-w.png" /><figcaption>AWS Lambda test</figcaption></figure><p>This function would start running and setting up the Public Access Block ACLs on each of your existing buckets. Once Completed, you should receive the following email of confirmation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EWAXQ7_4EKoLA_T1bAWGGQ.png" /><figcaption>Email notification</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9b4a167ce650" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Scan and set Server Side Encryption on all of your S3 Buckets with Terraform]]></title>
            <link>https://obutterbach.medium.com/scan-and-set-server-side-encryption-on-all-of-your-s3-buckets-with-terraform-4267b7483e0e?source=rss-d4a06db01174------2</link>
            <guid isPermaLink="false">https://medium.com/p/4267b7483e0e</guid>
            <category><![CDATA[s3]]></category>
            <category><![CDATA[lambda-function]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-sns]]></category>
            <dc:creator><![CDATA[Olivier Butterbach]]></dc:creator>
            <pubDate>Sun, 26 Apr 2020 11:39:51 GMT</pubDate>
            <atom:updated>2021-08-14T00:09:16.346Z</atom:updated>
            <content:encoded><![CDATA[<h3>Encrypt all of your S3 Buckets automatically</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/574/1*fDxSkqMHekzNLkAN7-KXfg.png" /><figcaption>Overview</figcaption></figure><p>Here is a quick guide on how to implement a lambda function which would <strong>scan all of your S3 Buckets</strong> and set the <strong>server side encryption</strong> automatically. Once completed, <strong>an email would be triggered</strong> to indicate which S3 Bucket was modified. This configuration is using Terraform 0.12 version to deploy this project.</p><p>This documentation is based on this following GitHub repository, any questions, don’t hesitate to raise it.</p><p>I also keep my blog updated with new articles with my consulting company, you can check at <a href="https://cdcloudlogix.com/blog">https://cdcloudlogix.com/blog</a> for more information :)</p><p><a href="https://github.com/cdcloudlogix/terraform_s3_encryption_email">cdcloudlogix/terraform_s3_encryption_email</a></p><h3>I. Terraform Providers</h3><p>Start by configuring your main AWS account as a Terraform provider as follow:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/d79f19ce1657311a9a6d7fe68a02edc3/href">https://medium.com/media/d79f19ce1657311a9a6d7fe68a02edc3/href</a></iframe><p>Once completed, add your Terraform backend:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/55c7e1f3057ac1e7d710e86bcd62b892/href">https://medium.com/media/55c7e1f3057ac1e7d710e86bcd62b892/href</a></iframe><p>Don’t forget to modify the S3 bucket name as well as the key name based on your situation.</p><h3>II. Modules</h3><p>This project is using a unique module:</p><ul><li>s3-scan-encryption</li></ul><p>This module would install the following resources:</p><ul><li>IAM roles and policies</li><li>CloudWatch Events</li><li>Lambda</li><li>SNS Notification</li></ul><h3>III. Lambda function</h3><p>This project is using a bash script for installing / testing and zipping our lambda function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9e081cad39180288f8e4d49acc9a722c/href">https://medium.com/media/9e081cad39180288f8e4d49acc9a722c/href</a></iframe><p>Before applying Terraform plan, the zip file would have to be present on the local file system.</p><p>Prepare a virtual environment for python before running this on your terminal:</p><pre>$ virtualenv -p python3 venv<br>Running virtualenv with interpreter /usr/local/bin/python3<br>Using base prefix &#39;/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7&#39;<br>New python executable in /Users/oli/Documents/venv/bin/python3.7<br>Also creating executable in /Users/oli/Documents/venv/bin/python<br>Installing setuptools, pip, wheel...<br>done.</pre><pre>$ source venv/bin/activate</pre><h3>IV. SSM Parameters</h3><p>To avoid exposing email addresses in a GitHub repository, this project is making the use of the following SSM parameters:</p><ul><li><strong><em>s3-encryption-exception-list: </em></strong>List of S3 Buckets excluded from Scan(StringList type)</li><li><strong><em>default-source-email</em></strong>: Default name used as a source (String type)</li><li><strong><em>default-destination-emails</em></strong>: List of email recipients (StringList type)</li></ul><p>Regarding the configuration of each of these SSM parameters, have a look below on these screenshots:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/802/1*7gOFFJGLPC9rR2YophYhKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/804/1*8vpB9b2iRxVv9oGx7prNew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/722/1*9QtrRB4etDYElZdGmXPyCg.png" /></figure><h3>V. Deploy</h3><p>Package your lambda script first (Truncated output):</p><pre>19:23 $ ./python_packages.sh<br>Requirement already satisfied: pytest in /Users/oli/Documents/terraform_s3_encryption_email/venv/lib/python3.7/site-packages (from -r requirements_test.txt (line 1)) (5.4.1)</pre><pre>[...]</pre><pre>--------------------------------------------------------------------<br>Your code has been rated at 10.00/10 (previous run: 10.00/10, +0.00)</pre><pre>~/Documents/terraform_s3_encryption_email/modules<br>~/Documents/terraform_s3_encryption_email/modules/s3-scan-encryption ~/Documents/terraform_s3_encryption_email/modules<br>  adding: s3_encryption.py (deflated 69%)<br>~/Documents/terraform_s3_encryption_email/modules</pre><p>Then execute terraform init command (Truncated output):</p><pre>11:51 $ terraform init<br>Initializing modules...</pre><pre>Initializing the backend...</pre><pre>Initializing provider plugins...</pre><pre>The following providers do not have any version constraints in configuration,<br>so the latest version was installed.</pre><pre>To prevent automatic upgrades to new major versions that may contain breaking<br>changes, it is recommended to add version = &quot;...&quot; constraints to the<br>corresponding provider blocks in configuration, with the constraint strings<br>suggested below.</pre><pre>* provider.template: version = &quot;~&gt; 2.1&quot;</pre><pre>Terraform has been successfully initialized!</pre><pre>You may now begin working with Terraform. Try running &quot;terraform plan&quot; to see<br>any changes that are required for your infrastructure. All Terraform commands<br>should now work.</pre><pre>If you ever set or change modules or backend configuration for Terraform,<br>rerun this command to reinitialize your working directory. If you forget, other<br>commands will detect it and remind you to do so if necessary.</pre><p>Finally, apply Terraform (Truncated output):</p><pre>1:51 $ terraform apply<br>module.s3-encryption-lambda.data.aws_ssm_parameter.display_name: Refreshing state...<br>module.s3-encryption-lambda.data.aws_caller_identity.current: Refreshing state...<br>module.s3-encryption-lambda.data.aws_ssm_parameter.s3_encryption_emails: Refreshing state...<br>module.s3-encryption-lambda.data.template_file.cloudformation_sns_stack: Refreshing state...</pre><pre>An execution plan has been generated and is shown below.<br>Resource actions are indicated with the following symbols:<br>  + create<br> &lt;= read (data resources)</pre><pre>Terraform will perform the following actions:</pre><pre># module.s3-encryption-lambda.data.aws_iam_policy_document.sns_publish will be read during apply<br>  # (config refers to values not yet known)<br> &lt;= data &quot;aws_iam_policy_document&quot; &quot;sns_publish&quot;  {<br>      + id   = (known after apply)<br>      + json = (known after apply)</pre><pre>+ statement {<br>          + actions   = [<br>              + &quot;SNS:Publish&quot;,<br>            ]<br>          + effect    = &quot;Allow&quot;<br>          + resources = [<br>              + (known after apply),<br>            ]<br>        }<br>    }</pre><pre>[...]</pre><pre>Plan: 15 to add, 0 to change, 0 to destroy.</pre><pre>Do you want to perform these actions?<br>  Terraform will perform the actions described above.<br>  Only &#39;yes&#39; will be accepted to approve.</pre><pre>Enter a value: </pre><p>If you’re happy with this configuration, just confirm by typing<strong><em> yes</em></strong></p><p>After deploying, each recipient would receive the following email from AWS, don’t forget to confirm that you wish to subscribe:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oxRwIDonjNLBkbapjy81DQ.png" /><figcaption>Subscription email</figcaption></figure><h3>VI. Details of this repository</h3><p>The following lambda function will:</p><ul><li>List all your existing buckets</li><li>Compare this list with the exempt list of S3 Buckets present in your SSM parameter</li><li>Check if KMS or SSE is applied on each of your bucket</li><li>Apply SSE on your bucket if it wasn’t apply</li><li>Notify by SNS notification</li></ul><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/58947ba6cb59f7e02a3892b9a52891e3/href">https://medium.com/media/58947ba6cb59f7e02a3892b9a52891e3/href</a></iframe><p>This lambda would be run from Monday to Friday each week:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/fcd2926d1e8fc8d6bba85e736da9e6bf/href">https://medium.com/media/fcd2926d1e8fc8d6bba85e736da9e6bf/href</a></iframe><p>Terraform doesn’t support SNS Email configuration natively, hence, the reason why we need to use a Cloudformation template for this purpose:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/37a2706fa635e246591cff5615f20b0e/href">https://medium.com/media/37a2706fa635e246591cff5615f20b0e/href</a></iframe><p>Combine with the following template file:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8bd47c4f18bb0220152ba4b0f87c3a95/href">https://medium.com/media/8bd47c4f18bb0220152ba4b0f87c3a95/href</a></iframe><h3>VII. Testing</h3><p>You can test your lambda by using the <strong><em>Test</em></strong> button as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*okaYx5ond4RltPPBase5Kg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vy9XEAsgMLgrqRdTF78M8Q.png" /><figcaption>Test configuration</figcaption></figure><p>This function would start running and setting up the encryption on each of your existing buckets. Once Completed, you should receive the following email of confirmation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5KgE7W1Z3uLr3-bgCTz4Zw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4267b7483e0e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS EventBus with Terraform]]></title>
            <link>https://obutterbach.medium.com/aws-eventbus-with-terraform-ea5f3873dd49?source=rss-d4a06db01174------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea5f3873dd49</guid>
            <category><![CDATA[aws-cloudwatch]]></category>
            <category><![CDATA[cloudwatch]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloudwatch-events]]></category>
            <dc:creator><![CDATA[Olivier Butterbach]]></dc:creator>
            <pubDate>Sat, 18 Apr 2020 12:46:27 GMT</pubDate>
            <atom:updated>2021-08-14T00:09:58.575Z</atom:updated>
            <content:encoded><![CDATA[<p>A simple guide on how to deploy a Cloudwatch EventBus with Terraform. If you check the <a href="https://www.terraform.io/docs/providers/aws/r/cloudwatch_event_permission.html">official Terraform documentation</a>, you will notice that it’s quite light and you’ll probably need some guidance at this point.</p><p>I also keep my blog updated with new articles with my consulting company, you can check at <a href="https://cdcloudlogix.com/blog">https://cdcloudlogix.com/blog</a> for more information :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*zaQAl36qYrjvB2HBolyLDA.png" /><figcaption>Passing Cloudwatch Events from one AWS Account to another</figcaption></figure><p>This solution would required the need to create an IAM role for allowing CloudWatch Event to <em>PutsEvents</em> into your remote AWS Account.</p><h3>1. Terraform Providers</h3><p>This solution is using Terraform version 0.12.16, you can set different aliases as follow. Terraform would then use these providers when we start creating our modules:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/52c9b1cb55c0308ceb89f963cd7358fe/href">https://medium.com/media/52c9b1cb55c0308ceb89f963cd7358fe/href</a></iframe><p>Once completed, don’t forget to add your backend configuration:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ef74bab26e8009eadbbe3d7963f787d/href">https://medium.com/media/3ef74bab26e8009eadbbe3d7963f787d/href</a></iframe><p>Keep in mind that bucket naming are unique globally, you will need to use your own unique one.</p><h3>2. Modules</h3><p>This project is composed of 2 different modules:</p><ul><li><strong>ec2-events </strong>(Member AWS accounts)</li><li><strong>eventbus-sqs </strong>(Main AWS account)</li></ul><p>Let’s start with the module what would be install in your main account.</p><h3>3. Main AWS account module</h3><p>This module is divided in several parts, let’s see the EventBus configuration:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/eef6981f742be0325939ffb6921a5742/href">https://medium.com/media/eef6981f742be0325939ffb6921a5742/href</a></iframe><p>This resource would need the following variable, EventBus would then <em>trust</em> each of your member AWS accounts.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/635de029f3c2ee721841ed2b4c51be9c/href">https://medium.com/media/635de029f3c2ee721841ed2b4c51be9c/href</a></iframe><p>With this, Terraform would iterate each member account and create a resource for each of them. Keep in mind that EventBus is <strong>region restricted</strong>, which mean you would need to repeat this variable configuration for each of your regions.</p><p>Next part of our module is CloudWatch Event link to SQS for collecting EC2 events from the main AWS account:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0e59663d3cba1d20b89194925aa7c611/href">https://medium.com/media/0e59663d3cba1d20b89194925aa7c611/href</a></iframe><p>This part would then generate CloudWatch Event rule, SQS queue and link each other with a target rule.</p><p>Final part, create an IAM role for allowing your AWS member account to put events in your main account:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/16b38d48af4dcc331b6635d367a85ba0/href">https://medium.com/media/16b38d48af4dcc331b6635d367a85ba0/href</a></iframe><p>This part conclude the main module, let’s have a look on the member one.</p><h3>4. Member AWS Account module</h3><p>This module is a lot more simpler that the previous one, start by declaring CloudWatch Event resource:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b8519965c68f6da84f4ed56cee95a18f/href">https://medium.com/media/b8519965c68f6da84f4ed56cee95a18f/href</a></iframe><p>Then, target the default EventBus of your main account and create an IAM role for CloudWatch:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/222f7b73e6ffa712bc208c81bef921ab/href">https://medium.com/media/222f7b73e6ffa712bc208c81bef921ab/href</a></iframe><p>Finally, create a policy to assume the previously created IAM role (in the main account) and link it to your IAM role as follow:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/14e0c286486b4c457482533a3167b4b4/href">https://medium.com/media/14e0c286486b4c457482533a3167b4b4/href</a></iframe><p>Please take note of the following declaration of variables in this module (partially display):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8e50a2a016374d20b3a11364cacec4bd/href">https://medium.com/media/8e50a2a016374d20b3a11364cacec4bd/href</a></iframe><p>Let’s move on to the final part for deploying all this</p><h3>5. Final part and deployment</h3><p>We almost reach the end of this guideline, we just need to call out our modules as follow:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6ef8438bfaa246fa96237b774db3956a/href">https://medium.com/media/6ef8438bfaa246fa96237b774db3956a/href</a></iframe><p>Don’t forget to declare your variables, then just deploy this as follow:</p><pre>$ terraform init<br>[...]<br>$ terraform apply</pre><p>By triggering some EC2 activities, you should start to see flowing some event into your newly created SQS queue:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ASwk_Mp6zSWktVVy0L7WRA.png" /><figcaption>SQS Monitoring</figcaption></figure><p>You can find all of this configuration at the following <a href="https://github.com/cdcloudlogix/eventbus_terraform">Github Repository</a>, any questions, please let me know 😃.</p><p><a href="https://github.com/cdcloudlogix/eventbus_terraform">cdcloudlogix/eventbus_terraform</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea5f3873dd49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlock the full potential of Pihole]]></title>
            <link>https://obutterbach.medium.com/unlock-the-full-potential-of-pihole-e795342e0e36?source=rss-d4a06db01174------2</link>
            <guid isPermaLink="false">https://medium.com/p/e795342e0e36</guid>
            <category><![CDATA[adblocker]]></category>
            <category><![CDATA[security]]></category>
            <category><![CDATA[tracker]]></category>
            <category><![CDATA[pihole]]></category>
            <category><![CDATA[dns]]></category>
            <dc:creator><![CDATA[Olivier Butterbach]]></dc:creator>
            <pubDate>Wed, 08 Apr 2020 17:06:38 GMT</pubDate>
            <atom:updated>2021-08-14T00:11:12.498Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b_l230K-Zqrjj2XBVPQ8UQ.png" /><figcaption>Pihole dashboard</figcaption></figure><p><strong><em>Foreword</em></strong><em>: I’m fascinated by technology and I wanted to share my findings while expirementing with Pihole. I’m not personally against advertisement companies as long as they’re not too intrusive. Pihole is advertised as an ad blocker, but it’s actually an amazing tool for protecting your own network from malwares and so on. I also keep my blog updated with new articles with my consulting company, you can check at </em><a href="https://cdcloudlogix.com/blog"><em>https://cdcloudlogix.com/blog</em></a><em> for more information :)</em></p><h3>I. Requirement and installation</h3><p>Starting point of our journey, I will cover this part really quickly as you can find many guideline online for installing Pihole.</p><p>I’m personally using Pihole installed on a <strong>Raspberry pi</strong>, I gave a fixed private IP on my network where I’m redirecting all my DNS queries. You need to have some basic knowledge of Linux command lines for installing Pihole, here is a link to the official documentation from <a href="https://www.raspberrypi.org/documentation/usage/terminal/">Raspberry pi</a> on how to operate the Terminal.</p><p>If you have some experience using Terminal, you can then start Pihole installation by simply using:</p><pre>curl -sSL https://install.pi-hole.net | bash</pre><p>This command will proceed automatically to this installation. For more information and guidelines, have a look on the <a href="https://docs.pi-hole.net/main/basic-install/">official Pihole documentation</a>.</p><h3>II. Pihole Dashboard</h3><p>Another part I will cover quickly, Pihole Dashboard is rather self explanatory. Once you completed the previous installation in part I, open your fav browser the following address:</p><pre>http://&lt;Pihole IP address&gt;/admin</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fbyuPB45AW6b0jFjSq14eA.png" /><figcaption>Pihole Dashboard</figcaption></figure><p>The password for <em>login</em> tab is randomised and given after the installation in your terminal, you can always reset it by using in your terminal:</p><pre>$ pihole -a -p</pre><p>You will then be presented with this detailed dashboard:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gPUaLiOhEE8bkHxvMR2UQw.png" /><figcaption>Pihole detail dashboard</figcaption></figure><p>This Dashboardwould allow to access <em>most </em>of the Pihole controls such as DHCP, DNS configuration and so on as well as reloading the configuration. Dashboard does help troubleshooting and visualising the global amount of dns request traffic, something you will need once we unlock the full potential of Pihole by using the command line in the next following parts.</p><h3>III. Community filter lists</h3><p>First step to make the most of your new toy would be to utilise the list of filtered domains already gathered by the community. The website <a href="https://filterlists.com/">filterlists.com</a> contains the primary main elements for helping you to block:</p><ul><li>Spyware domains</li><li>Malware domains</li><li>Coinmining networks</li><li>Ransomware domains</li><li>Phishing domains</li><li>Trackers and Analyticals domains</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGXquHahYGTVe1wkjXf5SQ.png" /><figcaption>Pihole logo is displayed when the filter is compatible with Pihole</figcaption></figure><p>To implement one of the filter, select the one you’d like to use and right click on the link<em> “ 🔎 View” </em>and select<em> Copy link location. </em>From there, open your terminal and paste this URL in the <em>/etc/pihole/adlists.list</em> file. Once completed, reload Pihole configuration by using pihole -g command. Here is an example of the output of this command:</p><pre>root@raspberrypi:~# pihole -g<br>  [i] Pi-hole blocking is enabled<br>  [i] Neutrino emissions detected...<br>  [✓] Pulling blocklist source list into range</pre><pre>[i] Target: raw.githubusercontent.com (adservers-and-trackers.txt)<br>  [✓] Status: Retrieval successful</pre><p>These external filter list are maintained and updated some time to time, I would advise to make use of a <a href="https://help.dreamhost.com/hc/en-us/articles/215767047-Creating-a-custom-Cron-Job">Cron job</a> in order to keep these list up to date by using the above command on a weekly basis.</p><p>As a starting point, here is my list of filters implemented on my personnal Pihole:</p><pre>root@raspberrypi:/home/pi# cat /etc/pihole/adlists.list<br># Prevent Trackers and Malwares<br><a href="https://raw.githubusercontent.com/DRSDavidSoft/additional-hosts/master/domains/blacklist/adservers-and-trackers.txt">https://raw.githubusercontent.com/DRSDavidSoft/additional-hosts/master/domains/blacklist/adservers-and-trackers.txt</a><br><a href="https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt">https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-malware.txt</a><br><a href="https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-blocklist.txt">https://gitlab.com/quidsup/notrack-blocklists/raw/master/notrack-blocklist.txt</a><br><a href="https://raw.githubusercontent.com/notracking/hosts-blocklists/master/hostnames.txt">https://raw.githubusercontent.com/notracking/hosts-blocklists/master/hostnames.txt</a><br><a href="https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt">https://s3.amazonaws.com/lists.disconnect.me/simple_tracking.txt</a><br><a href="https://gitlab.com/my-privacy-dns/matrix/matrix/-/raw/master/source/tracking/domains.list">https://gitlab.com/my-privacy-dns/matrix/matrix/-/raw/master/source/tracking/domains.list</a><br><a href="https://raw.githubusercontent.com/r-a-y/mobile-hosts/master/AdguardApps.txt">https://raw.githubusercontent.com/r-a-y/mobile-hosts/master/AdguardApps.txt</a><br><a href="https://raw.githubusercontent.com/r-a-y/mobile-hosts/master/AdguardMobileAds.txt">https://raw.githubusercontent.com/r-a-y/mobile-hosts/master/AdguardMobileAds.txt</a><br><a href="https://raw.githubusercontent.com/FadeMind/hosts.extras/master/StreamingAds/hosts">https://raw.githubusercontent.com/FadeMind/hosts.extras/master/StreamingAds/hosts</a><br><a href="https://raw.githubusercontent.com/w13d/adblockListABP-PiHole/master/Spotify.txt">https://raw.githubusercontent.com/w13d/adblockListABP-PiHole/master/Spotify.txt</a><br><a href="https://raw.githubusercontent.com/DRSDavidSoft/additional-hosts/master/domains/blacklist/adservers-and-trackers.txt">https://raw.githubusercontent.com/DRSDavidSoft/additional-hosts/master/domains/blacklist/adservers-and-trackers.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/AdAway-Default-Blocklist.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/AdAway-Default-Blocklist.txt</a><br><a href="https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt">https://s3.amazonaws.com/lists.disconnect.me/simple_ad.txt</a><br><a href="https://v.firebog.net/hosts/Easyprivacy.txt">https://v.firebog.net/hosts/Easyprivacy.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/FadeMind-addSpam.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/FadeMind-addSpam.txt</a><br><a href="https://raw.githubusercontent.com/mitchellkrogza/The-Big-List-of-Hacked-Malware-Web-Sites/master/hacked-domains.list">https://raw.githubusercontent.com/mitchellkrogza/The-Big-List-of-Hacked-Malware-Web-Sites/master/hacked-domains.list</a></pre><pre># Prevent Analytics<br><a href="https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/AmazonFireTV.txt">https://raw.githubusercontent.com/Perflyst/PiHoleBlocklist/master/AmazonFireTV.txt</a><br><a href="https://raw.githubusercontent.com/mitchellkrogza/Stop.Google.Analytics.Ghost.Spam.HOWTO/master/output/domains/INACTIVE/list">https://raw.githubusercontent.com/mitchellkrogza/Stop.Google.Analytics.Ghost.Spam.HOWTO/master/output/domains/INACTIVE/list</a><br><a href="https://raw.githubusercontent.com/nickspaargaren/no-google/master/categories/analytics.txt">https://raw.githubusercontent.com/nickspaargaren/no-google/master/categories/analytics.txt</a><br><a href="https://raw.githubusercontent.com/nickspaargaren/no-google/master/categories/analyticsparsed">https://raw.githubusercontent.com/nickspaargaren/no-google/master/categories/analyticsparsed</a><br><a href="https://raw.githubusercontent.com/kowith337/PersonalFilterListCollection/master/hosts/hosts_facebook0.txt">https://raw.githubusercontent.com/kowith337/PersonalFilterListCollection/master/hosts/hosts_facebook0.txt</a><br><a href="https://raw.githubusercontent.com/anudeepND/blacklist/master/facebook.txt">https://raw.githubusercontent.com/anudeepND/blacklist/master/facebook.txt</a></pre><pre># Prevent Spyware<br><a href="https://raw.githubusercontent.com/r-a-y/mobile-hosts/master/AdguardMobileSpyware.txt">https://raw.githubusercontent.com/r-a-y/mobile-hosts/master/AdguardMobileSpyware.txt</a><br><a href="https://raw.githubusercontent.com/XionKzn/PiHole-Lists/master/PiHole_HOSTS_Spyware.txt">https://raw.githubusercontent.com/XionKzn/PiHole-Lists/master/PiHole_HOSTS_Spyware.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/WindowsSpyBlocker81.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/WindowsSpyBlocker81.txt</a><br><a href="https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt">https://raw.githubusercontent.com/crazy-max/WindowsSpyBlocker/master/data/hosts/spy.txt</a></pre><pre># Prevent Coinmining network<br><a href="https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/list.txt">https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/list.txt</a><br><a href="https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/list_browser.txt">https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/list_browser.txt</a><br><a href="https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/hosts">https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/hosts</a><br><a href="https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/hosts_optional">https://gitlab.com/ZeroDot1/CoinBlockerLists/raw/master/hosts_optional</a><br><a href="https://raw.githubusercontent.com/anudeepND/blacklist/master/CoinMiner.txt">https://raw.githubusercontent.com/anudeepND/blacklist/master/CoinMiner.txt</a><br><a href="https://raw.githubusercontent.com/austinheap/sophos-xg-block-lists/master/nocoin.txt">https://raw.githubusercontent.com/austinheap/sophos-xg-block-lists/master/nocoin.txt</a></pre><pre># Prevent Ransomware<br><a href="https://raw.githubusercontent.com/pirat28/IHateTracker/master/iHateTracker.txt">https://raw.githubusercontent.com/pirat28/IHateTracker/master/iHateTracker.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/CryptoWall-Ransomware-C2-Domain-blocklist.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/CryptoWall-Ransomware-C2-Domain-blocklist.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/Locky-Ransomware-C2-Domain-Blocklist.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/Locky-Ransomware-C2-Domain-Blocklist.txt</a><br><a href="https://raw.githubusercontent.com/XionKzn/PiHole-Lists/master/Cerber_Ransomware.txt">https://raw.githubusercontent.com/XionKzn/PiHole-Lists/master/Cerber_Ransomware.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/Ransomware-Domain-Blocklist.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/Ransomware-Domain-Blocklist.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/TeslaCrypt-Ransomware-C2-Domain-Blocklist.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/TeslaCrypt-Ransomware-C2-Domain-Blocklist.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/TeslaCrypt-Ransomware-Payment-Sites-Domain-Blocklist.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/TeslaCrypt-Ransomware-Payment-Sites-Domain-Blocklist.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/TorrentLocker-Ransomware-C2-Domain-Blocklist.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/TorrentLocker-Ransomware-C2-Domain-Blocklist.txt</a><br><a href="https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/TorrentLocker-Ransomware-Payment-Sites-Domain-Blocklist.txt">https://raw.githubusercontent.com/deathbybandaid/piholeparser/master/Subscribable-Lists/ParsedBlacklists/TorrentLocker-Ransomware-Payment-Sites-Domain-Blocklist.txt</a></pre><pre># Prevent Phishing<br><a href="https://gitlab.com/Kurobeats/phishing_hosts/raw/master/hosts">https://gitlab.com/Kurobeats/phishing_hosts/raw/master/hosts</a><br><a href="https://raw.githubusercontent.com/MetaMask/eth-phishing-detect/master/src/hosts.txt">https://raw.githubusercontent.com/MetaMask/eth-phishing-detect/master/src/hosts.txt</a></pre><h3>IV. Dynamic DNS naming</h3><p>For fun and to challenge myself, I wanted to understand how to block Youtube ads on my AmazonFireTV. Youtube streaming service is using “<em>.googlevideo.com” </em>as the main domain name for videos as well as for ads.</p><p>Many have been trying and for quite sometime to recognise the pattern used by Youtube to inject Advertisement, (check this <a href="https://discourse.pi-hole.net/t/how-do-i-block-ads-on-youtube/253">Discourse pihole thread </a>started in 2016) and here is little documentation on <strong><em>How to do</em></strong> this.</p><p><strong>Update</strong>: Youtube Ads are no longer blocked by this method, Youtube integrates their ads within the same stream of data (which means blocking ads with DNS naming is no longer working. There’s perhaps another solution using a proxy for all of your HTTPS traffic that would be decrypt your secure traffic on the flight and denied ads traffic. It does require root access to phone / apps. Some solutions out there are avaible but you end up sending all your sensitive traffic to <em>who knows where</em>. At the end, I just use webapps (different from mobile app) on my phone where I keep control of my data and can deny Ads Traffic ;)</p><ol><li><strong>Add Python3 and pip on your pihole device</strong></li></ol><p>Install them this way:</p><pre>$ sudo apt-get install python3.7 python3-pip</pre><p>Link python3 to your user environment:</p><pre>$ sudo ln -s /usr/bin/pip3 /usr/local/bin/pip<br>$ sudo ln -s /usr/bin/python3.7 /usr/local/bin/python</pre><p>Verify:</p><pre>$ python --version<br>Python 3.7.3<br>$ pip --version<br>pip 18.1 from /usr/lib/python3/dist-packages/pip (python 3.7)</pre><p><strong>2. Make use of Sublist3r script:</strong></p><p>Create a folder for hosting this <a href="https://github.com/aboul3la/Sublist3r/">Github repo</a>(Instructions are also present there):</p><pre>$ sudo mkdir /etc/sublist/</pre><p>Download and unzip this project:</p><pre>$ cd /etc/sublist/<br>$ sudo wget <a href="https://github.com/aboul3la/Sublist3r/archive/master.zip">https://github.com/aboul3la/Sublist3r/archive/master.zip</a><br>[...]</pre><pre>$ sudo unzip -o master.zip</pre><p>This script will help us to retrieve dynamic subdomains created and generated by youtube (googlevideo in this case). I used to get these subdomain by using DNSDumpster but that was limited to only 100 domains (thank you to my readers for pointing that out). With this method, you should get routhly around 700+ subdomains.</p><p><strong>3. Final script to implement the magic:</strong></p><p>Sublist3r would also require some packages to be installed alongside, (instructions are also on Github), install them as follow</p><pre>root@raspberrypi:~# apt-get install python-argparse python3-dns python3-requests</pre><p>You should be able to test this script this way:</p><pre>root@raspberrypi:/etc/sublist# python /etc/sublist/Sublist3r-master/sublist3r.py -h<br>usage: sublist3r.py [-h] -d DOMAIN [-b [BRUTEFORCE]] [-p PORTS] [-v [VERBOSE]]<br>                    [-t THREADS] [-e ENGINES] [-o OUTPUT] [-n]</pre><pre>OPTIONS:<br>  -h, --help            show this help message and exit<br>  -d DOMAIN, --domain DOMAIN<br>                        Domain name to enumerate it&#39;s subdomains<br>  -b [BRUTEFORCE], --bruteforce [BRUTEFORCE]<br>                        Enable the subbrute bruteforce module<br>  -p PORTS, --ports PORTS<br>                        Scan the found subdomains against specified tcp ports<br>  -v [VERBOSE], --verbose [VERBOSE]<br>                        Enable Verbosity and display results in realtime<br>  -t THREADS, --threads THREADS<br>                        Number of threads to use for subbrute bruteforce<br>  -e ENGINES, --engines ENGINES<br>                        Specify a comma-separated list of search engines<br>  -o OUTPUT, --output OUTPUT<br>                        Save the results to text file<br>  -n, --no-color        Output without color</pre><pre>Example: python /etc/sublist/Sublist3r-master/sublist3r.py -d google.com</pre><p>Now, I’m using this script for filtering the desired traffic and adding this to my blacklist file in Pihole (script path: <em>/etc/pihole/youtube-ads.sh</em>):</p><pre>#!/usr/bin/env bash</pre><pre># Cleanup previous list of domains files<br>rm /var/log/sublist-youtube-result.txt</pre><pre># Retrieve all .googlevideo.com subdomains<br>python /etc/sublist/Sublist3r-master/sublist3r.py -d googlevideo.com -n -o /var/log/sublist-youtube-result.txt</pre><pre># Any .googlevideo.com subdomains starting with &#39;r&#39; would be filtered in a file<br>grep ^r /var/log/sublist-youtube-result.txt &gt;&gt; /var/log/sublist-youtube-filtered.txt</pre><pre># Any .googlevideo.com subdomains containing &#39;s&#39; from the previous filtered list will be filtered in a file<br>sed &#39;s/\s.*$//&#39; /var/log/sublist-youtube-filtered.txt &gt;&gt; /var/log/sublist-youtube-ads.txt</pre><pre># Place findings in Pihole blacklist text file<br>cat /var/log/sublist-youtube-ads.txt &gt; /etc/pihole/blacklist.txt</pre><pre># Get unique values<br>perl -i -ne &#39;print if ! $x{$_}++&#39; /etc/pihole/blacklist.txt</pre><pre># Get unique values<br>chown -R pihole. /etc/pihole</pre><pre># Pipe findings into pihole db<br>cat /etc/pihole/blacklist.txt | xargs pihole -b</pre><p>This script is divided in several parts:</p><ul><li>Retrieve subdomains from Sublist3r</li><li>Filter them, place findings in blacklist file and curate the results.</li><li>Use a xargs pipe to populate pihole db based on finding</li></ul><p>I’m running this twice a hour with a cronjob (don’t forget to make this script <strong>executable</strong> with <em>chmod</em>):</p><pre>root@raspberrypi:/home/pi# crontab -l<br>*/30 * * * * /etc/pihole/youtube-ads.sh</pre><p>This configuration has been running for a while and I do have some time some ads on my FireTV or Youtube App on my phone. Overtime, the cronjob would collect subdomains and add them to your pihole file, which would limit the number of ads you’d be expose to.</p><p>Feel free to contact me if you want to share your ideas.</p><h3>V. Regex blacklisting</h3><p>Final part of this publication, you can also leverage the use of implementing a list of regex matching the domain names that you wish to deny.</p><p>I <em>used</em> to make use of that in the past with previous versions of Pihole, somehow, <strong>blacklisted domains</strong> redirected to a <strong>whitelisted CNAME</strong> were actually bypassing Pihole. I’m not having anymore this issue in Pihole <strong>version 5.1</strong>:</p><pre>root@raspberrypi:/home/pi# pihole -v<br>  Pi-hole version is v5.1.1 (Latest: v5.1.1)<br>  AdminLTE version is v5.1 (Latest: v5.1)<br>  FTL version is v5.1 (Latest: v5.1)</pre><p>Previously, the only way for blocking this traffic was actually the use of Regex, by simply a list of pattern in this <em>/etc/pihole/regex.list </em>file. Here is an example:</p><pre>root@raspberrypi:/home/pi# cat /etc/pihole/regex.list<br>^(.+[-_.])??adse?rv(er?|ice)?s?[0-9]*[-.]<br>^(.+[-_.])??m?ad[sxv]?[0-9]*[-_.]<br>^(.+[-_.])??telemetry[-.]<br>^(.+[-_.])??xn--<br>^adim(age|g)s?[0-9]*[-_.]<br>^adtrack(er|ing)?[0-9]*[-.]<br>^advert(s|is(ing|ements?))?[0-9]*[-_.]<br>^aff(iliat(es?|ion))?[-.]<br>^analytics?[-.]<br>^banners?[-.]<br>^beacons?[0-9]*[-.]<br>^count(ers?)?[0-9]*[-.]<br>^pixels?[-.]<br>^stat(s|istics)?[0-9]*[-.]<br>^track(ers?|ing)?[0-9]*[-.]<br>^traff(ic)?[-.]<br>google-{0,}(analytic|syndication|(ad[a-z0-9]*|tag)-{0,}service)[s]\.[a-z]{2,7}$<br>google-{0,}(analytics{0,}|(ad|tag)manager)\.[a-z]{2,7}$<br>double-{0,}clic(k|k[.]*by-{0,}google)\.[a-z]{2,7}$<br>(google|partner|pub)-{0,}ads{0,}-{0,}(apis{0,})\.[a-z]{2,7}$<br>(^|\.)facebook\.[A-Za-z0-9]+$<br>(^|\.)fb\.[A-Za-z0-9]+$<br>(^|\.)fbcdn\.[A-Za-z0-9]+$<br>(^|\.)fbsbx\.com$<br>(^|\.)fbsbx\.com\.online-metrix\.net$<br>(^|\.)m\.me$<br>(^|\.)messenger\.com$<br>(^|\.)tfbnw\.net$<br>(^|\.)instagram\.com$<br>(^|\.)whatsapp\.com$<br>^(.+\.)?amp\..+\.com$<br>^(.+\.)?ampproject\.org$<br>^(.+\.)?amp\.cloudflare\.com$<br>^(.+\.)?cdn\.ampproject\.org$<br>(.*\.|^)((think)?with)?google($|((adservices|apis|mail|static|syndication|tagmanager|tagservices|usercontent|zip|-analytics)($|\..+)))<br>([A-Za-z0-9.-]*\.)?clicks\.beap\.bc\.yahoo\.com/<br>([A-Za-z0-9.-]*\.)?secure\.footprint\.net/<br>([A-Za-z0-9.-]*\.)?match\.com/<br>([A-Za-z0-9.-]*\.)?clicks\.beap\.bc\.yahoo(\.\w{2}\.\w{2}|\.\w{2 ,4})/<br>([A-Za-z0-9.-]*\.)?sitescout(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?appnexus(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?evidon(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?mediamath(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?scorecardresearch(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?doubleclick(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?flashtalking(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?turn(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?mathtag(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?googlesyndication(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?s\.yimg\.com/cv/ae/us/audience/<br>([A-Za-z0-9.-]*\.)?clicks\.beap/<br>([A-Za-z0-9.-]*\.)?.doubleclick(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?yieldmanager(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?w55c(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?adnxs(\.\w{2}\.\w{2}|\.\w{2,4})/<br>([A-Za-z0-9.-]*\.)?advertising\.com/<br>([A-Za-z0-9.-]*\.)?evidon\.com/<br>([A-Za-z0-9.-]*\.)?scorecardresearch\.com/<br>([A-Za-z0-9.-]*\.)?flashtalking\.com/<br>([A-Za-z0-9.-]*\.)?turn\.com/<br>([A-Za-z0-9.-]*\.)?mathtag\.com/<br>([A-Za-z0-9.-]*\.)?surveylink/<br>([A-Za-z0-9.-]*\.)?info\.yahoo\.com/<br>([A-Za-z0-9.-]*\.)?ads\.yahoo\.com/<br>([A-Za-z0-9.-]*\.)?global\.ard\.yahoo\.com/<br>(^|\.)lgsmartad\.com$<br>ngfts.lge.com<br>lgtvonline.lge.com<br>(^|\.)buffpanel\.com$<br>(^|\.)bugsnag\.com$<br>(^|\.)redshell\.io$<br>(^|\.)treasuredata\.com$<br>(^|\.)unity(|3d)\.com$<br>(^|\.)unityads(|\.co)\.com$</pre><h3>VI. What next?</h3><p>I will keep this publication up to date with the latest. Things keep moving fast, especially the new implementations such as <a href="https://en.wikipedia.org/wiki/DNS_over_HTTPS">DNS over HTTPS</a> and I wonder how Pihole would involve and adapt with this technology.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e795342e0e36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Serverless easy ride]]></title>
            <link>https://obutterbach.medium.com/serverless-easy-ride-dff35c64cfe?source=rss-d4a06db01174------2</link>
            <guid isPermaLink="false">https://medium.com/p/dff35c64cfe</guid>
            <category><![CDATA[api-gateway]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Olivier Butterbach]]></dc:creator>
            <pubDate>Wed, 08 Jan 2020 21:37:53 GMT</pubDate>
            <atom:updated>2020-04-09T07:54:02.811Z</atom:updated>
            <content:encoded><![CDATA[<h3>Overview on deploying Serverless services</h3><p>It’s hard to believe that Lambda function have already been around only for the last 5 years (at the time of writing this), and it became so popular so quickly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/768/1*pjIIpzt3smpDQR-Fk31ndg.png" /></figure><p>I’ve been working as a DevOps engineer for the last 8 years or so (working on AWS for the last 7 years), and I wanted to review some of the tools I came accross for deploying serverless solutions on AWS.</p><h3>I. First wave: bash script</h3><p>It works! And it still does, although it’s not very scalable, it’s mainly (as I still does today) for installing dependencies, testing and packaging them into zip.</p><p>One example of bash script code I keep re-using is this one:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b07bd89cd9365b494d859713730bd4c8/href">https://medium.com/media/b07bd89cd9365b494d859713730bd4c8/href</a></iframe><p>This is working quite well for the first part (Continuous Integration) but doesn’t fit the second part (Continuous Delivery). Back in these days, I started using CloudFormation for CD requirements, let’s see an example.</p><h3>II. Cloudformation Era</h3><p>Around 2016, a Cloudformation allowed the use of Yaml format for declaring AWS resources, that was a massive change specially for the sake of my eyes</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c398bcddab646a0c46f6ebce6868e672/href">https://medium.com/media/c398bcddab646a0c46f6ebce6868e672/href</a></iframe><p>From this to this:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/68fb5a6b8de8bd9b0a436949f9062a19/href">https://medium.com/media/68fb5a6b8de8bd9b0a436949f9062a19/href</a></iframe><p>Declaring AWS Lambda functions for Operational purposes, Cloudformation was indeed <em>doing</em> the job. Unfortunately, it can become rather complexe if you start adding API Gateway / SNS Topics and so on to the equations:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/f388bc6ce712ae5ead403751360ddd63/href">https://medium.com/media/f388bc6ce712ae5ead403751360ddd63/href</a></iframe><p>This is a truncated example of an API Gateway declaration in Cloudformation format. Let’s see Terraform way</p><h3>III. Does Terraform make it better?</h3><p>Depending who you ask, I believe it <em>slightly</em> does but not that much:</p><p><a href="https://www.terraform.io/docs/providers/aws/r/api_gateway_integration.html">AWS: aws_api_gateway_integration - Terraform by HashiCorp</a></p><p>Based on my experience, I had trouble deploying AWS Lambda functions with Terraform, especially around <strong><em>Stages</em></strong> and <strong><em>Testings</em></strong> which would see later. Terraform seems to have issues picking up the latest zip file containing the source code (even when build locally), I had to ran it twice</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/4fa48549b4c8a615f3c83a58dcc5a670/href">https://medium.com/media/4fa48549b4c8a615f3c83a58dcc5a670/href</a></iframe><h3>IV. AWS SAM</h3><p>Around 2018, AWS introduced AWS Serverless Application Model to answer the needs for managing Serverless deployments and the management of them. SAM is simply an extension of CloudFormation, is also using Yaml format and the installation process is as simple as AWS CLI one:</p><pre>pip install aws-sam-cli</pre><p>SAM CLI is then available as sam. Once completed, let’s crack on the first step: Package</p><pre>sam package \<br>  --template-file template.yml \<br>  --output-template-file package.yml \<br>  --s3-bucket my-bucket</pre><p>This command is to upload any artifacts to an AWS S3 bucket, generate a package AWS SAM template file that’s ready to be used.</p><pre>AWSTemplateFormatVersion: &#39;2010-09-09&#39;<br>Transform: AWS::Serverless-2016-10-31<br>Description: &gt;<br>  sam-app</pre><pre>Sample SAM Template for sam-app</pre><pre>Globals:<br>  Function:<br>    Timeout: 3</pre><pre>Resources:<br>  HelloWorldFunction:<br>    Type: AWS::Serverless::Function<br>    Properties:<br>      CodeUri: hello_world/<br>      Handler: app.lambda_handler<br>      Runtime: python3.7<br>      Events:<br>        HelloWorld:<br>          Type: Api<br>          Properties:<br>            Path: /hello<br>            Method: get</pre><pre>Outputs:<br>  HelloWorldApi:<br>    Description: &quot;API Gateway endpoint URL for Prod stage for Hello World function&quot;<br>    Value: !Sub &quot;<a href="https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/">https://${ServerlessRestApi}.execute-api.${AWS::Region}.amazonaws.com/Prod/hello/</a>&quot;<br>  HelloWorldFunction:<br>    Description: &quot;Hello World Lambda Function ARN&quot;<br>    Value: !GetAtt HelloWorldFunction.Arn<br>  HelloWorldFunctionIamRole:<br>    Description: &quot;Implicit IAM Role created for Hello World function&quot;<br>    Value: !GetAtt HelloWorldFunctionRole.Arn</pre><p>Here is a template example of an hello world application deploy with AWS SAM, the syntax is a mixed between Cloudformation template and addons AWS SAM, I personally found this confusing.Once your package is ready with the package command, you can deploy by using the following command:</p><pre>sam deploy \<br>  --template-file ./packaged.yaml <br>  --stack-name mystack <br>  --capabilities CAPABILITY_IAM</pre><p>AWS SAM is helping solving the previous mentionned issues with Cloudformation and Terraform, this tool helps for building scaffolding for Lambda / API Gateway / SNS and so on, it also helps for performing integration testings locally before pushing your code to production. After using AWS SAM, I also discovered that this tool would inherited problems from Cloudformation such as modifying records in Route53. If you compare AWS SAM with Serverless (which we will see next), you will quickly switch to Serverless as I did.</p><h3>V. Serverless Framework</h3><p>Serverless framework managed to solve most of these issues:</p><ul><li>Readable</li><li>Cloud agnostic</li><li>Speed of deployment</li><li><a href="https://serverless.com/learn/comparisons/">And so on…</a></li></ul><p>Installing this tool require Node.js installed, simply install that tool that way:</p><pre>npm install -g serverless</pre><p>Packing and deploying by only using a single command line:</p><pre>sls deploy</pre><p>After using this tool extensively, I’m no longer having issue managing API Gateway / SNS / Lambda and link them <em>automagically</em> together, deploying is really easy and fast.</p><h3>VI. My take on this</h3><p>My main recommendation would be to jump straight to Serverless framework and avoid investing too much of your time on Cloudformation / Terraform for deploying a whole set of serverless services together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dff35c64cfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS Guardduty to Slack]]></title>
            <link>https://obutterbach.medium.com/aws-guardduty-to-slack-6419e758aa8f?source=rss-d4a06db01174------2</link>
            <guid isPermaLink="false">https://medium.com/p/6419e758aa8f</guid>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[guard-duty]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Olivier Butterbach]]></dc:creator>
            <pubDate>Tue, 07 Jan 2020 20:38:37 GMT</pubDate>
            <atom:updated>2021-08-14T00:10:32.765Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a quick guide to send AWS Guardduty notifications to your Slack Channel. In this example, we will link a main AWS Account with its members by using Terraform.</p><p>I also keep my blog updated with new articles with my consulting company, you can check at <a href="https://cdcloudlogix.com/blog">https://cdcloudlogix.com/blog</a> for more information :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/501/1*GilDE0rkfbiPrZBVgHaazA.png" /><figcaption>AWS Account Data flow</figcaption></figure><p>AWS Guardduty is a threat detection service provided by AWS, cost effective and easily implemented. The following guide is using terraform files which are stored in the following <a href="https://github.com/cdcloudlogix/AWS_Guardduty_Slack_integration">GitHub</a> repository.</p><h3>I. First off</h3><p>By using Terraform 12, start by declaring all your AWS Accounts and their aliases into a specific file (<em>aws.tf</em> in this case):</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/dd1f621a93c979048b2b718a226652ac/href">https://medium.com/media/dd1f621a93c979048b2b718a226652ac/href</a></iframe><p>Once completed, add your backend:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3ef74bab26e8009eadbbe3d7963f787d/href">https://medium.com/media/3ef74bab26e8009eadbbe3d7963f787d/href</a></iframe><p>The acl <em>bucket-owner-full-control</em> allow the main AWS account to keep control over the state file, especially when you assume multiple profile, you can be quite handy.</p><h3>II. Modules</h3><p>This project is using multiples modules as follow:</p><ul><li>AWS Guardduty Master</li><li>AWS Guardduty Members</li><li>AWS Guardduty Invitations</li><li>AWS Guardduty Slack notifications</li></ul><h3>III. Lambda function</h3><p>This project is using a bash script for installing / testing and packaging the lambda function:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b07bd89cd9365b494d859713730bd4c8/href">https://medium.com/media/b07bd89cd9365b494d859713730bd4c8/href</a></iframe><p>Before applying Terraform plan, the zip file would have to be present on the local file system.</p><p>Prepare a virtual environment for python before running this on your terminal:</p><pre>$ virtualenv -p python3 venv<br>Running virtualenv with interpreter /usr/local/bin/python3<br>Using base prefix &#39;/usr/local/Cellar/python/3.7.5/Frameworks/Python.framework/Versions/3.7&#39;<br>New python executable in /Users/oli/Documents/venv/bin/python3.7<br>Also creating executable in /Users/oli/Documents/venv/bin/python<br>Installing setuptools, pip, wheel...<br>done.</pre><pre>$ source venv/bin/activate</pre><h3>IV. Slack configuration</h3><figure><img alt="Create a new App" src="https://cdn-images-1.medium.com/max/1024/1*SSC_ccYdGOBKT_s2pj6H-A.png" /></figure><p>Slack has now shifted to <a href="https://api.slack.com/">Slack API</a> for creating and installing your applications, it’s really easy to get started</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-tRO-cujOnqJvcOWOrZxQw.png" /><figcaption>Enable Incoming Webhooks</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*o8tStFV-8vbxZCkB37MRlA.png" /><figcaption>Once you select your channel, you’ll receive this message</figcaption></figure><h3>V. SSM parameters</h3><p>This system is using SSM parameters to fetch the 3 following variables:</p><ul><li>Slack Channel</li><li>Slack Incoming webhook</li><li>Email address used by the root account</li></ul><p>Just create these three variables in the main account:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HfXRjg3l4iIEmRDLdPLtKQ.png" /><figcaption>AWS System Manager</figcaption></figure><h3>VI. Deploy!</h3><p>Package your lambda script first:</p><pre>21:50 $ ./python_packages.sh<br>Collecting pylint<br>  Downloading pylint-2.4.4-py3-none-any.whl (302 kB)<br>     |████████████████████████████████| 302 kB 1.4 MB/s<br>Collecting mccabe&lt;0.7,&gt;=0.6<br>  Using cached mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)<br>Collecting astroid&lt;2.4,&gt;=2.3.0<br>  Downloading astroid-2.3.3-py3-none-any.whl (205 kB)<br>     |████████████████████████████████| 205 kB 1.9 MB/s<br>Collecting isort&lt;5,&gt;=4.2.5<br>  Using cached isort-4.3.21-py2.py3-none-any.whl (42 kB)<br>Processing /Users/oli/Library/Caches/pip/wheels/d7/de/2e/efa132238792efb6459a96e85916ef8597fcb3d2ae51590dfd/wrapt-1.11.2-cp37-cp37m-macosx_10_14_x86_64.whl<br>Collecting six~=1.12<br>  Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)<br>Collecting typed-ast&lt;1.5,&gt;=1.4.0; implementation_name == &quot;cpython&quot; and python_version &lt; &quot;3.8&quot;<br>  Downloading typed_ast-1.4.1-cp37-cp37m-macosx_10_9_x86_64.whl (223 kB)<br>     |████████████████████████████████| 223 kB 9.4 MB/s<br>Collecting lazy-object-proxy==1.4.*<br>  Using cached lazy_object_proxy-1.4.3-cp37-cp37m-macosx_10_13_x86_64.whl (19 kB)<br>Installing collected packages: mccabe, wrapt, six, typed-ast, lazy-object-proxy, astroid, isort, pylint<br>Successfully installed astroid-2.3.3 isort-4.3.21 lazy-object-proxy-1.4.3 mccabe-0.6.1 pylint-2.4.4 six-1.14.0 typed-ast-1.4.1 wrapt-1.11.2<br>~/Documents/AWS_Guardduty_Slack_integration/modules/sns-guardduty-slack ~/Documents/AWS_Guardduty_Slack_integration/modules</pre><pre>------------------------------------<br>Your code has been rated at 10.00/10</pre><pre>~/Documents/AWS_Guardduty_Slack_integration/modules<br>~/Documents/AWS_Guardduty_Slack_integration/modules/sns-guardduty-slack ~/Documents/AWS_Guardduty_Slack_integration/modules<br>  adding: sns_guardduty_slack.py (deflated 68%)<br>~/Documents/AWS_Guardduty_Slack_integration/modules</pre><p>Then, run terraform init command:</p><pre>17:17 $ terraform init<br>Initializing modules...<br>- aws_guardduty_invite_member in modules/guardduty-invitation<br>- aws_guardduty_master in modules/guardduty-master<br>- aws_guardduty_member in modules/guardduty-member<br>- aws_guardduty_sns_notifications in modules/sns-guardduty-slack</pre><pre>Initializing the backend...</pre><pre>Successfully configured the backend &quot;s3&quot;! Terraform will automatically<br>use this backend unless the backend configuration changes.</pre><pre>Initializing provider plugins...<br>- Checking for available provider plugins...<br>- Downloading plugin for provider &quot;aws&quot; (hashicorp/aws) 2.55.0...</pre><pre>Terraform has been successfully initialized!</pre><pre>You may now begin working with Terraform. Try running &quot;terraform plan&quot; to see<br>any changes that are required for your infrastructure. All Terraform commands<br>should now work.</pre><pre>If you ever set or change modules or backend configuration for Terraform,<br>rerun this command to reinitialize your working directory. If you forget, other<br>commands will detect it and remind you to do so if necessary.</pre><p>Finally, apply the changes with Terraform:</p><pre>17:39 $ terraform apply<br>module.aws_guardduty_sns_notifications.data.aws_ssm_parameter.slack_incoming_webhook: Refreshing state...<br>module.aws_guardduty_invite_member.data.aws_ssm_parameter.email: Refreshing state...<br>module.aws_guardduty_sns_notifications.data.aws_ssm_parameter.slack_channel: Refreshing state...</pre><pre>An execution plan has been generated and is shown below.<br>Resource actions are indicated with the following symbols:<br>  + create<br> &lt;= read (data resources)</pre><pre>Terraform will perform the following actions:</pre><pre># module.aws_guardduty_invite_member.aws_guardduty_member.members will be created<br>  + resource &quot;aws_guardduty_member&quot; &quot;members&quot; {<br>      + account_id          = &quot;123456789012&quot;<br>      + detector_id         = (known after apply)<br>      + email               = &quot;<a href="/service/mailto:whatever@example.com">whatever@example.com</a>&quot;<br>      + id                  = (known after apply)<br>      + invitation_message  = &quot;please accept guardduty invitation&quot;<br>      + invite              = true<br>      + relationship_status = (known after apply)<br>    }</pre><pre># module.aws_guardduty_master.aws_cloudwatch_event_rule.main will be created<br>  + resource &quot;aws_cloudwatch_event_rule&quot; &quot;main&quot; {<br>      + arn           = (known after apply)<br>      + description   = &quot;AWS GuardDuty event findings&quot;<br>      + event_pattern = jsonencode(<br>            {<br>              + detail      = {<br>                  + severity = [<br>                      + 3,<br>                      + 3,<br>                      + 3.1,<br>                      + 3.2,<br>                      + 3.3,<br>                      + 3.4,<br>                      + 3.5,<br>                      + 3.6,<br>                      + 3.7,<br>                      + 3.8,<br>                      + 3.9,<br>                      + 4,<br>                      + 4,<br>                      + 4.1,<br>                      + 4.2,<br>                      + 4.3,<br>                      + 4.4,<br>                      + 4.5,<br>                      + 4.6,<br>[..]</pre><p>This code 👆is a truncated output when you use the apply command, just confirm by typing “yes” if you’re happy with what you see.</p><pre>Apply complete! Resources: 0 added, 16 changed, 0 destroyed.</pre><p>Congratulation 🎉 a state file should be present in your bucket following this stage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BEfNZrqxiyv_n5WbxZ7WGg.png" /><figcaption>Terraform state file appears after applying the plan</figcaption></figure><h3>VII. Testing your deployment</h3><p>After logging to AWS Console, search for Guardduty tabs and go into settings. You can generate sample event from this window by clicking on “Generate sample finding” as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R7qobbrhx36MD8cs0BJyiA.png" /><figcaption>Generate finding for testing your deployment</figcaption></figure><p>Once triggered, you should start to see some messages appearing in Slack as follow:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1NTyaXTMBgqHRnCTPlRgOQ.png" /></figure><p><a href="https://github.com/cdcloudlogix/AWS_Guardduty_Slack_integration">cdcloudlogix/AWS_Guardduty_Slack_integration</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6419e758aa8f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>