<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Mitchell Edom</title>
    <description>The latest articles on DEV Community by Mitchell Edom (@mitchelledom).</description>
    <link>https://dev.to/mitchelledom</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F352306%2Fce8e0348-0763-415f-bbb8-e634453bb108.jpg</url>
      <title>DEV Community: Mitchell Edom</title>
      <link>https://dev.to/mitchelledom</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mitchelledom"/>
    <language>en</language>
    <item>
      <title>CloudTrail S3 Glacier archival - It's a trap...</title>
      <dc:creator>Mitchell Edom</dc:creator>
      <pubDate>Wed, 06 May 2020 12:11:36 +0000</pubDate>
      <link>https://dev.to/mitchelledom/it-s-a-trap-dkg</link>
      <guid>https://dev.to/mitchelledom/it-s-a-trap-dkg</guid>
      <description>&lt;p&gt;I was recently asked to implement a lifecycle policy to archive central S3 stored CloudTrail logs to Glacier, which on face value seemed like a reasonable idea...&lt;/p&gt;

&lt;p&gt;The environment is reasonably large and the volume of data generated by CloudTrail is not insignificant, existing stats;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&amp;gt;6TB S3 CloudTrail usage&lt;/li&gt;
&lt;li&gt;&amp;gt;345,000,000 Files in CloudTrail bucket&lt;/li&gt;
&lt;li&gt;&amp;gt;30,000,000 new CloudTrail files delivered monthly&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Here are the current approximate costs based on above usage;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;~6TB S3 Standard - $156 / month&lt;/li&gt;
&lt;li&gt;~30,000,000 put requests - $165 / month&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;~$321 / month&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not a huge expense but not insignificant... I started looking into pricing for Glacier;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;$0.005 per GB&lt;/li&gt;
&lt;li&gt;$0.06 per 1,000 Lifecycle Transition requests&lt;/li&gt;
&lt;li&gt;$0.025 per GB for Storage of 8KB file metadata per object...&lt;/li&gt;
&lt;li&gt;$0.005 per GB for Storage of 32KB index and related metadata per object...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So if I assume that the initial life cycle transition archives 80% of the files, the following new monthly costs would apply;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;1.2TB S3 Standard - $32 / month &lt;/li&gt;
&lt;li&gt;5TB Glacier storage - $25 / month&lt;/li&gt;
&lt;li&gt;2.1TB File meta data (8 * 276,000,000) * 0.025 = $52 "S3 storage overhead"&lt;/li&gt;
&lt;li&gt;8.4TB Index meta data (32 * 276,000,000) * 0.005 = $42 "Glacier storage overhead"&lt;/li&gt;
&lt;li&gt;30,000,000 transitions per month - (30,000,000 / 1000) * 0.06 = $1,800&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;~$1951 / month&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Plus the sweetener... an upfront cost of &lt;strong&gt;$16,560&lt;/strong&gt; for initially transitioned files ((276,000,000 / 1000) * 0.06)&lt;/p&gt;

&lt;p&gt;This obviously does not make financial sense and would have been a huge mistake to implement a net increase of ~$1630 plus the upfront shocker of $16560, needless to say we did not pursue the option to use Glacier archival for CloudTrail log files. There are other possible creative ways that could be implemented how ever those costs would likely exceed those of the raw S3 storage cost over time.&lt;/p&gt;

&lt;p&gt;Disclaimer AWS do not recommend Glacier for archival of small files for exactly these cost implications, though it is something that one could easily fall victim to if implemented in a rush. That said hopefully this post might save someone a potentially major headache.&lt;/p&gt;

