<?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 Tales Brondani on Medium]]></title>
        <description><![CDATA[Stories by Tales Brondani on Medium]]></description>
        <link>https://medium.com/@talesbrondani?source=rss-de43ab71f0db------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*74_hcv3ERwFTcr3-xPQbSg.jpeg</url>
            <title>Stories by Tales Brondani on Medium</title>
            <link>https://medium.com/@talesbrondani?source=rss-de43ab71f0db------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 03:35:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@talesbrondani/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[Cloud Security Quick Wins for your AWS Environment — PART 2 — AWS Organizations and SCPS]]></title>
            <link>https://medium.com/@talesbrondani/cloud-security-quick-wins-for-your-aws-environment-part-2-aws-organizations-and-scps-9f9fba8946e8?source=rss-de43ab71f0db------2</link>
            <guid isPermaLink="false">https://medium.com/p/9f9fba8946e8</guid>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[aws-scp]]></category>
            <category><![CDATA[aws-organizations]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-security]]></category>
            <dc:creator><![CDATA[Tales Brondani]]></dc:creator>
            <pubDate>Mon, 16 Sep 2024 13:17:45 GMT</pubDate>
            <atom:updated>2024-10-07T14:36:26.059Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cloud Security Quick Wins for your AWS Environment — PART 2 — AWS Organizations and SCPs</h3><p>Tech is hard, security is hard, living is hard.</p><p>In this second part, we’ll focus on how AWS Organizations and SCPs can <em>secure</em> even more your AWS Cloud.</p><p>Before starting, if you haven&#39;t already, check it out the first article of this series.</p><p><a href="https://medium.com/@tales.brondani/cloud-security-quick-wins-for-your-aws-environment-part-1-62e5025978ba">Cloud Security Quick Wins for your AWS Environment — PART 1</a></p><p>Today we have a lot to cover and go through, from AWS concepts to spooky stories, scary monsters and nice policies.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/474/1*hiLFkGhfxUiGHVTjz0jb9A.png" /><figcaption><a href="https://imgflip.com/memegenerator">https://imgflip.com/memegenerator</a></figcaption></figure><p>Disclaimer: AWS Organizations<strong><em> is not a silver bullet</em></strong> for cloud security, probably there isn’t one. A solid strategy is to always layer your security measures on top of each other, if this is alien to you here’s a starting point (<strong><em> </em></strong><a href="https://csrc.nist.gov/glossary/term/defense_in_depth">https://csrc.nist.gov/glossary/term/defense_in_depth</a>)</p><h3>Getting started with AWS Organizations</h3><p>To begin with, let’s create a fresh org for you, it’s free of charge and can take your AWS game to another level if you set it up properly.</p><p>Navigate through the console to the AWS Organizations landing page and click on the button “<strong><em>Create an Organization</em></strong>”.</p><p>Access the page or AWS Organizations Service and click on “Create an organization”, it’s very quick and easy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*A_eG2uXahhD19SBqoYfofQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/729/1*4oa9o8BzLSxGtnv2ssEWqA.png" /></figure><p>Before diving into the AWS Organizations and Service Control Policies, or <strong>AWSO</strong> and <strong>SCPs </strong>respectively as we’ll refer to them from now on, let’s do a quick overview on concepts for a better overall comprehension throughout the article.</p><h4>AWS Organizations — a Quick Overview</h4><p>AWSO centralizes management via a management account, everything begins in the Root OU (initially created with your org), which can <em>contain</em> all the subsequent OUs and accounts that were invited or created by us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mVwvrTJ6goOqRDHe8dfI9Q.png" /><figcaption><a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html">https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html</a></figcaption></figure><p>All the subsequent OUs and accounts that were invited or created by us are inside the root OU.</p><p>You can nest OUs and accounts inside the ROOT OUs, remember that the more OUs you add the more complexity you add.</p><p>If you would like to know more, there are 2 great study material below also refer to the official documentation.</p><h4>AWS Organizations — Deep Dives</h4><p>For those who want to dive deeper into these topics, I highly recommend two AWS re:Invent 2019 presentations, one by Sam Hennesy and other from Sam Elmalak.</p><p>Watch and take notes, as it is a masterclass on the topics such as breaking glass, landing zones, SCPs and almost everything in between.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2F_PrFgbuEqLA%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3D_PrFgbuEqLA&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2F_PrFgbuEqLA%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/fa61dd102f36006ccdebfa2798a948ff/href">https://medium.com/media/fa61dd102f36006ccdebfa2798a948ff/href</a></iframe><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FzVJnenaD3U8%3Ffeature%3Doembed&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DzVJnenaD3U8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FzVJnenaD3U8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/3d8086e6b358aa0bfa9f75402f33432f/href">https://medium.com/media/3d8086e6b358aa0bfa9f75402f33432f/href</a></iframe><p><strong>To grossly wrap-up:</strong> the idea is that you want to separate environments and create <strong>isolation, </strong>and defining general rules(OUs) and also specific rules for each environment(accounts)<strong> </strong>accounts and OUs.</p><p>For instance, you may want your backup policies to differ between development and production — for example, 45 days in production and 5 days in development — to ensure you can <em>protect</em> critical data in production for a longer period.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1005/1*-d73mRMRPNqCd8EWegDr4A.png" /><figcaption><a href="https://d1.awsstatic.com/events/reinvent/2019/REPEAT_2_Architecting_security_&amp;_governance_across_your_landing_zone_SEC325-R2.pdf">https://d1.awsstatic.com/events/reinvent/2019/REPEAT_2_Architecting_security_&amp;_governance_across_your_landing_zone_SEC325-R2.pdf</a> — Page 21.</figcaption></figure><p>Keep in mind that it’s not mandatory that you have those accounts, if your environment is a small workload why should you add unnecessary complexity? Remember to <a href="https://en.wikipedia.org/wiki/KISS_principle"><strong><em>keep it simple</em></strong></a>!</p><p>Also watch out for AWSO limits, the main ones are listed below for convenience:</p><ul><li>Number of AWS accounts in an organization : Default 10 — Max 10000</li><li>OU maximum nesting in a root — Five levels of OUs deep under a root.</li><li>Number of member accounts you can create concurrently — Default 5</li><li>Maximum size of the resource-based delegation policy — 40000 characters long.</li><li>Maximum size of a policy document<br>AI services opt-out policies: 2500 characters<br>Backup policies: 10,000 characters<br>Service control policies: 5120 characters<br>Tag policies: 10,000 characters</li></ul><p>If you want to further understand the soft and hard limits of the service, check <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_reference_limits.html">this</a> out.</p><p>For now we will focus on the main topic of the article, Service Control Policies or as we may refer them from now on, SCPs.</p><h4>Service Control Policies(SCP) in AWS Organizations</h4><p>As of today, the definition of a SCP according to the official documentation is:</p><blockquote>Service control policies (SCPs) are a type of organization policy that you can use to manage permissions in your organization. SCPs offer central control over the maximum available permissions for all accounts in your organization.(<a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html">ref</a>)</blockquote><p>AWSO gives you a wide range of new configurations you can implement much more easily, below is what you typically find after enabling your org in the Policies section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/703/1*2U39Ij0ZgY3U2B7iR5MDCg.png" /></figure><p>Usually this is the first SCP that will be available to you.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*4WvWywHdFfrU03ePvntW5w.png" /></figure><p>Enables you to control which AWS service APIs are accessible:</p><p>- Define the list of APIs that are allowed<br>- Define the list of APIs that must be blocked</p><p>SCPs are:</p><p>- Invisible to all users in the child account<br>- Applied to all users in the child account</p><p>Permission:<br>- Intersection between the SCP and IAM Permissions<br>- IAM policy simulator is SCP aware.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/387/0*4a7Pgwd-DHC70EJA.png" /><figcaption><a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html">https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html</a></figcaption></figure><h3>Scary Stories and SCPs suggestions from a Cloud Security perspective</h3><p>Now let’s jump right into the SCPs and how can you implement these as security measures for not only security purposes, but also for <strong><em>cost reasons, </em></strong>which is a form of security measure in the long run, keeping your costs at bay is one sure way to stay in business.</p><p>Let’s imagine a scenario where you are using AWS for about a year or so, you’ve deployed your apps using EC2 instances and RDS, using S3 for storing important files, have a team of 5 people in total interacting with your account.</p><p>It’s the holidays, some people are on vacation, some are travelling and no one is paying attention to the emails, one of your keys was inadvertently been posted online and in the next month you’ve got <em>nasty surprise, </em>as your AWS bill is now exploding, you discover someone hard coded <a href="https://docs.aws.amazon.com/STS/latest/APIReference/API_GetAccessKeyInfo.html#:~:text=Access%20keys%20consist%20of%20two%20parts%3A%20an%20access%20key%20ID%20(for%20example%2C%20AKIAIOSFODNN7EXAMPLE)%20and%20a%20secret%20access%20key%20(for%20example%2C%20wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY).%20For%20more%20information%20about%20access%20keys%2C%20see%20Managing%20Access%20Keys%20for%20IAM%20Users%20in%20the%20IAM%20User%20Guide.">AKIA keys</a> (long-term usage keys) with permission to launch EC2, RDS and S3 in any region without restriction.</p><p>This key was uploaded to a public Git system, allowing bad actors to spin up cryptominer instances(EC2 or any compute service) in Asia, Europe or any other region that is not your main region.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*l2Xt-ADWQaGnrVv6F1ASlw.png" /></figure><p>From a general security perspective, the situation presents <strong>several </strong>problems in process, technology, people, but besides the why,who or when, the blast radius is <em>ginormous </em>and we will try our best to mitigate the problem by implementing SCPs to aid us and protect us from ourselves as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*or8D19rwpfnh_4mDSU7EGA.png" /><figcaption>a super-simplification just to illustrate the problem</figcaption></figure><p>To prevent this from becoming your reality, let’s talk SCP.</p><h3>Block regions you are not using!</h3><p>You or any other region that you <strong>certainly</strong><em> </em><strong><em>don’t use</em></strong>.</p><p>Here’s an example of a SCP that denies any interaction outside the <em>us-east-1 </em>region.</p><pre>{<br>  &quot;Sid&quot;: &quot;whathappensinvirginiastaysinvirginia&quot;,<br>  &quot;Effect&quot;: &quot;Deny&quot;,<br>  &quot;Action&quot;: &quot;*&quot;,<br>  &quot;Resource&quot;: &quot;*&quot;,<br>  &quot;Condition&quot;: {<br>    &quot;StringNotEquals&quot;: {<br>      &quot;aws:RequestedRegion&quot;: &quot;us-east-1&quot;<br>    }<br>  }<br>}</pre><h3>Limit the types of instances that can be launched</h3><p>Next, let’s look at how to restrict the types of instances, this policy limits instance deployment to the t3 family.</p><pre>{<br>    &quot;Sid&quot;: &quot;sorryyoucanonlyusethese&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Action&quot;: [&quot;ec2:RunInstances&quot;],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Deny&quot;,<br>            &quot;Condition&quot;: {<br>                &quot;StringNotEquals&quot;: {<br>                    &quot;ec2:InstanceType&quot;: [<br>                        &quot;t3.nano&quot;, &quot;t3.micro&quot;, &quot;t3.small&quot;, &quot;t3.medium&quot;,<br>                        &quot;t3.large&quot;, &quot;t3.xlarge&quot;, &quot;t3.2xlarge&quot;<br>                    ]<br>                }<br>            }<br>        }<br>    ]<br>}</pre><h3>Implement a TAG requirement</h3><p>Last but not least, you soon learn after a while that resources without tagging are the sure way to have a resource just standing there, with no tracing of what its purpose or who deployed, let’s try to fix that.</p><p>The policy will <strong>only allow </strong>resources to be deployed after they have the tags set up properly in the moment they are being deployed(IaC or ClickOps).</p><pre>{<br>  &quot;Sid&quot;: &quot;pleaselabelstuff&quot;,<br>  &quot;Effect&quot;: &quot;Deny&quot;,<br>  &quot;Action&quot;: &quot;ec2:RunInstances&quot;,<br>  &quot;Resource&quot;: [<br>    &quot;arn:aws:ec2:*:*:instance/*&quot;,<br>    &quot;arn:aws:ec2:*:*:volume/*&quot;<br>  ],<br>  &quot;Condition&quot;: {<br>    &quot;Null&quot;: {<br>      &quot;aws:RequestTag/CostCenter&quot;: &quot;true&quot;,<br>      &quot;aws:RequestTag/Project&quot;: &quot;true&quot;,<br>      &quot;aws:RequestTag/Owner&quot;: &quot;true&quot;<br>    }<br>  }<br>}</pre><p>So now your blast radius just decreased considerably because:</p><ul><li>Regions outside of your scope of work are blocked;</li><li>Can’t launch big bulky instances;</li><li>Specific tags are required before launching new EC2 instances.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/562/1*RzIeBirxDBcpEVuMsHW33A.png" /><figcaption>As a result, the blast radius of an AWS key with EC2 launch permissions is significantly reduced.</figcaption></figure><p>Now there’s three more that are worth mentioning in a quick win article!</p><h3>Block Services that you probably don’t &amp; OR won’t use</h3><p>Still on the subject on limiting cryptomining in uncommon but possible services, here is my personal suggestions on that.</p><pre>{<br>  &quot;Sid&quot;: &quot;pleasedontcryptomineme&quot;,<br>  &quot;Effect&quot;: &quot;Deny&quot;,<br>  &quot;Action&quot;: [<br>      &quot;amplify:*&quot;,<br>      &quot;sagemaker:*&quot;,<br>      &quot;lightsail:*&quot;,<br>      &quot;elasticmapreduce:*&quot;,<br>      &quot;apprunner:*&quot;,<br>      &quot;outposts:*&quot;,<br>      &quot;elasticbeanstalk:*&quot;,<br>      &quot;workspaces:*&quot;<br>  ],<br>  &quot;Resource&quot;: &quot;*&quot;<br>}</pre><h3>Block the deletion of your AWS Organization</h3><p>You just set everything up, why delete it right away?</p><pre>{<br>    &quot;Sid&quot;: &quot;youcancheckanytimeyoulikebutyoucanneverleave&quot;<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Action&quot;: [<br>                &quot;organizations:DeleteOrganization&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;,<br>            &quot;Effect&quot;: &quot;Deny&quot;<br>        }<br>    ]<br>}</pre><h3>Block accounts from leaving the Organization</h3><p>Now that you have setup a nice a cozy place for all your aws accounts, imagine if they ever wanna leave or someone could take them away, with this SCP you block this.</p><pre>{<br>    &quot;Sid&quot;: &quot;pleasedontleaveus&quot;<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Deny&quot;,<br>            &quot;Action&quot;: [<br>                &quot;organizations:LeaveOrganization&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><p>Also after implementing AWS Organization this is the first SCP that I usually deploy.</p><p>This covers all the topics I wanted to go through.</p><h3>Considerations on using AWS Organizations for small environments</h3><p>I know that not all companies have teams of 10 to hundreds of professionals to set it up, maintain, keep it secure, so here’s my advice if you have a small environment(single account), just do it.</p><ol><li>Create a new account and enable AWS Organizations on it</li></ol><p>2. Invite your “old” account into the organization</p><p>3. You’re good to go !</p><p>With these steps you have isolated your workload account from your management account of the organization, and you can start implementing the strategies we discussed today, no hassle.</p><h3>Conclusion and closing statements</h3><p>Take your time; there’s no need to rush into implementing AWSO just because you read an article.</p><p>Use this material as a guide for your studies and try to branch out as much as possible with the resources contained here.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*6X9sh18NivFqfKxOQLU9qQ.png" /><figcaption>It’s hard, it’s tiring, but you will get there ! — <a href="https://imgflip.com/">https://imgflip.com/</a></figcaption></figure><p>It can get quite hard specially when you are about to start, too much information at once, but bear with me and keep in mind everything here it’s a way to improve how your cloud is going to behave in certain situations that can cause headaches, financially speaking or not.</p><p>Final note: I know there are some SCPs that I didn’t cover, such as blocking modifications on services such as AWS Config, CloudTrail and other services, don’t worry there will be more in the future ;)</p><p><strong>Thank you for your time! </strong><em>If you enjoyed or learned something new, please consider </em><a href="https://www.buymeacoffee.com/tbrondani"><em>buying me a coffee</em></a><em>!</em></p><h3>Resources Used</h3><ul><li>AWS Organizations terminology and concepts — <a href="https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html">https://docs.aws.amazon.com/organizations/latest/userguide/orgs_getting-started_concepts.html</a></li><li>Establishing your best practice AWS environment — <a href="https://aws.amazon.com/organizations/getting-started/best-practices/?nc1=h_ls">https://aws.amazon.com/organizations/getting-started/best-practices/</a></li><li>AWS Maturity Model — <a href="https://maturitymodel.security.aws.dev/en/2.-foundational/scps/">https://maturitymodel.security.aws.dev/en/2.-foundational/scps/</a></li><li>Identity Guide — Preventive controls with AWS Identity — SCPs — <a href="https://aws.amazon.com/blogs/mt/identity-guide-preventive-controls-with-aws-identity-scps/">https://aws.amazon.com/blogs/mt/identity-guide-preventive-controls-with-aws-identity-scps/</a></li><li>How crypto miners hijack AWS accounts (Cryptojacking GUI-Vil Case Study) — <a href="https://cybr.com/cloud-security/how-crypto-miners-hijack-aws-accounts-cryptojacking-gui-vil-case-study/">https://cybr.com/cloud-security/how-crypto-miners-hijack-aws-accounts-cryptojacking-gui-vil-case-study/</a></li><li>AWS re:Invent 2019: Centralize control &amp; visualization of your multi-account environments (MGT220-P) — <a href="https://www.youtube.com/watch?v=_PrFgbuEqLA">https://www.youtube.com/watch?v=_PrFgbuEqLA</a></li><li>Defense-in-depth — <a href="https://csrc.nist.gov/glossary/term/defense_in_depth">https://csrc.nist.gov/glossary/term/defense_in_depth</a></li><li><a href="https://flameshot.org/">Flameshot</a> and <a href="https://app.diagrams.net/">Draw.io</a> as always :)</li><li><em>A curious mind.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9f9fba8946e8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CKA Journey— How to NOT Pass CKA and How to Pass]]></title>
            <link>https://medium.com/@talesbrondani/my-cka-journey-how-to-not-pass-in-cka-78ef2d812ce3?source=rss-de43ab71f0db------2</link>
            <guid isPermaLink="false">https://medium.com/p/78ef2d812ce3</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[cka]]></category>
            <category><![CDATA[cka-exam]]></category>
            <dc:creator><![CDATA[Tales Brondani]]></dc:creator>
            <pubDate>Thu, 06 Jun 2024 12:24:50 GMT</pubDate>
            <atom:updated>2024-10-07T14:36:08.021Z</atom:updated>
            <content:encoded><![CDATA[<h3>My CKA journey — How to NOT Pass CKA</h3><blockquote>Kubernetes is not that hard.</blockquote><blockquote>You just have to know your cluster, understand pods and nodes, configure your YAML files, set up persistent storage, manage secrets, configurations, monitor health and performance, implement auto-scaling, handle service discovery and load balancing, ensure high availability, apply rolling updates without downtime, secure your containers, enforce network policies, integrate with CI/CD pipelines, leverage Helm charts for deployment, and continuously optimize for cost and efficiency.</blockquote><p>Okay, let’s be honest, a good Kubernetes infrastructure is <strong><em>HARD</em></strong> ! The Certified Kubernetes Administrator exam, a.k.a CKA is one of the most challenging certifications today.</p><p>Thanks to <a href="https://www.linkedin.com/in/govardhana-miriyala-kannaiah/overlay/about-this-profile/">Govardhana</a> for the authorization for <a href="https://www.linkedin.com/posts/govardhana-miriyala-kannaiah_kubernetes-is-not-that-hard-you-just-have-activity-7186691186131111937-XaIc/">citation</a>, please do follow him on <a href="https://www.linkedin.com/in/govardhana-miriyala-kannaiah/">LinkedIn</a>, awesome content there by him.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/320/1*3Cnye63cBhjUEWZdcZiCSA.png" /><figcaption>cncf.io</figcaption></figure><p>You can skip the next section and jump right into the CKA resources if you want, I just wanted to give some intro first.</p><p>And don’t worry, as always, references with links will be found throught the article and at the end as well.</p><h3>My journey and how I got to know DevOps</h3><p>Let’s start from the beginning. In 2014/15, I was a junior sysadmin working with Ubuntu, PFSense, VMWare, and Microsoft Windows technologies.</p><p>I had just graduated from college and only had on-premises experience. At that time, I couldn’t quite grasp what was going on, but I did come across cloud technology while studying.</p><p>However, I didn’t fully understand why companies would adopt it. It was during this period that I took a interest in DevOps, Cloud, and Cybersecurity.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/442/1*zOALpwxPAaNPU2SMv4u_cg.png" /><figcaption>POV: This was me after understanding what I got into.</figcaption></figure><p>Fast forward three more years, and I’m working as a senior cloud engineer, utilizing all the technologies mentioned before except Kubernetes.</p><p>In August 2021, the Linux Foundation announced a 50% discount for the exam, and I thought to myself “This is my chance to finally get started.”</p><h4>About the exam:</h4><p>As of today:</p><ul><li>You have 1 year to take the exam from the purchase date.</li><li>You’ll have access to two mock exams in <a href="https://killer.sh/">killer.sh</a> by <a href="https://www.linkedin.com/in/kimwuestkamp/">Kim Wüstkamp</a></li><li>The minimum pass is a score 66.</li><li>You get a “free” retake.</li></ul><p>I didn’t come from zero when started my study path and I’m going to deliver it now why it took me so long to get CKA certified.</p><blockquote><strong><em>The main reason I didn’t pass was because I did not practice enough.</em></strong></blockquote><p>I took a course from the awesome LinuxTips and joined others in live stream sessions of <em>Bonde do CKA</em> and also <em>Descomplicando CKA</em>, both idealized by LinuxTips as well.</p><p>After solidifying my bases I needed practice, for that I spent quite some time playing around with <em>kind</em> and <em>minikube</em>. I’ll write about the projects I played around when studying some time in the future.</p><ul><li>My first attempt resulted in a total 38 out of 100, due bad time management and stumbled around docs a lot.</li><li>My second and last attempt I managed to get 55, again bad time management and missed 4 questions due time constraints. (PLEASE DO PRACTICE BEFORE HAND).</li><li>Almost passed but failed on the third try, I managed to pass on the fourth.</li></ul><p>Below you will find the resources and strategies that I’ve adopted for achieving my certification.</p><h3>Resources used</h3><p>Below you will find everything I’ve used to earn my place among the holders of the CKA, in order and some dates around, both in PT-BR and English.</p><h4>Videos and Courses</h4><ul><li>2018–6hrs — Uncomplicating Docker 2016 — Youtube — LinuxTips;</li><li>2021–15hrs — Uncomplicating Kubernetes — Self-Paced Course — LinuxTips;</li><li>2021–8hrs — BONDE DO CKA — Youtube — LinuxTips(missed the last 2);</li><li>2021–2023 — Kubernetes videos while doing dishes, cleaning the house, going to the gym — Youtube — DevOps with Nana;</li><li>2022 — Udemy Practice Labs — Self paced hands on Lab — KodeKloud;</li><li>2022–2024 —Kubernetes path on KodeKloud— Courses, labs, challanges KodeKloud.</li><li>2022 — Kind and minikube shennenigans — Self paced, used to explore curiosity — Internet;</li><li>2022-2023 — Kubernetes CKA Exam Question Bank — Youtube — Alok Kumar.</li></ul><h4>Awesome Links and Awesome articles</h4><ul><li>CKA Learning Series: Build K8s Cluster using Kubeadm in minutes ! — <a href="https://arunksingh16.medium.com/cka-learning-series-build-k8s-cluster-using-kubeadm-in-minutes-3e34b8ac5e5">Medium</a></li><li>MiniKube, Kubeadm, Kind, K3S: how to start with Kubernetes? — <a href="https://www.padok.fr/en/blog/minikube-kubeadm-kind-k3s">Padok</a></li><li>GitHub — scriptcamp/vagrant-kubeadm-kubernetes: Vagrantfile &amp; Scripts to setup Kubernetes Cluster using Kubeadm for CKA, CKAD and CKA practice environment — <a href="https://github.com/scriptcamp/vagrant-kubeadm-kubernetes">GitHub</a></li><li>Diving Into Kubernetes: Preparing for the CKA · Arch Cloud Labs — <a href="https://archcloudlabs.com/projects/diving-into-kubernetes/">Arch Cloud Labs</a></li><li>Zero to CKA in 2 Weeks — <a href="https://capgemini.github.io/kubernetes/Zero-to-CKA-in-2-Weeks/">Capgemini</a></li><li>How to protect your Kubernetes cluster for free using CrowdSec : kubernetes — <a href="https://www.reddit.com/r/kubernetes/comments/s78ccr/how_to_protect_your_kubernetes_cluster_for_free/">Reddit</a></li><li>Best YAML Formatter Online: Advance YAML Formatter — <a href="https://jsonformatter.org/yaml-formatter">JSON Formatter</a></li><li>How to prepare and pass Certified Kubernetes Administrator(CKA) exam — <a href="https://medium.com/@sovmirich/preparing-and-passing-the-certified-kubernetes-administrator-cka-exam-4a76fa4b1c4#:~:text=General%20information,that%20it%20is%20completely%20practical.">Medium</a></li><li>How to Prepare for CKA Exam ? — <a href="https://www.linkedin.com/pulse/how-prepare-cka-exam-mustapha-jdad/">LinkedIn</a></li><li>The Comprehensive Guide To Passing the Certified Kubernetes Administrator (CKA) Exam — <a href="https://medium.com/@danielmittelman1/the-comprehensive-guide-to-passing-the-certified-kubernetes-administrator-cka-exam-ba7ef2cec27f">Medium</a></li><li>Katacoda — Interactive Learning Platform for Software Engineers — <a href="https://www.katacoda.com/">Katacoda</a></li><li>Kubernetes for Beginners — <a href="https://training.play-with-kubernetes.com/kubernetes-workshop/">Training</a></li><li>Kubernetes Cluster Administration — <a href="https://kubernetes.io/docs/tasks/administer-cluster/">Kubernetes Documentation</a></li></ul><p>This is what I used to go through my first two attempts, again, all of this should be enough for you, but as I mentioned before, at that time I failed both 1st and 2nd try because I was lacking practice.</p><p>For the 3rd and 4th try now in 2024 here’s what I did.</p><p>Re-did mock exams in <a href="https://kodekloud.com/">KodeKloud</a>, <a href="https://killer.sh/">Killershell</a> and spent a good amount of time on <a href="https://www.youtube.com/c/AlokKumar-CloudKeFunde">Alok Kumar</a> series on Y<a href="https://www.youtube.com/watch?v=vWuy_CKz0GY&amp;list=PL6nVblW4NNAQpWVdOJAtS_ANzrrOAktr0">outube</a> and <a href="https://www.linuxtips.io/course/descomplicando-o-cka-ckad-cks">Uncomplicating CKA</a> on <a href="https://linuxtips.io/">LinuxTips.io</a> (Special thanks to <a href="https://www.linkedin.com/in/joaopaulocunhafreire/">João Freire</a> a.ka P0ssu1dao).</p><h4>Tips, tricks and strategies.</h4><p>This is not a priority list or a “what you should do” list. Many strategies here don’t apply to everyone. These are recommendations from someone who has both failed and thrived.</p><ul><li><strong>Practice, practice </strong>and <strong>practice;</strong></li><li><strong>Map</strong> the exam before taking it, read all the questions and prioritize the ones you are good <strong>first;</strong></li><li>Use a <em>big</em> monitor;</li><li><strong>Don’t spend time on setting up new aliases(specially if you are not used to them) </strong>— I know it’s controversial, as many people recommend it, but I personally don’t find it necessary. I used what LF gave me and it was enough, I really favor speed and pace over than three minutes creating aliases that would only save me the same amount of time throughout the exam;</li><li>Train you VI/VIM game, I recommend : <a href="https://www.youtube.com/watch?v=XXRZ0acXHU0">VIM — PT-BR</a> / <a href="https://www.youtube.com/watch?v=ggSyF1SVFr4">VIM — English</a>;</li><li>Train your VI/VIM game by playing a game game in your browser ! <em>No RGB/GPU required</em> — <a href="https://vim-adventures.com/">https://vim-adventures.com/</a> ;</li><li>Elevate shell game as well, especially bash;</li><li>Get a good night of sleep before your exam and take a nap if you’re taking middle of the day / night;</li><li>You are allowed to do breaks, you cannot leave the premises and you will be monitored in that time, <strong>DO USE THEM — </strong>exam rules still apply;</li><li>Learn how to enter and leave the <a href="https://en.wikipedia.org/wiki/Flow_(psychology)">flow state</a>;</li><li>You need 66 points, not 100! Focus on <strong>what you can do</strong>, flag the question you are having trouble or have a know weak spot and come back later after you focused on your strengths;</li><li><strong>Train your time management</strong> game and testing pace, as a two-hour exam is no joke and can take a toll on you very quickly;</li><li>You don’t need to wait until a process is finished to start another, e.g., when you run a <em>ETCDCTL</em> backup command, you can switch to another terminal window and keep working on a “easier” question;</li><li>Effectively learn how to handle YAML;</li><li>Use the yaml outputs in <strong>get</strong> commands instead of <strong>describe</strong>, this saved me a lot of time: e.g. “<em>k get po nginx -o yaml” ;</em></li><li><strong>Know you way around the kubernetes doc! </strong>There are a lot of quick to use YAMLs that are somewhat hidden, for example, I’ve used <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/">this</a> instead of <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/">that</a> for Volume questions. First link is shorter in length and have the quick to use logic [ PV-&gt;PVC-&gt;POD ] in yamls, instead of using the latter which is huge and cover all types of volumes, storage classes and related objects;</li><li>Abuse passive study practices — listen to classes, videos, podcasts while doing dishes, cleaning your house, walking with your dog etc etc;</li><li>When doing active study, grab a pen and paper and <strong><em>WRITE THINGS DOWN</em> </strong>instead of using a virtual notepad;</li></ul><blockquote>This one is for the ESL out there. <em>Your spoken/written english does not need to be top notch to take the exam</em>, only english skills you need are <strong><em>listening</em></strong><em>(</em>after 6 remote proctored exams, only needed this once<em>) </em>and <strong><em>reading</em></strong>, if you can read this article and understand it, you should be good to go on the exam.</blockquote><h4>My Strategy at exam day</h4><p>Both applied on 3rd and 4th try.</p><ul><li>While you wait for the proctor to start the validation, try to clear my mind and focus on the present to spark a flow state;</li><li>As soon the exam start, I skim through all the questions and find the quick and long questions, mark the longest and hardest;</li><li>Finish the quicker/easier questions first;</li><li>Around 1 hour mark , I only have 4/5 questions left, call on a break;</li><li>Drink some water, stretch out while sitting, closed my eyes try to clear my mind and focus on the silence for some minutes;</li><li>After I feel more relaxed, I go back and face the remaining questions.</li></ul><h3>Final Results</h3><p>These are my final results and I’m very proud of myself from all the grinding, testing, writing, mocking, deploys, deletes and many other stuff.</p><ul><li>1st try — July 2022 — 38/100 — ( Bad time management, focused on each question at a time);</li><li>2nd try — August 2022 — 55/100 — Better time management but, still missed 4 questions).</li></ul><blockquote>In between these attempts ( 2022 to 2024), I took my time to study and specialize in other fields, got my Terraform Associate and AWS Security, as K8S was not technology needed for me at that time, I decided to focus on tools and concepts that I would be needing the most.</blockquote><ul><li>3td try — February 2024 — 60/100 — Good time management(14 questions in 1 hour), but had a lot of trouble with the 4 remaining questions on ingress and network policies;</li><li>4th try — April 2024 — 84/100 — Good time management(13 questions in 1 hour) and solid knowledge on my previous weak spots.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/426/1*-cEh7lwPcKvCF1_9RSi1Eg.png" /><figcaption>This is me after getting my results. — <a href="https://www.youtube.com/watch?v=SI5bkZcgvP0">https://www.youtube.com/watch?v=SI5bkZcgvP0</a></figcaption></figure><p>But use this as a guide to your success in CKA and also other certs, as I gave many tips that you can follow to have success in other areas of your life as well.</p><p>Also, don’t give up you experienced something similar, as Albert Einstein once said:</p><blockquote>“Failure is success in progress.”</blockquote><p>This was my journey in the but now I start another one on the path of CKS and many more others certifications and learning paths.</p><p><strong>Keep studying and thank you for your time!</strong></p><p><em>If you enjoyed or learned something new, please consider </em><a href="https://www.buymeacoffee.com/tbrondani"><em>buying me a coffee</em></a><em>!</em></p><h3>Resources Used</h3><ul><li>Certified Kubernetes Candidate Handbook — <a href="https://docs.linuxfoundation.org/tc-docs/certification/lf-handbook2">https://docs.linuxfoundation.org/tc-docs/certification/lf-handbook2</a></li><li>Kubernetes Curriculum — <a href="https://github.com/cncf/curriculum">https://github.com/cncf/curriculum</a></li><li>Kubernetes docs — <a href="https://kubernetes.io/docs/home/">https://kubernetes.io/docs/home/</a></li><li>KillerShell — <a href="https://killer.sh/">https://killer.sh/</a></li><li><em>A restless mind.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78ef2d812ce3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cloud Security Quick Wins for your AWS Environment — PART 1]]></title>
            <link>https://medium.com/@talesbrondani/cloud-security-quick-wins-for-your-aws-environment-part-1-62e5025978ba?source=rss-de43ab71f0db------2</link>
            <guid isPermaLink="false">https://medium.com/p/62e5025978ba</guid>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[cloud-security]]></category>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[s3]]></category>
            <dc:creator><![CDATA[Tales Brondani]]></dc:creator>
            <pubDate>Tue, 13 Feb 2024 18:43:30 GMT</pubDate>
            <atom:updated>2024-10-07T14:35:34.942Z</atom:updated>
            <content:encoded><![CDATA[<h3>Cloud Security Quick Wins for your AWS Environment — PART 1</h3><p>Not enough time? I’ve got you!</p><p>In the fast-paced world of cloud computing, security should be at the forefront of every AWS user’s mind. Whether you’re managing small workloads or running labs, prioritizing security is a non-negotiable aspect of a robust cloud environment.</p><p>For some, security might not be the initial consideration when managing labs or small workloads in your company. However, if security is a priority of 0 for AWS, and you are utilizing AWS, why not align with the same emphasis?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/473/1*niimHdIaSMBtMtc3zwA77g.png" /><figcaption>Pls, do cloud security</figcaption></figure><p>I’ve curated some tips and how-to’s so you can effortlessly implement quick wins for your AWS cloud environment with just a few clicks or CLI commands. For those lazy DevOps enthusiasts I’ve even included a bash script. Additionally, there’s an explanation at the end for those who are at the beginning of their cloud journey.</p><blockquote>WARNING: Actions below may disrupt or impact your environment depending on your current settings and use-case, test first in a test environment and slowly progress over to production.</blockquote><h3>Enable MFA for Root</h3><p>Yes, the first one is MFA for root ! Cliche, I know. (you’d be surprised)</p><p>Navigate to the top right corner of your AWS console. There, you’ll find your identity, click on it and proceed to the <em>Security Credentials</em> section.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/251/1*zpkpxhhUfz2nE9aNGC1X2w.png" /></figure><p>You will be taken to this screen , where you can click on <em>Assign MFA</em> in the banner or <em>Assign MFA device </em>to proceed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/979/1*GCYDoyIYx-CbrGvegF65pw.png" /></figure><p>After that follow the instructions and add <strong>something.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/966/1*NVYa0sfqMUlUl118gQi5-Q.png" /></figure><p>In this case I’ve added a virtual device type, but you can use even use a ubikey if you want.</p><p>Now let’s go over some EC2/S3 quick wins (two of the most used AWS services out there).</p><h3>Enable EBS Encryption</h3><p>First let’s check the current status by using aws cli:</p><p>Now, that’s not good, let’s enable it and check if it was applied.</p><pre> aws ec2 get-ebs-encryption-by-default</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*nE2yqSxbpDteOixtKycSNg.png" /></figure><p>Now, that’s not good, let’s enable it and check if it was applied.</p><pre>aws ec2 enable-ebs-encryption-by-default</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/555/1*KnBVRmk6zDtbjAB963zMLw.png" /></figure><p>Note: All EBS created <strong>AFTER</strong> this will be encrypted by default, even if you don’t specify in your IaC or ClickOps, but you <strong>will have to relaunch old unencrypted EBS</strong>.</p><blockquote>OH NO ! IT BROKE PROD (it didn’t, but you were asked to roll it back…yikes)</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*vQsDjR12oAyHu3bU7lESQA.png" /></figure><p>Fear not! You can just run the <em>aws ec2 disable-ebs-encryption-by-default</em> to revert the change, no harm no foul.</p><pre>aws ec2 disable-ebs-encryption-by-default</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/568/1*5WQbhicrIshHOlIC9dGBTg.png" /></figure><h3>Enable Block public access for EBS Snapshots</h3><p>We always try to avoid the fat finger, but eventually, someone will try to do it, accidentally or intentionally. Before applying, let’s check the current state.</p><pre>aws ec2 get-snapshot-block-public-access-state</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/604/1*J7u_sBjxQbhN3FfotFShkA.png" /></figure><p>Now for this one, we have a <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/block-public-access-snapshots-work.html#block-public-access-snapshots-view">few options,</a> let’s focus on the this one for now.</p><pre>aws ec2 enable-snapshot-block-public-access --state block-all-sharing</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/771/1*jRRM9m4Wrx02Dwcwm8MY2Q.png" /></figure><h4>Rollback time:</h4><pre>aws ec2 disable-snapshot-block-public-access</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*pHzujrx8Z2vGNyiJV1rcuw.png" /></figure><h3>Block public access for AMIs</h3><p>AWS enabled it by default for all costumers, but if your account isnt covered by that here it is how to check and enable it properly the same way as the other two.</p><h4>Checking:</h4><pre>aws ec2 get-image-block-public-access-state</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*DLVbjGt3HdZJHCBdTEsoKg.png" /></figure><h4>Blocking:</h4><pre> aws ec2 enable-image-block-public-access --image-block-public-access-state block-new-sharing</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/943/1*YZxKpnM7jZcsU7gpO7v-8Q.png" /></figure><h4>Rollback:</h4><pre>aws ec2 disable-image-block-public-access</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/592/1*p-b-CsEhP694LGDQ_RdwoA.png" /></figure><h3>Blocking S3 Public Access</h3><p>You can use the one liner below to check the current configurations</p><pre>ID=$(aws sts get-caller-identity --query &quot;Account&quot; --output text) ; aws s3control get-public-access-block --account-id ${ID}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/798/1*DigewYTVmSjniW5vrGu_eg.png" /></figure><p>Let’s apply the block, don’t worry about the command for now.</p><pre>ID=$(aws sts get-caller-identity --query &quot;Account&quot; --output text) ; aws s3control put-public-access-block --public-access-block-configuration &#39;{&quot;BlockPublicAcls&quot;: true, &quot;IgnorePublicAcls&quot;: true, &quot;BlockPublicPolicy&quot;: true, &quot;RestrictPublicBuckets&quot;: true}&#39; --account-id ${ID} ; aws s3control get-public-access-block --account-id ${ID}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/803/1*qVLT0v0j0yYBJDhjPb_BFg.png" /></figure><p>Now let’s suppose you’ve changed your mind and want to revert the changes</p><pre>ID=$(aws sts get-caller-identity --query &quot;Account&quot; --output text) ; aws s3control put-public-access-block --public-access-block-configuration &#39;{&quot;BlockPublicAcls&quot;: false, &quot;IgnorePublicAcls&quot;: false, &quot;BlockPublicPolicy&quot;: false, &quot;RestrictPublicBuckets&quot;: false}&#39; --account-id ${ID} ; aws s3control get-public-access-block --account-id ${ID}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/805/1*PMmWIqYlYaP6b8FxruFIwA.png" /></figure><p>If you don’t want to enable all the blocks, you can select true/false depending on your need before applying the configuration with this bash.</p><p><strong><em>You can skip this next few lines, just some explanation on why the AWS CLI got a little complicated.</em></strong></p><p>If we want to apply the blocks using cli we gotta make some bash wizardry, <em>aws s3controls</em> is kinda tricky and here’s why:</p><ul><li>it expects us to use an account id as a parameter(that’s why the ID variable is there);</li><li>expects a json string in as parameter (<em>‘{“BlockPublicAcls”: true, “IgnorePublicAcls”: true, “BlockPublicPolicy”: true, “RestrictPublicBuckets”: true}’) ;</em></li><li>Put actions don’t return any messages, so I concatenated a get in the final version allowing you to confirm the applied settings.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/808/1*r94fDKJtnJPWuJ1-nSOoPw.png" /></figure><h3>ClickOps Section for every EC2/S3 tip</h3><p>Go to the EC2 Dashboard and find the Account attributes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/366/1*KgGl-MIEngghC17BpTS03Q.png" /></figure><p>I’ve spun a new AWS account and did some shenanigans with it, this is what it should look like on your side. We will go through each one of the services in order and some explanation will follow as well.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/598/1*NK3z67_Cppc8eZV_lH2lCQ.png" /></figure><h4><strong>EBS Encryption</strong></h4><p>Something to consider before enabling.</p><blockquote>1: After you enable EBS encryption current existing volumes will NOT be encrypted automatically, only volumes created AFTER will be created as encrypted by default.</blockquote><blockquote>2: If you plan on sharing your EBS volumes with other aws accounts in the future on a daily basis, do keep in mind that will require some effort on your side to properly access data inside the volume itself after has been moved.</blockquote><p>Mark the checkbox for Enable and select your encryption key.</p><p>After you are comfortable just hit the “Update EBS Encryption”.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/638/1*qYW9khpEWt_oIm4NPFJt7Q.png" /></figure><p>and after that, newly created EBS volumes will have encryption enabled by default.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/617/1*wNYF4mg9XwSxlcpg2d7t-w.png" /></figure><h4>Block public access for AMI’s</h4><p>Click on Manage, check the box and hit the update button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*VBB8yYW_6hh8K9KIWabpUw.png" /></figure><p>I know it’s redundant, but, any public AMI will continue to be public, check out this <em>totally legit AMI </em>shared like this one down below is still public after applying the config.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*WJEMHMRslimD366uOtoxUQ.png" /></figure><blockquote>my recommendation is always to check <strong>first</strong> and then <strong>apply</strong> the config.</blockquote><h4>Block Public Snapshots</h4><p>Click on Manage</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/670/1*vXyPu4LaAs6MvkZxS7vLJw.png" /></figure><p>Click on “<em>Block public access” </em>and select the type of block you want, <em>“block all”</em> or “<em>new public sharing”, </em>you can click on the “<strong><em>View public snapshots”</em></strong> link to check if you have any, my recommendation is to check first and then apply the config.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*2boKWGLTjjaVyd62MOqqZA.png" /></figure><h4>Block S3 Public Acess</h4><p>I have created some buckets in my account, which are the perfect example, one of them has explicit public objects for testing purposes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*_gLp4asTo161Eu0JGRd8cg.png" /></figure><p>Now go to S3 Console and find this section <em>“Block Public Access settings for this account”</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/270/1*pTzg3qdi1rZxf-6448vXcw.png" /></figure><p>You will be directed to this page, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/686/1*4lUA2nKyXyuUbMpsihdIPA.png" /></figure><p>After that just select everything and hit the “Save Changes” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*y9qzhhi8ftHVxX2EoCEdzw.png" /></figure><p>Don’t forget to confirm! It behaves in a similar way as other tips, public items <strong>WILL</strong> be blocked.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/528/1*5UV2swhivuSOkHp8zwbz5g.png" /></figure><p>And there you go, previously public buckets are now private.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*7POJCGY3RdXM7xDgD72UnA.png" /></figure><p>Done and dusted.</p><p>No time to go through every aws cli page or aws console page?</p><p>I’ve got you ! This script will cover all the EC2/S3 blocks we’ve talked about before, you can use the options to check(1), apply configuration (2) or disable the configuration(3).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/580/1*90JAhvYCJ324qnX13ugzgg.png" /><figcaption><a href="https://github.com/tbrondani/random/blob/master/aws/block-public-acess.sh">https://github.com/tbrondani/random/blob/master/aws/block-public-acess.sh</a></figcaption></figure><p>I’ve used cloudshell to run the script above and ran using a profile with Full EC2/S3 permissions in IAM, you need to check if your permissions allow you to run the script.</p><p>Now, here’s a <em>why</em> for every tip:</p><ol><li><strong>Enable EBS Encryption:</strong></li></ol><p>This is for when someone shares your EBS with another account. If you don’t share the key you’ve used to encrypt the EBSes, the other side will never be able to access the data. Hence, if your data is leaked, you’re protected.</p><p><strong>2. Enable Block public access for EBS Snapshots;</strong></p><p><strong>3. Enable Block public access for AMIs:</strong></p><p>These configurations are essential to prevent accidental or intentional sharing of your snapshot/AMI with another account. They serve as a barrier against data leakage from these backups.</p><p>It’s worth noting that, while (1) restricts the sharing of AMIs(because they use volumes under the hood), enabling (2) and (3) is still important to prevent old volumes, AMIs, and snapshots from being shared publicly.</p><p><strong>4. Blocking S3 Public Access</strong></p><p>This is meant to prevent you from leaking data unintentionally.</p><p>Also, all the features</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*sNFfC49Ox5oOfCrr3WeyYw.png" /><figcaption>Don’t worry, I know it’s a lot to do, but you got this!</figcaption></figure><p>The next topic I wanted to discuss is about AWS Organizations, but I will cover that on the part 2. Stay tuned for more!</p><p>EDIT: Part 2 is out now :)</p><p><a href="https://medium.com/@talesbrondani/cloud-security-quick-wins-for-your-aws-environment-part-2-aws-organizations-and-scps-9f9fba8946e8">Cloud Security Quick Wins for your AWS Environment — PART 2 — AWS Organizations and SCPS</a></p><p><strong>Thank you for your time! </strong><em>If you enjoyed or learned something new, please consider </em><a href="https://www.buymeacoffee.com/tbrondani"><em>buying me a coffee</em></a><em>!</em></p><h4>Resources Used</h4><ul><li>S3 Block Public Acess — <em>h</em><a href="https://docs.aws.amazon.com/AmazonS3/latest/userguide/configuring-block-public-access-account.html"><em>ttps://docs.aws.amazon.com/AmazonS3/latest/userguide/configuring-block-public-access-account.html</em></a></li><li>AWS S3 Control CLI — <a href="https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3control/put-public-access-block.html"><em>https://awscli.amazonaws.com/v2/documentation/api/latest/reference/s3control/put-public-access-block.html</em></a></li><li>AWS Docs — <a href="https://docs.aws.amazon.com/">https://docs.aws.amazon.com/</a></li><li><a href="https://app.prntscr.com/">LightShot</a> and <a href="https://flameshot.org/">Flameshot</a></li><li><em>A curious mind.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62e5025978ba" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS IAM + Terraform — Terraform Tactics for IAM dominance]]></title>
            <link>https://medium.com/@talesbrondani/aws-iam-terraform-terraform-tactics-for-iam-dominance-e22177e094d0?source=rss-de43ab71f0db------2</link>
            <guid isPermaLink="false">https://medium.com/p/e22177e094d0</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[infrastructure-as-code]]></category>
            <category><![CDATA[terraform]]></category>
            <category><![CDATA[iam-roles]]></category>
            <dc:creator><![CDATA[Tales Brondani]]></dc:creator>
            <pubDate>Wed, 18 Oct 2023 14:12:40 GMT</pubDate>
            <atom:updated>2024-02-13T18:05:32.533Z</atom:updated>
            <cc:license>https://creativecommons.org/licenses/by-nc-sa/4.0/</cc:license>
            <content:encoded><![CDATA[<h3>AWS IAM + Terraform — Terraform Tactics for IAM dominance</h3><p>Who doesn&#39;t like coding infrastructure? (I love it!)</p><p>Being able to create, recreate and modify (at least some of) your infrastructure at your will with just a few commands or clicks (not judging) is not just an estimated skill nowadays, it is also a must or a lifesaver depending on the company you work for or the kind of project you’re doing.</p><p>This article will cover the process of creating<strong> </strong>the permissions needed for an infrastructure to access another environment within the cloud ecosystem.</p><h3>What is IAM ?</h3><p>AWS Identity and Access Management (IAM) policies are essential components of AWS security and access rights for users, groups or roles within an AWS environment. Policies are created and maintained in JSON format and define what actions are allowed or denied on AWS resources.</p><h4>IAM Roles</h4><blockquote>“An IAM role is similar to an IAM user, in that it is an AWS identity with permission policies that determine what the identity can and cannot do in AWS. However, instead of being uniquely associated with one person, a role is intended to be assumable by anyone who needs it.”</blockquote><blockquote><a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html">IAM roles — AWS Identity and Access Management (amazon.com)</a></blockquote><p>When working with IAM, security is your top priority and for this you need to avoid actions that will enable more than your user or application would need it. The principle behind this is called “principle of least privilege (<a href="https://en.wikipedia.org/wiki/Principle_of_least_privilege">PoLP</a>)”.</p><h3>The Architecture</h3><p>For this article we will use the following base scenario as an example to work on our task that is to implement the IAM Role using Terraform effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*qUoLjfHuEcEWtCPthtYcUA.png" /><figcaption>Figure 1: Base architecture used as an example</figcaption></figure><p>This architecture consists in a AWS EC2 named “UltraAwesomeEC2” with a IAM role named “ultra-role” access to read a AWS S3 bucket named “MySuperBucket”.</p><p>For this architecture we will be needing 3 resources from the AWS provider:</p><ul><li>(1) aws_iam_role;</li><li>(2) aws_iam_policy;</li><li>(3) aws_iam_role_policy_attachment.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/382/1*GtKhjofRM2bg15c6MdN9Fg.png" /><figcaption>Figure 2: Represents all needed resources from AWS provider and how they interact between them</figcaption></figure><p>Both (1) and (2) are responsible for creating the role and the policy respectively and (3) to bind them together.<br><em>(There is another way of doing this but let’s focus on this for now, okay?)</em></p><p>For now we will be focusing only on the IAM role part of the architecture (more coming in the future).</p><p><strong>That being said, let’s examine 3 methods to harness Terraform potential in AWS having the following architecture used as our case!</strong></p><h4>Method 1 — File Feature</h4><p>This method consists in using a Terraform feature called “File” which you can reference files outside Terraform ecosystem by separating the Terraform code file from the JSON code file. You can use this method to focus <strong><em>only </em></strong>on terraforming. Tough I don’t recommend using this for big projects or using too many JSON files.</p><p>This could severely increase your maintenance time in the future since you would always need to go into that file and change it manually (again, not judging).</p><p><strong>Below you can see an example of implementing the File method containing the 3 resources mentioned earlier:</strong></p><pre>#iam.tf file<br><br>resource &quot;aws_iam_role&quot; &quot;ultra_role&quot; {<br>  name = &quot;ultra-role&quot;<br><br>  assume_role_policy = file(&quot;iam/assumerole.json&quot;)<br>}<br><br>resource &quot;aws_iam_policy&quot; &quot;ultra_policy&quot; {<br>  name   = &quot;ultra-policy&quot;<br>  policy = file(&quot;iam/policy.json&quot;)<br>}<br><br>resource &quot;aws_iam_role_policy_attachment&quot; &quot;example_role_policy_attachment&quot; {<br>  role       = aws_iam_role.ultra_role.name<br>  policy_arn = aws_iam_policy.ultra_policy.arn <br>}<br><br></pre><pre># policy.json - remove this line if you plan to use this json -<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:GetObject&quot;,<br>        &quot;s3:ListBucket&quot;,<br>        &quot;s3:ListMultipartUploads&quot;,<br>        &quot;s3:GetObjectVersion&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::your-bucket-name/*&quot;<br>    }<br>  ]<br>}<br></pre><pre># assumerole.json - remove this line if you plan to use this json -<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: &quot;ec2.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>    }<br>  ]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/262/1*3UP1AsSEXQPT1mQBvZScLA.png" /><figcaption>Figure 3: Example of how the files would be structured using the separating method</figcaption></figure><p>But remember, there is no <strong><em>right way</em></strong> of doing this. If it works for you and your team/company, just go for it!</p><p>The next two methods accomplish the exact same objective but the implementation is quite different from one another.</p><h4>Method 2 — Here-document syntax (&lt;&lt;POLICY / EOF)</h4><p>First of all we need to at least understand what is a H<a href="https://en.wikipedia.org/wiki/Here_document">eredoc</a>:</p><blockquote><strong>“Heredoc </strong>is a section of a <a href="https://en.wikipedia.org/wiki/Source_code">source code</a> file that is treated as if it were a separate <a href="https://en.wikipedia.org/wiki/Computer_file">file</a>”</blockquote><blockquote><a href="https://en.wikipedia.org/wiki/Here_document">https://en.wikipedia.org/wiki/Here_document</a></blockquote><p>So in the end, Terraform treats this during plan and apply steps as a JSON file itself and it will have no issues doing this, but do be careful, Terraform will not debug JSON for you!</p><p>Below is an example of Heredocs implementation using the same example as before:</p><pre>#iam.tf file<br><br>resource &quot;aws_iam_policy&quot; &quot;ultra_policy&quot; {<br>  name = &quot;ultra-policy&quot;<br><br>  policy = &lt;&lt;POLICY<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:GetObject&quot;,<br>        &quot;s3:ListBucket&quot;,<br>        &quot;s3:ListMultipartUploads&quot;,<br>        &quot;s3:GetObjectVersion&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;${aws_s3_bucket.ultra_bucket.arn}&quot;<br>    }<br>  ]<br>}<br>POLICY<br><br>}</pre><h4>Method 3 — JSONEncode</h4><p>Okay! Now onto our last method: JSONEncode! This is the most common method around and it’s one of the most recommended if you take a look at Terraform docs. It treats JSON code very similar to the example before and allow you to bring it more close to the Terraform code.</p><pre>#iam.tf file<br><br>resource &quot;aws_iam_role&quot; &quot;ultra_role&quot; {<br>  name = &quot;ultra-role&quot;<br><br>  assume_role_policy = jsonencode({<br>    Version = &quot;2012-10-17&quot;,<br>    Statement = [<br>      {<br>        Effect    = &quot;Allow&quot;,<br>        Principal = {<br>          Service = &quot;ec2.amazonaws.com&quot;<br>        },<br>        Action    = &quot;sts:AssumeRole&quot;<br>      }<br>    ]<br>  })<br>}<br><br><br>resource &quot;aws_iam_policy&quot; &quot;ultra_policy&quot; {<br>  name = &quot;ultra-policy&quot;<br><br>  policy = jsonencode({<br>    Version = &quot;2012-10-17&quot;,<br>    Statement = [<br>      {<br>        Effect = &quot;Allow&quot;,<br>        Action = [<br>          &quot;s3:GetObject&quot;,<br>          &quot;s3:ListBucket&quot;,<br>          &quot;s3:ListMultipartUploads&quot;,<br>          &quot;s3:GetObjectVersion&quot;<br>        ],<br>        Resource = &quot;arn:aws:s3:::your-bucket-name/*&quot;<br>      }<br>    ]<br>  })<br>}<br><br>resource &quot;aws_iam_role_policy_attachment&quot; &quot;example_role_policy_attachment&quot; {<br>  role       = aws_iam_role.ultra_role.name<br>  policy_arn = aws_iam_policy.ultra_policy.arn <br>}</pre><h3>Bonus TIP!</h3><p>If you are using the example code above in a project or template where you need to change the name of the bucket based on <strong><em>anything, </em></strong>you need to change the arn id for the s3 bucket every time to reflect the changes. With both method 2 and 3 you can do this <strong><em>dynamically</em></strong>.</p><p>The solution is pretty <strong>neat</strong> and HCL has our back on this (<a href="https://developer.hashicorp.com/terraform/language/syntax/json#expression-mapping">link</a>). You could implement <em>interpolation</em> in the code to make it more reusable and also easier to maintain in the future. HEREDOCS and JSONEncode both supports interpolation.</p><pre>#iam.tf file<br><br>resource &quot;aws_iam_policy&quot; &quot;ultra_policy&quot; {<br>  name = &quot;ultra-policy&quot;<br><br>  policy = &lt;&lt;POLICY<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:GetObject&quot;,<br>        &quot;s3:ListBucket&quot;,<br>        &quot;s3:ListMultipartUploads&quot;,<br>        &quot;s3:GetObjectVersion&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;${aws_s3_bucket.ultra_bucket.arn}&quot;<br>    }<br>  ]<br>}<br>POLICY<br><br>}</pre><h3>Wrap-up / TL;DR</h3><ol><li>JSON files and file argument are easy to implement and hard to maintain;</li><li>HEREDOCS/JSONEncode are, for now, the best options available and support all what HCL can offer in terms of code manipulation using features such as interpolation and local variables if you are feeling adventurous;</li><li>The policies should be designed with the Principle of Least Privilege always and by doing this you avoid excess permissions in roles and policies.</li></ol><h3>Last Thoughts</h3><p>Personally I prefer to use a mix of method 2 and 3:</p><ul><li>Using HEREDOCS for complex IAM policy resources in my view it’s very easy to spot mistakes (such as missing commas or brackets);</li><li>JSONEncode for resources, such as “assume_role_policy”, which will only be implemented once and rarely needs to be revisited.</li></ul><p>For now, this is what I would go with:</p><pre>#iam.tf file<br><br>resource &quot;aws_iam_role&quot; &quot;ultra_role&quot; {<br>  name = &quot;ultra-role&quot;<br><br>  assume_role_policy = jsonencode({<br>    Version = &quot;2012-10-17&quot;,<br>    Statement = [<br>      {<br>        Effect    = &quot;Allow&quot;,<br>        Principal = {<br>          Service = &quot;ec2.amazonaws.com&quot;<br>        },<br>        Action    = &quot;sts:AssumeRole&quot;<br>      }<br>    ]<br>  })<br>}<br><br><br>resource &quot;aws_iam_policy&quot; &quot;ultra_policy&quot; {<br>  name = &quot;ultra-policy&quot;<br><br>  policy = &lt;&lt;POLICY<br>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Action&quot;: [<br>        &quot;s3:GetObject&quot;,<br>        &quot;s3:ListBucket&quot;,<br>        &quot;s3:ListMultipartUploads&quot;,<br>        &quot;s3:GetObjectVersion&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;${aws_s3_bucket.ultra_bucket.arn}&quot;<br>    }<br>  ]<br>}<br>POLICY<br><br>}<br><br><br>resource &quot;aws_iam_role_policy_attachment&quot; &quot;example_role_policy_attachment&quot; {<br>  role       = aws_iam_role.ultra_role.name<br>  policy_arn = aws_iam_policy.ultra_policy.arn <br>}</pre><p>What’s your favorite? Will you jump back into legacy code and change it? Any ideas or thoughts? Please let me know!</p><p>More content coming in the near future and thanks for your time!</p><p>if you enjoyed, please consider <a href="https://www.buymeacoffee.com/tbrondani">buying me a coffee</a>!</p><p>Resources used:</p><ul><li>Terraform Docs — <a href="https://developer.hashicorp.com/terraform/docs">https://developer.hashicorp.com/terraform/docs</a></li><li>AWS Docs — <a href="https://docs.aws.amazon.com/">https://docs.aws.amazon.com/</a></li><li><em>Draw.io — </em><a href="https://draw.io/"><em>https://draw.io</em></a></li><li>Wikipedia — <a href="https://www.wikipedia.org/">https://wikipedia.org/</a></li><li><em>A curious mind.</em></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e22177e094d0" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>