&lt;h3&gt;
  
  
  References
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;a href="https://aws.amazon.com/s3/pricing/"&gt;https://aws.amazon.com/s3/pricing/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/lifecycle-transition-general-considerations.html"&gt;https://docs.aws.amazon.com/AmazonS3/latest/dev/lifecycle-transition-general-considerations.html&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>aws</category>
      <category>beginners</category>
      <category>costs</category>
      <category>itsatrap</category>
    </item>
    <item>
      <title>Simplify AWS IAM Role Trust Policies in Organizations</title>
      <dc:creator>Mitchell Edom</dc:creator>
      <pubDate>Fri, 20 Mar 2020 04:58:32 +0000</pubDate>
      <link>https://dev.to/mitchelledom/simplify-aws-iam-role-trust-policies-in-organizations-24d5</link>
      <guid>https://dev.to/mitchelledom/simplify-aws-iam-role-trust-policies-in-organizations-24d5</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;As a company scales out the number of AWS accounts used for different workloads, they may require IAM roles which are able to be assumed by any other account within the organization to perform some action, if you are trusting accounts by adding each account principal to the trust policy you may soon find your self hitting the 2048 character limit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Solution
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Use conditions
&lt;/h3&gt;

&lt;p&gt;When making use of conditional filters and the inherent trust that comes from being within an organization, you can dramatically reduce the size and complexity of policies.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From listing all explicit account IDs&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;OrgWideRole&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AWS::IAM::Role&lt;/span&gt;
    &lt;span class="na"&gt;Properties&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;RoleName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;OrgWideRole&lt;/span&gt;
      &lt;span class="na"&gt;AssumeRolePolicyDocument&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;Version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2012-10-17'&lt;/span&gt;
        &lt;span class="na"&gt;Statement&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;Effect&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Allow&lt;/span&gt;
            &lt;span class="na"&gt;Principal&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;AWS&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;012345678901'&lt;/span&gt;
                &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;123456789012'&lt;/span&gt;
                &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;234567890123'&lt;/span&gt;
                &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;345678901234'&lt;/span&gt;
                &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;456789012345'&lt;/span&gt;
                &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;567890123456'&lt;/span&gt;
                &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*150&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;or&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;so&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;more&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;account&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;IDs*'&lt;/span&gt;
            &lt;span class="na"&gt;Action&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sts:AssumeRole&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;To trusting the organization ID&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;OrgWideRole&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;Type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;AWS::IAM::Role&lt;/span&gt;
    &lt;span class="na"&gt;Properties&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;RoleName&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;OrgWideRole&lt;/span&gt;
      &lt;span class="na"&gt;AssumeRolePolicyDocument&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;Version&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;2012-10-17'&lt;/span&gt;
        &lt;span class="na"&gt;Statement&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
          &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;Effect&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Allow&lt;/span&gt;
            &lt;span class="na"&gt;Principal&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;AWS&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s1"&gt;'&lt;/span&gt;&lt;span class="s"&gt;*'&lt;/span&gt;
            &lt;span class="na"&gt;Action&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;sts:AssumeRole&lt;/span&gt;
            &lt;span class="na"&gt;Condition&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
              &lt;span class="na"&gt;StringEquals&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
                &lt;span class="s"&gt;aws:PrincipalOrgID&lt;/span&gt; &lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;o-12345abcd&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;You can change the behavior to limit to accounts associated with a specific OU by using conditional key &lt;code&gt;aws:PrincipalOrgPaths&lt;/code&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e.g.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;Condition&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;ForAnyValue:StringEquals:&lt;/span&gt;
      &lt;span class="s"&gt;aws:PrincipalOrgPaths:&lt;/span&gt;
      &lt;span class="s"&gt;- o-12345abcd/r-eg123/ou-example123/&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Further extension of this is possible by using &lt;code&gt;StringLike&lt;/code&gt; operator to trust all children of the OU&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;e.g.&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;  &lt;span class="na"&gt;Condition&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;ForAnyValue:StringLike:&lt;/span&gt;
      &lt;span class="s"&gt;aws:PrincipalOrgPaths:&lt;/span&gt; 
        &lt;span class="s"&gt;- o-12345abcd/r-eg123/ou-example123*&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;There are more permutations of this possible to fit your needs, though implementing trust via organization membership or OU membership has significantly reduced our trust policy sizes while increasing scalability of the platform.&lt;/p&gt;

&lt;h3&gt;
  
  
  Useful References
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html"&gt;AWS Global Condition Context Keys&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.amazonaws.cn/en_us/IAM/latest/UserGuide/reference_iam-limits.html"&gt;IAM and STS Limits&lt;/a&gt;&lt;/p&gt;

</description>
      <category>aws</category>
      <category>security</category>
      <category>iam</category>
    </item>
  </channel>
</rss>
