<?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 Michael Kirchner on Medium]]></title>
        <description><![CDATA[Stories by Michael Kirchner on Medium]]></description>
        <link>https://medium.com/@michael.kirchner?source=rss-e98b8899684f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dKZ6D4T0rPBWKPfruRlRRg.jpeg</url>
            <title>Stories by Michael Kirchner on Medium</title>
            <link>https://medium.com/@michael.kirchner?source=rss-e98b8899684f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 17:58:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@michael.kirchner/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[Seeing what your Resource Control Policies (RCPs) are going to break]]></title>
            <link>https://medium.com/@michael.kirchner/seeing-what-your-resource-control-policies-rcps-are-going-to-break-2dfeddbd8782?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dfeddbd8782</guid>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-iam]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Tue, 18 Feb 2025 17:35:20 GMT</pubDate>
            <atom:updated>2025-02-18T17:35:20.140Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article shows how you can enumerate trust relationships to outside your AWS Organization that are going to break when you deploy RCPs that block outside access.</h4><p>Resource Control Policies (RCPs) were a great launch of last year’s re:Invent. Similar to Service Control Policies (SCPs), they allow you to set forth central boundaries of what kind of access is allowed within your AWS Organization. In case you want to familiarize yourself with RCPs, you can find the AWS launch blog post <a href="https://aws.amazon.com/blogs/aws/introducing-resource-control-policies-rcps-a-new-authorization-policy/">here</a>.</p><p>A central use case of RCPs is blocking access to resources that live within your AWS Organization from principals that live outside of it. You can use this to, for example,</p><ul><li>make S3 buckets only accessible from within your own Org, or</li><li>make IAM roles only assumable from your own accounts, no matter how misconfigured their role trust policies are. The following example shows such an RCP that protects IAM roles (and you can find more RCP examples <a href="https://github.com/aws-samples/data-perimeter-policy-examples/tree/main/resource_control_policies">here</a>):</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/579/1*oK_p4epZcukowbYTxQu0lw.png" /></figure><p>While such RCPs can offer a great deal of protection, a question remains when you are about to enable them: What is going to break?</p><h4>Legitimate outside sharing</h4><p>There can be several use cases where your resources legitimately trust principals outside your Organization. Most notably these are integrations with external partners and vendors: an AWS account outside your Organization may have write access to one of your S3 buckets, because they are legitimately delivering data to your business. An external CSPM tool may assume roles in your AWS accounts, because you have configured said CSPM tool to conduct regular security scans.</p><p>Before enabling restrictive RCPs, it’s thus a good idea to check upfront which integrations would break. You can then, if desired, add exceptions for certain AWS accounts or resources, using policy conditions.</p><h4>Enumerating outside trusts relevant to RCPs</h4><p>At the time of writing, RCPs offer direct support for five AWS services: S3, STS (and thus IAM roles), KMS, SQS and Secrets Manager. Suppose you want to enable an RCP that denies outside trusts for all accounts that belong to a certain organizational unit (OU). To see if something would break, you will need to perform the following steps for each account that belongs to the OU:</p><ul><li>for each AWS region you might be using, enumerate resources that belong to the five supported services,</li><li>enumerate their resource-based policies,</li><li>extract the principals that are referenced in the resource-based policies, and</li><li>determine whether those principals belong to your own AWS Organization or rather represent an outside trust.</li></ul><p>The good news is that these steps were already automated. You can use the <a href="https://github.com/welldone-cloud/aws-lint-iam-policies">aws-lint-iam-policies tool</a> and run the following exemplary command:</p><pre>python aws_lint_iam_policies.py \<br>  --scope ORGANIZATION \<br>  --member-accounts-role OrganizationAccountAccessRole \<br>  --include-ous ou-aabb-cc11dd22 \<br>  --trusted-accounts SAMEORG \<br>  --include-policy-types sqs_queue_policies,kms_key_policies,secrets_manager_secret_policies,iam_role_trust_policies,s3_access_point_policies,s3_bucket_policies,s3_directory_bucket_policies,s3_multi_region_access_point_policies,s3_object_lambda_access_point_policies,s3_table_bucket_policies,s3_table_policies \<br>  --include-finding-issue-codes TRUSTED_OUTSIDE_PRINCIPAL,TRUSTED_OUTSIDE_PRINCIPAL_WITH_CONDITIONS,TRUSTED_WILDCARD_PRINCIPAL,TRUSTED_WILDCARD_PRINCIPAL_WITH_CONDITIONS</pre><p>Now that’s quite a lengthy command, so let’s break down the individual arguments:</p><ul><li><strong>scope </strong>and <strong>member-accounts-role</strong>: You will need to run the tool with credentials that belong to the Organization management account. This is because it needs to assume a role within each account of the targeted OU and it also needs access to the list of account IDs that belong to the Organization. You can learn more about the minimum set of IAM permissions required in the GitHub repository referenced above.</li><li><strong>include-ous</strong>: In this example, we only want to analyze a specific OU (“ou-aabb-cc11dd22”). You may also target multiple OUs or leave away the parameter entirely to analyze the entire Organization.</li><li><strong>trusted-accounts</strong>: Here we declare all account IDs that belong to your own Organization as being trustworthy. The tool will thus only report on trust relationships to principals outside your Org. Instead of using “SAMEORG”, you can also list individual account IDs here.</li><li><strong>include-policy-types</strong>: While aws-lint-iam-policies supports more AWS services, this time we are only interested in resources that belong to those five services that are supported by RCPs.</li><li><strong>include-finding-issue-codes</strong>: Again, the tool can detect several kinds of errors and security observations in your policies, but this time we are only interested in one kind of finding: trusts to principals outside your AWS Organization (which also includes trusts to the wildcard principal).</li></ul><h4>Example result</h4><p>For demo purposes, I’ve set up multiple cross-account trust relationships in accounts of an example OU. Some trusts are within the same Organization, some involve AWS accounts outside of it.</p><p>When running the command listed above, we get results both in JSON and in HTML format. The results highlight resource-based policies that trust principals outside of your AWS Organization. We can see that a Secrets Manager secret as well as an IAM role have this kind of trust configured:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Uk_Zrn99rJXjnPFaCaGz2w.png" /></figure><p>We can further drill down into the details and investigate the affected policies. Here we have the exemplary IAM role that trusts to be assumed by an external vendor:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1011/1*pWYIS0zeJoifwaq9Sx6KJg.png" /></figure><p>As a security responsible, you can now investigate whether this setup is as desired, whether access is still needed and used, and whether you want to put exceptions into your RCP in order not to break functionality. Exceptions can be implemented using policy conditions, for example using the “aws:PrincipalAccount”, “aws:ResourceAccount” or “aws:ResourceTag” condition keys. As an alternative, AWS accounts that require certain outside trusts may also be moved to a different OU.</p><h4>Closing thoughts</h4><p>Before enforcing RCPs in your AWS Organization, take the time to thoroughly investigate whether outside trust relationships are going to break. You might even discover trusts that you were not aware of yet :) This article showed one way how to identifiy these trusts. There are also alternative ways, like investigating your CloudTrail data.</p><p>While RCPs provide great capabilities, an “audit mode” would still be a nice addition, to investigate for a while what RCPs would be blocking, if actually enforced. In the meanwhile, you can just use open source tooling like the one referenced above.</p><p>Happy engineering and that’s all for today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dfeddbd8782" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is the probability that you can successfully assume an IAM role in a random AWS account?]]></title>
            <link>https://medium.com/@michael.kirchner/what-is-the-probability-that-you-can-successfully-assume-an-iam-role-in-a-random-aws-account-52dfa85cf077?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/52dfa85cf077</guid>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-security]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Thu, 15 Aug 2024 15:03:15 GMT</pubDate>
            <atom:updated>2024-08-17T06:06:36.005Z</atom:updated>
            <content:encoded><![CDATA[<p>Many resources on AWS can be configured to allow public access, using their resource-based policies. S3 buckets are a well-known example, but other resources can be made publicly accessible too, such as IAM roles. This research collected valid IAM role ARNs that live in random AWS accounts and subsequently tried to assume them.</p><h3>The starting point</h3><p>When I conduct AWS account security reviews, every now and then I see an IAM role that inadvertently is made public. This means that the role’s trust policy trusts the “*” principal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/415/1*h1tJJuYbpvTl438wbGvNVw.png" /></figure><p>Such a policy sets forth that anybody with an AWS account can assume this role and act under the permissions of this role. The actual impact for the customer varies, as it depends on the permissions of the role and the criticality of the data processed in the account.</p><p>From a shared responsibility model point of view, the responsibility for this configuration is on the customer side. AWS shows a warning message on the Console, but if you use infrastructure as code (which you should!), chances are that you will never click on the role and see it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*kmo6rsOQB5lhVkZ2XrlqYw.png" /></figure><p>In any case, there is also a dedicated note on trusting the “*” principal in the AWS documentation: <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html">https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_principal.html</a></p><p>I asked myself how common this configuration issue is and whether it would be possible for external actors to find such roles, without access to the underlying AWS accounts.</p><h3>The approach</h3><p>To analyze the topic at scale, we require a list of valid IAM role ARNs and can subsequently try to assume them. The two core components of a role ARN are the account number the role lives in, and the role name:</p><p>arn:aws:iam:112233445566:role/SomeRoleName</p><p>To collect a list of role ARNs, two approaches were chosen, resulting in two different data sets:</p><p><strong>Data set 1: Sourcegraph</strong></p><p>Sourcegraph offers great functionality to search through public source code repositories, such as GitHub. IAM role ARNs are not a secret piece of information per se, so they might end up being stored directly in code. The well-known structure of IAM role ARNs also allows to search for them using regular expressions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*oGKyc8NmD6C_3MXvvA6KCA.png" /></figure><p>This approach was also used by other security research, such as this one by Datadog: <a href="https://securitylabs.datadoghq.com/articles/amplified-exposure-how-aws-flaws-made-amplify-iam-roles-vulnerable-to-takeover/">https://securitylabs.datadoghq.com/articles/amplified-exposure-how-aws-flaws-made-amplify-iam-roles-vulnerable-to-takeover/</a></p><p>At the time of collecting the data, the above query returned 86,495 results. After removing duplicates and obviously anonymized entries (for example, account IDs like 000000000000 or 111111111111), this number reduced to 6,816. Those IAM roles, however, only “look valid”. They may not exist in practice or may have already been deleted in the meanwhile.</p><p>To confirm the existence of IAM principals (be it users or roles), without having access to the respective AWS accounts, we can use resource-based policies. The core mechanism is that AWS will only allow you to add an IAM role to a resource-based policy, if that IAM role actually exists. If it does not exist, the attempt will result in an error message. A closer description of this mechanism and ready-made tools are available here: <a href="https://hackingthe.cloud/aws/enumeration/enum_iam_user_role/">https://hackingthe.cloud/aws/enumeration/enum_iam_user_role/</a></p><p>Validating the collected 6,816 IAM roles resulted in a list of 4,437 valid IAM roles for this data set.</p><p><strong>Data set 2: Brute force</strong></p><p>Given the well-defined structure of IAM role ARNs, it is also possible to just guess account IDs and role names.</p><p>This process was split into two parts: First, valid AWS account IDs were enumerated. Only then, when an account ID was confirmed to exist, it was tried to guess IAM roles names that exist within the account. Both can be achieved using resource-based policies, as already described for data set 1. To enumerate account IDs, a reference to root can be used in the resource-based policy:</p><p>arn:aws:iam:112233445566:root</p><p>If it is possible to store a resource-based policy with this principal ARN, it means that the account ID exists. Subsequently, IAM roles can be brute forced that may exist, such as:</p><p>arn:aws:iam:112233445566:role/admin</p><p>arn:aws:iam:112233445566:role/terraform</p><p>arn:aws:iam:112233445566:role/ec2</p><p>arn:aws:iam:112233445566:role/billing</p><p>...</p><p>Using this approach, 1,506,031,783 random possible account IDs were tested, which resulted in the discovery of 139,279 valid account IDs. (As a side note, this means that if you test one million random possible account IDs, you will find, on average, 92 valid ones.)</p><p>Brute forcing valid IAM role names within those accounts comes with the challenge that roles names are case sensitive. As an example, ECSTaskRole will be treated as something different to ecsTaskRole, ecstaskrole, or EcsTaskRole. Adding to the complexity, there are also personal or company preferences regarding separator characters, such as dashes and underscores. So it’s also not uncommon to find role notations like ecs-task-role or ecs_task_role. In a brute force approach, several of those possible notations should ideally be considered.</p><p>To tackle this task, I developed a script that takes a base form of an IAM role name, such as admin!role, and generates a list of mutations that represent possible IAM role names, such as AdminRole, adminRole, admin-role, ADMINrole, etc. You can find the script <a href="https://gist.github.com/michael-kirchner-at/296247755a2e025d881d75fa1aecf450">here</a>.</p><p>When all base forms of IAM role names in the script are expanded, this generates a list of 30,473 possible role names. These names were tested against the previously identified 139,270 valid account IDs. This resulted in a list of 15,010 valid IAM roles for this data set.</p><p>In case you are interested in statistics, here are the 10 most common IAM role names that were discovered for this data set, with number one likely not being a surprise:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/496/1*E9Ac5tRrAvTiygZ_Rt-6Yg.png" /></figure><h3>The role assumption procedure</h3><p>Given the lists of valid IAM role ARNs of data set 1 and data set 2, the next step was to actually try and assume those roles. This is a sensitive step that should be approached with caution. Successful role assumptions will result in CloudTrail entries at the respective AWS accounts. They will also result in valid IAM session credentials being returned for accounts. I took the following steps to mitigate this:</p><ul><li>Setting a custom user agent value that explains that this is research activity and includes a link where I can be contacted.</li><li>Setting a DenyAll session policy while assuming a role. This way, the credentials returned by the sts:AssumeRole API call will not actually provide any usable capabilities within a target account:</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/680/1*1TKMWuadLS6bsfISQBf57Q.png" /></figure><h3>The results</h3><p>For data set 1 (“Sourcegraph”), it was possible to assume ten IAM roles out of the 4,437 tested. This is a success rate of 0.2253%.</p><p>For data set 2 (“Brute force”), it was possible to assume one IAM role out of the 15,010 tested, representing a success rate of 0.0066%.</p><p>While the success rate of data set 1 is higher, I also estimate the probability of decoys or canaries being present in this data set to be much higher. While I did not receive any inquiries as a result of this research, I also did not make any efforts to hide my identity and disclosed all information in the user agent string. Operators of decoys/canaries, if present, thus may did not feel a need to reach out.</p><p>Where I was able to identify the owners of an affected AWS account, I contacted and informed them directly. The remaining IAM role identifiers were reported to AWS Security.</p><p>My personal interpretation of the results is that the numbers are not terribly high. Chances are that other kinds of attack vectors against AWS workloads will stay more prevalent. However, the research hopefully contributes to quantifying the risk behind this attack vector. It may also provide input to the recurring discussion whether you want to keep your AWS account IDs secret.</p><h3>The remediation</h3><p>As mentioned in the beginning, the underlying issue is basically a misconfiguration of IAM role trust policies. Not only IAM roles, but many other AWS resources can be configured this way and allow public access, by granting access to the “*” principal in their resource-based policies.</p><p>To scan your AWS account(s) or AWS Organization(s) for these issues, I’ve published an open source tool that warns you when such configurations are detected. You can find it here:</p><p><a href="https://github.com/welldone-cloud/aws-lint-iam-policies">GitHub - welldone-cloud/aws-lint-iam-policies</a></p><p>Happy scanning and that’s all for today! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52dfa85cf077" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Sharing a single CloudTrail across all accounts of an AWS Organization]]></title>
            <link>https://awstip.com/sharing-a-single-cloudtrail-across-all-accounts-of-an-aws-organization-d19833dc6b99?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d19833dc6b99</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[aws-cloudtrail]]></category>
            <category><![CDATA[aws-cost-optimization]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Mon, 09 Oct 2023 09:35:28 GMT</pubDate>
            <atom:updated>2023-10-10T20:21:49.729Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article shows how you can configure an Organization-wide CloudTrail and selectively share the logs with the respective source accounts. This avoids creating multiple trails, which can lead to reduced costs.</h4><p>AWS CloudTrail is the central API call logging and auditing service on AWS. Whether security group rules were changed, EC2 instances launched or backups deleted: CloudTrail serves as the single source of truth and helps to anwer questions like “Who did what and when?”</p><p>CloudTrail also offers Organization-wide trails. With this feature, the management account of an AWS Organization (or a delegated administrator account) configures a trail, which is then automatically rolled out to all member accounts of an Organization. This has lots of advantages:</p><ul><li>You get a central place (an S3 bucket) where all CloudTrail logs of your Organization are consolidated. This supports auditing, compliance and incident handling activities.</li><li>Newly created accounts in the Organization get onboarded to the trail automatically.</li><li>Individual account owners cannot change or delete the trail. It cannot be prevented from logging, even if the account is compromised on an administrator level.</li></ul><p>Many customers I work with use an Organization-wide CloudTrail for the above-mentioned benefits. Sometimes, however, the following concerns come up: The first CloudTrail you create in an AWS account is free of charge. If individual account owners also want a copy of their CloudTrail data, they need to create a second trail. These trails do get charged, however. Besides increased CloudTrail cost, this essentially means logging the same data twice and storing it on S3 twice (where storage cost can also aggregate over time).</p><h3>Sharing a single CloudTrail</h3><p>One solution to this issue is to configure the central CloudTrail S3 bucket in a way so that the member accounts can access their logs as well. The following diagram shows the setup:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/607/1*5zyZG4t-KBhNi23S_xC53g.png" /></figure><p>On the left, we have the central account that operates the Organization-wide CloudTrail and logs the data to S3. On the right, we have Organization member accounts that use S3 access points to access their logs stored in the central S3 bucket.</p><p>S3 access points themselves don’t have a cost. The bucket policy configuration will make sure that each account can only access the CloudTrail data that belongs to them, and not the logs of the other accounts.</p><h3>The prerequisites</h3><p>The solution makes use of a bucket policy on the central S3 CloudTrail bucket. For bucket policies to work as expected, we need to make sure that the objects stored by the CloudTrail service also belong to the bucket owner. The easiest way of achieving this is to disable ACLs on the bucket:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/789/1*uMnP3JyJ0VPERYHtrDQQkw.png" /></figure><p>If this is not an option for you, change the object ownership settings on the bucket to “Bucket owner preferred”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/576/1*UYde2waIugvwjsh0N9wowg.png" /></figure><p>If you configure CloudTrail to use SSE-S3 to encrypt the log files on S3, there is no further encryption key permission management required. If you choose to use SSE-KMS instead, you also need to grant permissions on the KMS key to the CloudTrail service and to your member accounts. These KMS permissions are not discussed in this article.</p><h3>The implementation</h3><p>The main part of the solution is the bucket policy configured on the central S3 CloudTrail bucket. The bucket policy makes use of the fact that the CloudTrail service writes logs to S3 using structured paths. The path information contains the Organization ID and the member account ID that the logged data belongs to, for example:</p><pre>s3://cloudtrail-data-org-bucket/AWSLogs/o-39rp91j2d4/892431629021/</pre><p>The following bucket policy gives the solution blueprint:</p><pre>{<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;cloudtrail.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;s3:GetBucketAcl&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::cloudtrail-data-org-bucket&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;AWS:SourceArn&quot;: &quot;arn:aws:cloudtrail:eu-central-1:892431629021:trail/cloudtrail-data-org&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;Service&quot;: &quot;cloudtrail.amazonaws.com&quot;<br>      },<br>      &quot;Action&quot;: &quot;s3:PutObject&quot;,<br>      &quot;Resource&quot;: [<br>        &quot;arn:aws:s3:::cloudtrail-data-org-bucket/AWSLogs/892431629021/*&quot;,<br>        &quot;arn:aws:s3:::cloudtrail-data-org-bucket/AWSLogs/o-39rp91j2d4/*&quot;<br>      ],<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;AWS:SourceArn&quot;: &quot;arn:aws:cloudtrail:eu-central-1:892431629021:trail/cloudtrail-data-org&quot;,<br>          &quot;s3:x-amz-acl&quot;: &quot;bucket-owner-full-control&quot;<br>        }<br>      }<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;AWS&quot;: &quot;*&quot;<br>      },<br>      &quot;Action&quot;: &quot;s3:ListBucket&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::cloudtrail-data-org-bucket&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;aws:PrincipalOrgID&quot;: &quot;o-39rp91j2d4&quot;<br>        },<br>        &quot;StringLike&quot;: {<br>          &quot;s3:DataAccessPointArn&quot;: &quot;arn:aws:s3:*:*:accesspoint/cloudtrail-data&quot;,<br>          &quot;s3:prefix&quot;: [<br>            &quot;&quot;,<br>            &quot;AWSLogs/&quot;,<br>            &quot;AWSLogs/${aws:PrincipalOrgID}/&quot;,<br>            &quot;AWSLogs/${aws:PrincipalOrgID}/${aws:PrincipalAccount}/*&quot;<br>          ]<br>        }<br>      }<br>    },<br>    {<br>      &quot;Effect&quot;: &quot;Allow&quot;,<br>      &quot;Principal&quot;: {<br>        &quot;AWS&quot;: &quot;*&quot;<br>      },<br>      &quot;Action&quot;: &quot;s3:GetObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::cloudtrail-data-org-bucket/AWSLogs/${aws:PrincipalOrgID}/${aws:PrincipalAccount}/*&quot;,<br>      &quot;Condition&quot;: {<br>        &quot;StringEquals&quot;: {<br>          &quot;aws:PrincipalOrgID&quot;: &quot;o-39rp91j2d4&quot;<br>        },<br>        &quot;StringLike&quot;: {<br>          &quot;s3:DataAccessPointArn&quot;: &quot;arn:aws:s3:*:*:accesspoint/cloudtrail-data&quot;<br>        }<br>      }<br>    }<br>  ]<br>}</pre><p>We can ignore the first two statements of the bucket policy: these are the standard permissions that the CloudTrail service needs to be able to write to this bucket. These permissions will be granted automatically when configuring CloudTrail to log to S3.</p><p>The third and fourth statement grant access to the member accounts of the AWS Organization. Let’s go through core aspects of them:</p><ul><li>The statements grant read access only to IAM principals that belong to the same AWS Organization (aws:PrincipalOrgID).</li><li>Access is only granted to paths on S3 where the account ID matches the one of the requesting IAM principal (aws:PrincipalAccount). This limits each member account to their own CloudTrail data.</li><li>Access is only allowed if IAM principals make the request via an S3 access point (s3:DataAccessPointArn). In our case, the S3 access point also needs to have a specific name, but you may also change this.</li></ul><p>Member accounts of the Organization can now create an S3 access point and use it to access their CloudTrail logs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*ndJ5jMlzJdG8d3WGOPkHDA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*d0hK7mg7N5bXw5x3ZaDM9Q.png" /></figure><p>Trying to access the CloudTrail log paths of other member accounts will be denied:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/517/1*9kkxHCmsxDQq3kfnJbeqbg.png" /></figure><p>Member accounts can use their S3 access points with any log analytics tools they desire. As an example, a member account may create an Athena table to query their logs. (You can find the required CREATE TABLE statements <a href="https://docs.aws.amazon.com/athena/latest/ug/cloudtrail-logs.html">here</a>). In the table definition, you can refer to the S3 access point alias, like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*KKDpqZLfUT1Di81wHL5Juw.png" /></figure><p>After the table is created, you can use standard SQL to analyze your CloudTrail data:</p><pre>SELECT eventtime, eventsource, eventname, awsregion, sourceipaddress<br>FROM cloudtrail_logs<br>LIMIT 100;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SoL5Zo-uIDcQyGe8ErB_kQ.png" /></figure><h3>Rolling out access points to all member accounts</h3><p>Owners of the member accounts may find it cumbersome to create the S3 access points themselves, while taking care to choose a specific access point name, etc. To centrally roll out the access points to all member accounts of an Organization, you can use CloudFormation StackSets.</p><p>The idea is that you take a CloudFormation template and roll it out to all members via the Organization management account (or a delegated administrator account). If you want to follow this approach, I created a CloudFormation template for you <a href="https://gist.github.com/michael-kirchner-at/a900fe5d13a1e68e2bfdc0ce9eb0d728">here</a>.</p><p>You can choose to deploy the template to all member accounts of your Organization or only to certain OUs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/745/1*wyEIiaWf59lG8syFpULgnQ.png" /></figure><p>After a while, you will see the finished deployments to your member accounts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/622/1*NEy6cVL6RWjcDfbhJWTFsA.png" /></figure><p>If you desire, you may also use Service Control Policies (SCPs) to prevent member accounts from deleting the access points again (and thus reduce potential load for support desks).</p><h3>Benefits of the solution</h3><ul><li>No duplication of logging activities and log storage, leading to reduced charges for the S3 and CloudTrail services.</li><li>Owners of the member accounts can decide individually who or what within their account should be allowed to access their CloudTrail data: S3 access points have a resource-based policy that works just like an S3 bucket policy. Administrators can adapt the access point policy without requiring coordination with the central team.</li><li>The solution only grants read access to the CloudTrail data of the individual member accounts. If a member account gets compromised, it’s not possible to delete log data or access the CloudTrail data of other accounts.</li></ul><h3>Caveats of the solution</h3><ul><li>The centralized CloudTrail S3 bucket will live in a certain AWS region that the central team needs to decide on. The S3 access points need to be created in the same AWS region as well, which is enforced by AWS. This region may not be the primary region that a certain member account normally uses.</li><li>Member accounts can only see the CloudTrail data that belongs to their own account. What they can see in addition, though, is a list of AWS account IDs on S3 that belong to the same Organization. They cannot see the regions they use, nor the amount of activity, but the account IDs. AWS account IDs are not secret information, but it’s still worth noting.</li><li>S3 access points do not provide the same set of features that regular S3 buckets do. As an example, you cannot configure S3 event notifications that should be triggered each time when a new log object comes in.</li><li>Member accounts are bound to the configuration of the Organization-wide CloudTrail. CloudTrail allows to configure which events should be logged (e.g., management events, data events, KMS activity, etc.). If an individual account owner wants a different logging configuration than the central team has opted for, they need to create their own CloudTrail.</li></ul><p>Coming to an end, I am wishing you happy CloudTrail logging and that’s all for today! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d19833dc6b99" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/sharing-a-single-cloudtrail-across-all-accounts-of-an-aws-organization-d19833dc6b99">Sharing a single CloudTrail across all accounts of an AWS Organization</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Combining memory- and disk-based caching to accelerate AWS Lambda functions]]></title>
            <link>https://awstip.com/combining-memory-and-disk-based-caching-to-accelerate-aws-lambda-functions-872646b3b9ca?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/872646b3b9ca</guid>
            <category><![CDATA[aws-cost-optimization]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws-well-architected]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Wed, 04 Oct 2023 12:49:43 GMT</pubDate>
            <atom:updated>2023-10-05T10:09:18.424Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article shows how you can use the /tmp directory offered by AWS Lambda to speed up function executions and how to use a combined approach of memory-based and disk-based caching.</h4><p>Caching objects and data between Lambda function executions is an often used pattern: as you pay for the time a Lambda function is running, caching not only reduces latency but can also have real impact on your AWS bill. The core idea is that that your functions do not repeatedly fetch the same data from backend systems (e.g., RDS, DynamoDB, S3, etc.), but keep data cached for a while. Subsequent requests for the same data can then be answered without reaching out to the backend systems again.</p><p>The prime location for caching is the memory of a Lambda function. Lambda currently supports between 128 MB and 10240 MB of RAM, which can provide plenty of space for keeping data cached. If you dial up the available memory though, this will also incur higher charges for Lambda execution time. This is not always cost-efficient, especially when your Lambda function is primarily I/O-bound: you then pay more for Lambda execution time, while your function is actually just waiting idle for a backend system to answer.</p><h3>Using the /tmp directory for caching</h3><p>Another storage location available to Lambda functions is the /tmp directory that is provided to each function execution environment. By default, every Lambda comes with 512 MB of space in /tmp that is provided without additional charge. You can configure up to 10240 MB of /tmp space for a function, which is then charged additionally. However, the cost of this storage space is way lower than adding more RAM to a function.</p><p>So can we use /tmp for caching?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/826/1*W76c7I8FFC9q8BNqJ4oGfg.png" /></figure><p>In the following sections, we’ll explore disk-based caching on AWS Lambda, using the diskcache library. It is a Python caching library that uses SQLite to manage data on disk. You can find more information about it here:</p><p><a href="https://github.com/grantjenks/python-diskcache">https://github.com/grantjenks/python-diskcache</a></p><p><a href="https://grantjenks.com/docs/diskcache/tutorial.html">https://grantjenks.com/docs/diskcache/tutorial.html</a></p><h3>The test setup</h3><p>All tests conducted were run in an AWS Lambda function, x86 architecture, Python 3.11, with 256 MB of RAM configured and using the default emphemeral /tmp space with 512 MB.</p><p>To test diskcache with Lambda’s /tmp and to see which access times we should expect, we can use the following example code:</p><pre>import diskcache<br>import random<br>import string<br>import time<br><br><br>CACHE_ENTRY_TTL_SECONDS = 300<br>CACHE_SIZE_MB = 450<br>NUMBER_OF_CACHE_ENTRIES_TO_TEST = 100000<br><br><br># Initialize disk cache<br>cache = diskcache.Cache(<br>    size_limit=CACHE_SIZE_MB * 1024 * 1024,<br>    eviction_policy=&quot;least-recently-used&quot;,<br>    directory=&quot;/tmp&quot;,<br>    sqlite_synchronous=0,<br>)<br><br><br>def lambda_handler(event, context):<br>    # Generate test data that will be written to and read from the cache<br>    alphabet = string.ascii_uppercase + string.ascii_lowercase + string.digits<br>    seeded_random = random.Random(0)<br>    cache_test_data = {}<br>    for _ in range(0, NUMBER_OF_CACHE_ENTRIES_TO_TEST):<br>        cache_key = &quot;&quot;.join(seeded_random.choice(alphabet) for _ in range(16))<br>        cache_value = &quot;&quot;.join(seeded_random.choice(alphabet) for _ in range((seeded_random.randint(1, 1024))))<br>        cache_test_data[cache_key] = cache_value<br><br>    # Test cache writes<br>    start = time.time()<br>    for key in cache_test_data:<br>        cache.set(key, cache_test_data[key], expire=CACHE_ENTRY_TTL_SECONDS)<br>    end = time.time()<br>    print(&quot;Writes: {:.2f} seconds&quot;.format(end - start))<br><br>    # Test cache reads<br>    cache_test_data = list(cache_test_data.keys())<br>    seeded_random.shuffle(cache_test_data)<br>    start = time.time()<br>    for key in cache_test_data:<br>        cache.get(key)<br>    end = time.time()<br>    print(&quot;Reads: {:.2f} seconds&quot;.format(end - start))</pre><p>The code generates 100000 random key-value pairs that are first put into the cache and then read again from there. Cache keys consist of 16 characters, which in practice could represent object IDs, customer IDs or similar. Cache values have a random length between 1 and 1024 characters. Keep the following in mind about the test code:</p><ul><li>With 100000 test entries we will not actually fill the entire defined cache size of 450 MB. Cache entries will also not hit their defined TTL of 300 seconds. This means that cache evictions will not happen during this test. Overall, this is okay, because we are rather interested in getting a rough picture of access times to be expected.</li><li>Cache entries are read in a different order than they were written, to mimic random access.</li><li>Regarding the sqlite_synchronous=0 setting, the SQLite documentation states: “<em>If the application running SQLite crashes, the data will be safe, but the database might become corrupted if the operating system crashes or the computer loses power before that data has been written to the disk surface. On the other hand, commits can be orders of magnitude faster with synchronous OFF.</em>” (<a href="https://www.sqlite.org/pragma.html">https://www.sqlite.org/pragma.html</a>) For AWS Lambda, the storage space in /tmp is anyhow ephemeral. If the OS or hardware underneith a Lambda function has an issue, we lose access to the cache anyhow. Setting this flag is thus fine to gain performance benefits.</li></ul><p>When running the above code on Lambda, we get the following output:</p><pre>Writes: 164.38 seconds<br>Reads: 155.02 seconds</pre><p>At a first glance, these numbers seem quite high. But keep in mind: AWS Lambda assigns CPU resources in proportion to the amount of memory we assign to a Lambda function. With 256 MB of RAM configured, our test scenario only runs on a fraction of a vCPU. If we assigned more RAM, execution would be faster and numbers would get lower. But that’s not the idea here. Instead, we want to explore disk-based caching for Lambda functions with low RAM configurations.</p><p>After the code ran, we can also have a look into the SQLite file that is used for cache persistence and see the test data:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/965/1*q58F74McwwhNyYAAeaZljQ.png" /></figure><h3>Comparing the results to memory-based caching</h3><p>To get a comparison to memory-based caching, we make use of the popular cachetools library and it’s TTLCache class. We adapt the code used above to the following:</p><pre>import cachetools<br>import random<br>import string<br>import sys<br>import time<br><br><br>CACHE_ENTRY_TTL_SECONDS = 300<br>CACHE_SIZE_MB = 100<br>NUMBER_OF_CACHE_ENTRIES_TO_TEST = 100000<br><br><br># Initialize memory cache<br>cache = cachetools.TTLCache(<br>    maxsize=CACHE_SIZE_MB * 1024 * 1024, <br>    ttl=CACHE_ENTRY_TTL_SECONDS, <br>    getsizeof=sys.getsizeof<br>)<br><br><br>def lambda_handler(event, context):<br>    # Omitted for brevity. Uses the same logic as the previously listed code.<br>    # [...]</pre><p>We select a smaller cache size of 100 MB, to still play nice with our Lambda function that has 256 MB of RAM available. But we keep the rest of the test logic the same, like generating 100000 random key-value pairs that are first cached and then read again. When running the code, the following result is returned:</p><pre>Writes: 3.80 seconds<br>Reads: 1.62 seconds</pre><h3>Interpreting the results</h3><p>If we only look at the amount of time required for cache reads (and reads will hopefully occur much more often than writes), we can see that memory-based caching is roughly 100 times faster than our disk-based scenario. Please take this number only as a rough ballpark figure though, because it can be influenced by many factors:</p><ul><li>Random vs. sequential access</li><li>The size of items cached</li><li>Hardware properties</li><li>Some pages of the SQLite database being actually held in memory</li><li>Lambda tech stack details regarding /tmp that we don’t know about</li><li>…</li></ul><p>It’s safe to conclude though that disk-based caching will be slower than memory-based caching, while being able to provide more storage space at a much lower cost.</p><p>The results should not be interpreted in a way that disk-based caching is too slow in general: In our test, reading 100000 items from the cache has taken 155.02 seconds. So reading one item from the cache took, on average, 0.0016 seconds, or roughly 2 milliseconds. That’s still way faster than talking to RDS or S3 over the network to re-fetch data.</p><h3><strong>Combining both approaches</strong></h3><p>Only using a disk-based cache is possible, but we would give up the speed benefits of memory-based caching entirely. Instead, we can go for a combined approach, where we cache items both in memory and on disk. The memory-based cache will be smaller and thus evict items earlier. The disk-based cache has more space available and will still hold data that was already evicted from memory.</p><p>The following code shows how this combined approach can be used on Lambda:</p><pre>import cachetools<br>import diskcache<br>import sys<br><br><br>CACHE_ENTRY_TTL_SECONDS = 300<br>MEMORY_CACHE_SIZE_MB = 100<br>DISK_CACHE_SIZE_MB = 450<br><br><br># Initialize memory cache<br>memory_cache = cachetools.TTLCache(<br>    maxsize=MEMORY_CACHE_SIZE_MB * 1024 * 1024,<br>    ttl=CACHE_ENTRY_TTL_SECONDS,<br>    getsizeof=sys.getsizeof,<br>)<br><br># Initialize disk cache<br>disk_cache = diskcache.Cache(<br>    size_limit=DISK_CACHE_SIZE_MB * 1024 * 1024,<br>    eviction_policy=&quot;least-recently-used&quot;,<br>    directory=&quot;/tmp&quot;,<br>    sqlite_synchronous=0,<br>)<br><br># Initialize cache stats<br>cache_stats = {<br>    &quot;memory_cache_hits&quot;: 0,<br>    &quot;memory_cache_misses&quot;: 0,<br>    &quot;disk_cache_hits&quot;: 0,<br>    &quot;disk_cache_misses&quot;: 0,<br>}<br><br><br>def put_cache_entry(key, value):<br>    memory_cache[key] = value<br>    disk_cache.set(key, value, expire=CACHE_ENTRY_TTL_SECONDS)<br><br><br>def get_cache_entry(key):<br>    try:<br>        value = memory_cache[key]<br>        cache_stats[&quot;memory_cache_hits&quot;] += 1<br>        return value<br>    except KeyError:<br>        cache_stats[&quot;memory_cache_misses&quot;] += 1<br>        try:<br>            value = disk_cache[key]<br>            cache_stats[&quot;disk_cache_hits&quot;] += 1<br>            return value<br>        except KeyError:<br>            cache_stats[&quot;disk_cache_misses&quot;] += 1<br>            raise<br><br><br>def lambda_handler(event, context):<br>    # Your function logic and caching calls go here:<br>    # Cache an item via &quot;put_cache_entry(...)&quot;<br>    # Get a cached item via &quot;get_cache_entry(...)&quot;<br>    #   raises KeyError if the item is neither found in memory nor on disk<br><br>    print(cache_stats)</pre><p>The code defines a memory-based cache with 100 MB and a disk-based cache with 450 MB in size. These are, unfortunately, only approximate size limits: the getsizeof function of the memory-based cache will only measure the size of the cache values and not of the cache keys. SQLite will also write a WAL file, besides the actual database file. Memory that is not used any more may not be freed immediately. You get the idea.</p><p>Both caches use a TTL per cache entry and evict items based on LRU (least recently used), in case their defined maximum cache size should be reached. The code also collects some basic statistics on cache usage.</p><p>As always, it’s important to monitor how your caches perform in practice and to tweak their usage and sizes, if needed. Here are two examples that you might encounter in your statistics:</p><ul><li>If you see that there are barely any memory_cache_hits nor disk_cache_hits, then your cache sizes may be too small or you are dealing with quite diverse data where there is hardly ever a second request for the same thing. Also check whether your TTL is too low.</li><li>If you see that there are many memory_cache_hits, but barely any disk_cache_hits, then you likely don’t need a combined caching approach: you can then leave away the disk cache entirely and save yourself the time penalty of writing items to disk.</li></ul><h3>Wrap-up</h3><p>I hope this article gave you a good understanding of how disk-based caching works in connection with AWS Lambda and how you can combine it with memory-based caching to get benefits of both worlds. Disk-based caching can provide significant amounts of additional caching space at a much lower price, when compared to memory. As an example, a Lambda function with only 128 MB of RAM can cache up to 10 GB of data on /tmp.</p><p>The price you need to pay for disk-based caching are slower access times. But overall, those access times should still be much faster than re-fetching data from your source systems.</p><p>Happy caching and that’s all for today! :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=872646b3b9ca" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/combining-memory-and-disk-based-caching-to-accelerate-aws-lambda-functions-872646b3b9ca">Combining memory- and disk-based caching to accelerate AWS Lambda functions</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ten recommendations for when you access customer AWS accounts]]></title>
            <link>https://awstip.com/ten-recommendations-for-when-you-access-customer-aws-accounts-b25edd3a2103?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/b25edd3a2103</guid>
            <category><![CDATA[aws-well-architected]]></category>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-iam]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 18:08:43 GMT</pubDate>
            <atom:updated>2023-08-28T09:34:26.323Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article offers a collection of recommendations and best practices you can follow when your customer trusts you or your SaaS product with access to their AWS environments.</h4><p>I regularly do security reviews of AWS accounts and part of the review is a thorough analysis of the IAM setup. During this I get some insight into which external entities customers grant access, be it SaaS tools, contractors or companies providing AWS development support. The ways how access is implemented and which security mechanisms are used do vary. What all scenarios have in common is that they cross a trust boundary: an external entity accesses a customer account.</p><p>This article provides security recommendations if you are such an external entity, like a contractor or a provider of a SaaS service. It will very likely not make sense to follow all of these recommendations. Instead, they should serve as a reference and source of ideas to further secure your overall setup — and ideally reduce the risk for your customer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LRGSiFlzNV1U3FNoXbIN1Q.png" /></figure><h3>1. Ask for IAM roles instead of long-term access</h3><p>There are two primary ways to access customer AWS accounts: IAM users and IAM roles. With IAM users, you either get username and password (for Console UI access) or long-term API access keys. Both bring the challenge that you now have a piece of secret information that needs to be protected. This entails encrypted storage, implementing access control mechanisms, etc. You may also not have the necessary permissions to change your password or API key information on your own, in case there was a security mishap. (It depends on the level of access the customer gave you: read-only access, for example, won’t be enough.)</p><p>Using IAM roles instead allows you to establish a trust relationship between two AWS accounts. A customer allows you to access their AWS environment from an AWS account that you control. There are no spearate passwords or API keys to be managed. The security ties back to those mechanisms that you use to control access to your own AWS account (e.g., login only via SSO, regular review of access permissions, etc.).</p><p>When you assume an IAM role in a customer account, this also has the advantage that the access credentials that are used during this procedure are temporary. The credentials lose their value after a maximum of 12 hours (by default, it’s one hour). So in case of an unintentional exposure of credentials (for example, because you increased the log level for debugging and all of a sudden you see credentials in your application logs), the information loses value quickly.</p><h3>2. If there is no other way than long-term access, explore using federation tokens</h3><p>If you are stuck with using IAM users and cannot change the situation, there is still a mechanism how you can create temporary sessions out of long-term IAM credentials. The AWS STS API provides a functionality called GetFederationToken:</p><p><a href="https://docs.aws.amazon.com/STS/latest/APIReference/API_GetFederationToken.html">https://docs.aws.amazon.com/STS/latest/APIReference/API_GetFederationToken.html</a></p><p>The feature is similar to assuming a role and many mechanisms described in this article are also supported by GetFederationToken. The core idea here is that you don’t use your long-term credentials to actually perform work in a customer AWS account. Instead, you only use them to request temporary credentials, which are then used to perform the actual work. There are two things to keep in mind with this:</p><ul><li>Your long-term access keys need to be granted permissions to call sts:GetFederationToken. Read-only permissions will not be sufficient.</li><li>Temporary credentials created this way unfortunately do not have access to the AWS IAM API. For SaaS security products, this is quite likely a deal breaker.</li></ul><h3>3. Ask for limited permissions in the first place</h3><p>I made the experience that some customers can be incredibly trusting when it comes to granting you access to their AWS environment. If they set up your access, they grant you Administrator privileges in the account. That’s of course an honor and a sign of trust, but some tasks (such as my security reviews) simply don’t need that level of access.</p><p>Following the principle of least privilege, it’s a good idea to ask the customer from the very beginning to only grant those permissions that you require. If you are tasked with building a solution, there is nothing wrong with Administrator access. Carving out a granular set of permissions can also be a lot of work (and change over time). But if you can limit yourself to some coarse-grained boundaries, this can already be an improvement.</p><h3>4. Make use of session policies to scope down permissions</h3><p>Having in mind the last item, there is a mechanism to voluntarily reduce your level of access when assuming a role in a customer account (or using sts:GetFederationToken): session policies. These are regular IAM policies written in JSON that you send along in the API call towards STS. Instead of a custom IAM policy, you can also refer to a managed IAM policy ARN. The idea behind session policies is the following: the temporary credentials that STS will send you back only allow the intersection of the permissions that the role has and the permissons that your session policy specifies.</p><p>Sticking with the example that a customer granted you Administrator permissions in their account via an IAM role, you can assume this role while also specifying a session policy:</p><pre>sts_client = boto3.client(&quot;sts&quot;)<br><br>sts_response = sts_client.assume_role(<br>    RoleArn=&quot;arn:aws:iam::112233445566:role/RoleInCustomerAccount&quot;,<br>    RoleSessionName=&quot;michael.kirchner@welldone.cloud&quot;,<br>    PolicyArns=[{&quot;arn&quot;: &quot;arn:aws:iam::aws:policy/ReadOnlyAccess&quot;}],<br>)</pre><p>The policy referred to in <em>PolicyArns </em>is the session policy. In this case, it points to the AWS-managed IAM policy for read-only access. The temporary credentials that STS delivers back will thus be limited to read-only actions. You can get much more fine-grained here with what your session should be allowed to do. The CloudTrail logs in the customer account will also show that you made use of this feature and what the policy data was.</p><p>Session policies are particularly useful for SaaS products. Your software may consist of several components that need to perform different tasks in a customer AWS account. Instead of trusting each of those components with full access to the role in the customer account, you can implement an internal service/broker. Its task is to hand out scoped-down credentials depending on what a specific component needs.</p><p>The larger and more complex your SaaS product becomes, the more useful this design gets. In case one of your components has a security mishap and session credentials leak, the potential customer impact will stay limited to those actions that were allowed in the particular session policy.</p><h3>5. Scope down where credentials can be used from</h3><p>This recommendation makes use of session policies as well. It is mostly relevant for SaaS products where you already know from which IP address(es) you will send requests towards a customer AWS account. As an example, consider a scenario where a part of your product runs on EC2 or Fargate, either with a public IP address or behind a NAT Gateway. In both cases you will know the source IP address your requests will come from when communicating with the customer AWS account.</p><p>This means that, for example, an EC2 instance can dynamically look up its public IP address and include it in the session policy during the sts:AssumeRole call. The resulting credentials will deny requests that do not originate from the instances own and expected IP address:</p><pre>sts_client = boto3.client(&quot;sts&quot;)<br><br>sts_response = sts_client.assume_role(<br>    RoleArn=&quot;arn:aws:iam::112233445566:role/RoleInCustomerAccount&quot;,<br>    RoleSessionName=&quot;MySaaSProduct&quot;,<br>    PolicyArns=[{&quot;arn&quot;: &quot;arn:aws:iam::aws:policy/ReadOnlyAccess&quot;}],<br>    Policy=&quot;&quot;&quot;<br>        {<br>            &quot;Version&quot;: &quot;2012-10-17&quot;,<br>            &quot;Statement&quot;: [<br>                {<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;NotIpAddress&quot;: {&quot;aws:SourceIp&quot;: [&quot;11.22.33.44/32&quot;]},<br>                        &quot;Bool&quot;: {&quot;aws:ViaAWSService&quot;: &quot;false&quot;}<br>                    }<br>                }<br>            ]<br>        }<br>    &quot;&quot;&quot;.strip(),<br>)</pre><p>If you use Bring Your Own IP Address (BYOIP) on AWS, you may also restrict credential validity to your network range, instead of individual IP addresses.</p><p>The <em>aws:SourceIP</em> condition also supports IPv6 addresses. But it is worth checking upfront whether the AWS service you want to talk to (on behalf of your customer) already supports IPv6:</p><p><a href="https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html">https://docs.aws.amazon.com/vpc/latest/userguide/aws-ipv6-support.html</a></p><h3>6. Set a time limit on credential validity</h3><p>Session credentials are already temporary in nature. If you don’t specify any validity period, credentials will expire after one hour. The maximum validity period is 12 hours. During the sts:AssumeRole API call you can also specify shorter periods, with a minimum of 15 minutes (=900 seconds). This comes in handy when your SaaS product only needs to do a quick and simple task within the customer account.</p><pre>aws sts assume-role \<br>--role-arn arn:aws:iam::112233445566:role/RoleInCustomerAccount \<br>--role-session-name MySaaSProduct \<br>--duration-seconds 900</pre><p>You can also go shorter than 900 seconds by adding a session policy statement that refers to a specific date and time boundary. As an example, you can deny requests after a certain point in time, using the <em>DateGreaterThan</em> condition key:</p><pre>{<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;DateGreaterThan&quot;: {&quot;aws:CurrentTime&quot;: &quot;2023-08-27T09:10:31Z&quot;}<br>    }<br>}</pre><p>However, I’d recommend not to overdo this: your SaaS application may need to perform API call retries, it may be slower than usual because of currently high demand, etc. If you use an internal service/broker to vend credentials (as described above), it will also take some time until the consumer component will actually use them, etc.</p><h3>7. Use an external ID</h3><p>The requirement to use an external ID already needs to be specified when the customer creates the IAM role for you in their AWS account. As an example, the following trust policy may be configured on the IAM role:</p><pre>{<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;: &quot;sts:AssumeRole&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;AWS&quot;: &quot;998877665544&quot;<br>            },<br>            &quot;Condition&quot;: {<br>                &quot;StringEquals&quot;: {<br>                    &quot;sts:ExternalId&quot;: &quot;GZEqWHz4y&quot;<br>                }<br>            }<br>        }<br>    ]<br>}</pre><p>The trust policy sets forth that principals from your account <em>998877665544 </em>can assume this role, but only if they specify the value <em>GZEqWHz4y </em>as an external ID. Not providing an external ID, or sending a wrong ID value, will prevent the principal from being able to assume the role:</p><pre>aws sts assume-role \<br>--role-arn arn:aws:iam::112233445566:role/RoleInCustomerAccount \<br>--role-session-name MySaaSProduct \<br>--external-id wrongValueHere<br><br>An error occurred (AccessDenied) when calling the AssumeRole operation</pre><p>Using an external ID helps to safeguard against confused deputy problems. An example of this is when a SaaS provider can be convinced to talk to customer A, while in reality they should be talking to customer B. If both customers have different external IDs, the operation will fail. Diving deep into the confused deputy problem is beyond this article, but it is closer described here:</p><p><a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html">https://docs.aws.amazon.com/IAM/latest/UserGuide/confused-deputy.html</a></p><p><a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html">https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-user_externalid.html</a></p><h3>8. Leave a clear reference to your product or to you as a person</h3><p>When your customer goes through internal or external audit, there will be questions coming up on why trusts to external parties were set up and whom they are trusting here. Worse yet, if there is a security incident in a customer account, incident handlers need to quickly judge on account activity seen in CloudTrail and reason whether something is likely benign or not. This all turns out to be way easier and faster if you can clearly see who or what is behind a certain cross-account activity.</p><p>There are different ways how you can leave a recognizable reference to a product or a person in CloudTrail:</p><ul><li>Ask your customer to use a specific IAM role name when they set up your access. That’s an easy solution, but it’s up to the customer on how they want to name an IAM role. SaaS products usually don’t deny service, just because a customer has chosen a different role name than there is written in the documentation.</li><li>Set a role session name. During the sts:AssumeRole call you have to specify a name for the session that will be created for you. You can use it to leave the SaaS product name or an e-mail address:</li></ul><pre>aws sts assume-role \<br>--role-arn arn:aws:iam::112233445566:role/RoleInCustomerAccount \<br>--role-session-name MySaaSProduct</pre><ul><li>Setting a source identity. This is a feature of STS that allows you to specify information about the user or software that is behind a session. This sounds quite similar to the role session name explained above, but has the advantage that the source identity also persists when you chain roles (so when a role assumes another role). CloudTrail not only shows the source identity information in the log entry of the sts:AssumeRole call, but for all other subsequent calls the session makes (for example, ec2:DescribeInstances):</li></ul><pre>aws sts assume-role \<br>--role-arn arn:aws:iam::112233445566:role/RoleInCustomerAccount \<br>--role-session-name MySessionName<br>--source-identity michael.kirchner@welldone.cloud </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/569/1*gImynoVKUeJ6dPDPWyJDcQ.png" /></figure><ul><li>There can be situations where you cannot specify a source identity value. For example, when your source identity information was already set by your IdP when you logged into your own AWS account. Source identity information — once set — cannot be changed any more and persists through role chaining. In these cases you can use a workaround, by specifying session tags. The disadvantage here is that session tags will only be shown in the initial CloudTrail log entry for the sts:AssumeRole call. They will not be shown for subsequent API calls that are made by this session.</li></ul><pre>sts_client = boto3.client(&quot;sts&quot;)<br><br>sts_response = sts_client.assume_role(<br>    RoleArn=&quot;arn:aws:iam::112233445566:role/RoleInCustomerAccount&quot;,<br>    RoleSessionName=&quot;MySessionName&quot;,<br>    Tags=[<br>        {&quot;Key&quot;: &quot;identity&quot;, &quot;Value&quot;: &quot;MySaaSProduct&quot;},<br>    ],<br>    TransitiveTagKeys=[&quot;identity&quot;],<br>)</pre><h3>9. Auto-expire trust relationships for project-based engagements</h3><p>This recommendation primarily addresses consultants and contractors. It is less applicable in SaaS scenarios. For project-based engagements, there is usually a certain point in time when the project is (very likely) finished. When the customer initially sets up your IAM role (or, less ideal, your IAM user), it is possible to already include a time limit in the IAM policy. This time limit should be out far enough so that it will not cause any issues while you are still working on the project. Still, access will auto-expire when it is very likely not needed any more.</p><p>When I conduct a security review for a customer, I ask them to set up an IAM role and to apply a trust policy similar to this:</p><pre>{<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;: &quot;sts:AssumeRole&quot;,<br>            &quot;Principal&quot;: {<br>                &quot;AWS&quot;: &quot;998877665544&quot;<br>            },<br>            &quot;Condition&quot;: {<br>                &quot;StringEquals&quot;: {<br>                    &quot;sts:ExternalId&quot;: &quot;ProjectSpecificValueHere&quot;<br>                },<br>                &quot;DateLessThan&quot;: {<br>                    &quot;aws:CurrentTime&quot;: &quot;2023-12-01&quot;<br>                }<br>            }<br>        }<br>    ]<br>}</pre><p>Even if the customer forgets to remove the IAM role again after the engagement, the trust relationship will be disabled automatically after a while. This way, I also do not create an AWS account that, over time, has paths into many other AWS accounts owned by different entities.</p><h3>10. Keep your source AWS accounts tidied up</h3><p>When customers create an IAM role that can be assumed from your source account, they put a certain degree of trust into either you or your SaaS product. You are crossing a trust boundary and customers cannot see who has access to your accounts, nor what or how you operate in there.</p><p>To keep risk low, don’t run any test setups in your source accounts. Avoid that several dozens of people can log into them. Keep network exposure limited. Or to keep it short: treat them as production accounts.</p><p>To wrap it up, I hope that you got some inspiration on how you can further secure the AWS trust relationship between you and your customer. Leave a comment if you’d like to recommend any additional measures. Thank you and that’s all for today :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b25edd3a2103" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/ten-recommendations-for-when-you-access-customer-aws-accounts-b25edd3a2103">Ten recommendations for when you access customer AWS accounts</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linting AWS IAM policies]]></title>
            <link>https://awstip.com/linting-aws-iam-policies-e76b95859c93?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e76b95859c93</guid>
            <category><![CDATA[aws-well-architected]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-security]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Mon, 14 Aug 2023 17:58:56 GMT</pubDate>
            <atom:updated>2023-08-15T11:40:14.462Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article shows you how you can check whether your AWS IAM policies violate security best practices or contain errors — at scale.</h4><p>No matter in which way you are using AWS, there is a topic you will likely not get around: identity and access management. AWS IAM allows you to define identities (e.g., for human users, EC2 instances or Lambda functions) and to grant them permissions. Expressing permissions works via the IAM JSON policy language. The language is quite expressive and allows to implement very nuanced permission requirements. This feature richness can come with a certain complexity (just look at the <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html#policy-eval-denyallow">picture here</a>) and so it’s important to ensure that your policies actually implement what you wanted to express when writing them.</p><h3>Examples of policy mistakes</h3><p>Let’s look at the following real-world example of a service control policy (SCP). It was designed to disallow certain API calls within member accounts of an AWS Organization. Can you spot the issue?</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Sid&quot;: &quot;DenyReservations&quot;,<br>      &quot;Effect&quot;: &quot;Deny&quot;,<br>      &quot;Action&quot;: [<br>        &quot;ec2:PurchaseReservedInstancesOffering&quot;,<br>        &quot;ec2:CreateCapacityReservation&quot;,<br>        &quot;savingsplans:CreateSavingsPlans&quot;,<br>        &quot;rds:PurchaseReservedDBInstancesOffering&quot;,<br>        &quot;elasticache:PurchaseReservedCacheNodesOffering&quot;,<br>        &quot;redshift:PurchaseReservedNodeOffering&quot;,<br>        &quot;dynamodb:PurchaseReservedCapacityOfferings&quot;<br>      ],<br>      &quot;Resource&quot;: &quot;*&quot;<br>    }<br>  ]<br>}</pre><p>The issue here is that an API action with the name “CreateSavingsPlans” does not exist at the AWS Savings Plans service. Instead, the API action is called “CreateSavingsPlan” (without the additional “s” at the end). This means that member accounts affected by this SCP in practice did not face any restrictions when working with the AWS Savings Plans API.</p><p>Let’s look at another example. Consider the following IAM policy that should prevent the principal it is attached to from deleting objects that are stored in an S3 bucket. What’s the issue here?</p><pre>{<br>  &quot;Version&quot;: &quot;2012-10-17&quot;,<br>  &quot;Statement&quot;: [<br>    {<br>      &quot;Effect&quot;: &quot;Deny&quot;,<br>      &quot;Action&quot;: &quot;s3:DeleteObject&quot;,<br>      &quot;Resource&quot;: &quot;arn:aws:s3:::cloudtrail-logs-112233445566&quot;<br>    }<br>  ]<br>}</pre><p>The problem with this policy is that the “DeleteObject” operation applies to resources of the type <em>object</em>. However, the “Resource” part of the policy actually refers to a <em>bucket </em>and not to an <em>object</em>. This means that this policy does not have any effect, because “Action” and “Resource” do not fit together. To achieve what the policy author likely wanted to express, the “Resource” part of the policy would need to read like this:</p><pre>&quot;arn:aws:s3:::cloudtrail-logs-112233445566/*&quot;</pre><h3>Policy linting to the rescue</h3><p>AWS traditionally is not all too strict when it comes to preventing you from saving IAM policies that contain errors or have potential security issues. The level of policy validation applied differs from service to service. As an example, AWS S3 prevents you from saving a bucket policy if the resource ARN refers to a different bucket. It does not prevent you though from using condition keys that don’t make sense in bucket policies.</p><p>It’s thus a good idea to apply linting checks that specifially search for issues in IAM policies. An early project in this space was <a href="https://github.com/duo-labs/parliament">parliament</a>, but AWS later also released their own <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-validation.html">policy validation feature</a> as part of AWS IAM Access Analyzer. This feature is mostly known for showing recommendations when manually editing IAM policies on the AWS Console UI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*YArxtyzEhKPvn5v75U4VOg.png" /></figure><p>The list of issues it can detect has grown over time and you can check it out <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-reference-policy-checks.html">here</a>. Overall, the feature is great, but there are some limitations to it:</p><ul><li>Only some of the policy editors on the AWS Console UI currently integrate with the policy validation feature. If you, for example, edit an IAM policy or an S3 bucket policy, you will immediately see the recommendations while typing. If you edit an SQS queue policy or a VPC endpoint policy, you won’t.</li><li>If you are using infrastructure as code (which you should), the warnings will not be shown to you during deployment.</li><li>There is currently no feature to retroactively lint already existing policies that are used within an AWS account or an entire AWS Organization.</li></ul><h3>Introducing aws-lint-iam-policies</h3><p>To make use of the AWS IAM Access Analyzer policy validation feature at scale, I created the <em>aws-lint-iam-policies</em> tool, which you can find here:</p><p><a href="https://github.com/welldone-cloud/aws-lint-iam-policies">https://github.com/welldone-cloud/aws-lint-iam-policies</a></p><p>It runs IAM policy linting checks against either a single AWS account or all accounts of an AWS Organization. It reads all policies of supported policy types (currently: 34) from an AWS account and uses the IAM Access Analyzer API to analyze them. Discovered errors, security issues and recommendations are written to a JSON output file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/482/1*XJgMmalro64YBoaTokfMWQ.png" /></figure><p>Linting the existing IAM policies of a single AWS account is as simple as:</p><pre>pip install -r requirements.txt<br>python aws_lint_iam_policies.py --scope ACCOUNT</pre><p>Here is an example result:</p><pre>{<br>  &quot;_metadata&quot;: {<br>    &quot;invocation&quot;: &quot;aws_lint_iam_policies.py --scope ACCOUNT&quot;,<br>    &quot;principal&quot;: &quot;arn:aws:iam::123456789012:user/user1&quot;,<br>    &quot;run_timestamp&quot;: &quot;20230729093927&quot;,<br>    &quot;scope&quot;: &quot;ACCOUNT&quot;,<br>    &quot;errors&quot;: [],<br>    &quot;account_id&quot;: &quot;123456789012&quot;<br>  },<br>  &quot;results_grouped_by_account_id&quot;: {<br>    &quot;123456789012&quot;: [<br>      {<br>        &quot;account_id&quot;: &quot;123456789012&quot;,<br>        &quot;region&quot;: &quot;us-east-1&quot;,<br>        &quot;resource_type&quot;: &quot;AWS::IAM::UserPolicy&quot;,<br>        &quot;resource_name&quot;: &quot;inlinepolicy&quot;,<br>        &quot;resource_arn&quot;: &quot;arn:aws:iam::123456789012:user/user1&quot;,<br>        &quot;policy_type&quot;: &quot;IDENTITY_POLICY&quot;,<br>        &quot;finding_type&quot;: &quot;SECURITY_WARNING&quot;,<br>        &quot;finding_issue_code&quot;: &quot;PASS_ROLE_WITH_STAR_IN_RESOURCE&quot;,<br>        &quot;finding_description&quot;: &quot;Using the iam:PassRole action with wildcards (*) in the resource can be overly permissive because it allows iam:PassRole permissions on multiple resources. We recommend that you specify resource ARNs or add the iam:PassedToService condition key to your statement.&quot;,<br>        &quot;finding_link&quot;: &quot;https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-reference-policy-checks.html#access-analyzer-reference-policy-checks-security-warning-pass-role-with-star-in-resource&quot;<br>      },<br>      {<br>        &quot;account_id&quot;: &quot;123456789012&quot;,<br>        &quot;region&quot;: &quot;eu-central-1&quot;,<br>        &quot;resource_type&quot;: &quot;AWS::SQS::QueuePolicy&quot;,<br>        &quot;resource_name&quot;: &quot;queue1&quot;,<br>        &quot;resource_arn&quot;: &quot;arn:aws:sqs:eu-central-1:123456789012:queue1&quot;,<br>        &quot;policy_type&quot;: &quot;RESOURCE_POLICY&quot;,<br>        &quot;finding_type&quot;: &quot;WARNING&quot;,<br>        &quot;finding_issue_code&quot;: &quot;MISSING_VERSION&quot;,<br>        &quot;finding_description&quot;: &quot;We recommend that you specify the Version element to help you with debugging permission issues.&quot;,<br>        &quot;finding_link&quot;: &quot;https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-reference-policy-checks.html#access-analyzer-reference-policy-checks-general-warning-missing-version&quot;<br>      }<br>    ]<br>  },<br>  &quot;results_grouped_by_finding_category&quot;: {<br>    &quot;SECURITY_WARNING&quot;: {<br>      &quot;PASS_ROLE_WITH_STAR_IN_RESOURCE&quot;: [<br>        // Truncated for brevity<br>      ]<br>    },<br>    &quot;WARNING&quot;: {<br>      &quot;MISSING_VERSION&quot;: [<br>        // Truncated for brevity<br>      ]<br>    }<br>  }<br>}</pre><p>If you instead want to analyze all accounts of an AWS Organization, you will need to provide an IAM role that can be assumed in each member account: the documentation on GitHub has the details.</p><p>Give it a try, look at the results and see whether there are any surprises in your environment. Happy linting and keeping your AWS environments secure! And that’s all for today :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e76b95859c93" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/linting-aws-iam-policies-e76b95859c93">Linting AWS IAM policies</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Detecting AWS cost spikes for central teams]]></title>
            <link>https://awstip.com/detecting-aws-cost-spikes-for-central-teams-38b6313e2244?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/38b6313e2244</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-well-architected]]></category>
            <category><![CDATA[aws-cost-optimization]]></category>
            <category><![CDATA[aws-cost-management]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Fri, 09 Jun 2023 12:21:01 GMT</pubDate>
            <atom:updated>2023-06-10T12:42:35.721Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article shows you two methods how central teams can receive warnings about AWS accounts where costs are about to spike — before the monthly bill comes in.</h4><p>The number of AWS accounts used in a typical organization is rising and that’s a good thing: an AWS account is a strong security boundary, so having multiple of them reduces the blast radius in case things go wrong. Multiple accounts also allow for a clean separation between projects and their <em>dev</em>, <em>test </em>and <em>prod </em>environments. They usually also make IAM setups easier, as there is less need to separate principals and resources from each other that should not be able to step on each other’s toes.</p><p>In such a multi-account setup, different teams and parts of an organization are responsible for different AWS accounts — which also includes the costs incurred in those accounts. Teams may set up <a href="https://docs.aws.amazon.com/cost-management/latest/userguide/budgets-managing-costs.html">alerts in AWS Budgets</a> or create <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/monitor_estimated_charges_with_cloudwatch.html">Billing alarms</a> for accounts under their responsibility. That’s a good idea, as it happens easily that some tests are left running, a script goes wild, etc.</p><p>Still, central entities such as Cloud Center of Excellence teams or finance teams often want to receive an early warning as well if an AWS account starts to incur much higher costs than usual. They can then act as a second line of defense. This article focuses on their use case.</p><h3>Using AWS Cost Anomaly Detection</h3><p>The two methods presented are making use of the <a href="https://docs.aws.amazon.com/cost-management/latest/userguide/manage-ad.html">AWS Cost Anomaly Detection service</a>. It is designed to detect and alarm on unusual spend patterns in AWS accounts and can also be used in single account scenarios. We will use the service to send e-mail alerts to a defined mailbox, but it can also be configured to send notifications via SNS — and thus integrates with many chat-based services, ticketing systems, etc.</p><p>The AWS Cost Anomaly Detection service itself is free of charge. To deploy the methods presented, you will need access to the management account of an AWS Organization.</p><h3>Method 1: Create an “AWS Services cost monitor” in the Organizations management account</h3><p>This method is simple and can be set up quickly. It comes with the drawback though that it is less accurate, which we will further discuss below.</p><p>AWS Cost Anomaly Detection allows you to create a cost monitor of the type “AWS Services”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/281/1*xxmS9kjdJBi6EUo8EmNmtw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/825/1*RQAMRrIrx295RAl69bc-6Q.png" /></figure><p>The monitor will track total service spend across all member accounts of an Organization. This comes with the advantage that it analyzes costs on a per-service level. So if, for example, your Organizations’ spend for S3 gets lower, but the costs for EC2 rise abnormally, this will still trigger an alert.</p><p>You may be asking yourself why you would not choose the “Linked Account” monitor type shown in the screenshot above. The reason is the following: currently you can only select a maximum of 10 linked accounts and you also need to explicitly select the individual accounts to monitor, which will not scale when growing.</p><p>When creating the cost monitor, you can select which e-mail address should be notified and under which cost anomaly situations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/646/1*2cyXUhVpri-4j_LVuehrCw.png" /></figure><p>And that’s basically all there is for this method. In many sitiations, this solution will suffice and hopefully prevent billing surprises. So what is the drawback that was mentioned previously?</p><p>The created monitor analyzes service spend across all member accounts of an Organization. We rely on the assumption that the Organizations’ total cost for a service will rise when there is a cost anomaly within an account. There can be situations though where costs cancel each other out: if, for example, member account A has managed to lower their EC2 costs by choosing more adequate instance types, but member account B has a mishap, the total EC2 cost may still be roughly the same and keep the anomaly detector happy. This is where method two comes in.</p><h3>Method 2: Centrally orchestrate the deployment of cost monitors to each member account</h3><p>This method has higher complexity than the previous one, but ticks all of the following boxes:</p><ul><li>It is deployed centrally from the Organizations management account. It uses the StackSets feature of AWS CloudFormation to deploy a cost monitor into each member account. We thus get tailored and individual anomaly detection that works on a per-account, per-service basis. This avoids the discussed effects that cost movements could cancel each other out.</li><li>The StackSets feature ensures that the solution is rolled out automatically when new accounts are added to an Organization. It is also possible to limit the rollout to certain Organizational Units (OUs) or individual accounts.</li><li>We are using Service Control Policies (SCPs) so that individual account owners cannot directly modify or delete the cost monitors and the associated CloudFormation stacks.</li><li>Owners of the member accounts can make use of the centrally created cost monitors as well: they can add themselves as alarm recipients (and also use different alarm thresholds, if they wish)</li></ul><p>To apply this method, you can make use of <a href="https://gist.github.com/michael-kirchner-at/d8fd9fbd46fc1c497a50c19f341dd5cc">this ready-made CloudFormation template</a> and deploy it via CloudFormation StackSets in the Organization management account (using region <em>us-east-1</em>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/253/1*Cme64NvIGEost-YYJ3OIXg.png" /></figure><p>If you want to protect the created resources via SCPs, it is important that you choose a uniform name and stack tag when rolling out the CloudFormation stack. In this example, we will use <em>central-cost-monitoring</em>, but you can use any identifier as long as you use the same in the SCP.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/660/1*-0F6Gh3yyhiGA8uvyw1C8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/710/1*u2oB9nxgijtn6ubVAyBZ5A.png" /></figure><p>In this example, we deploy the solution to the entire Organization, instead of individual OUs. You need to specify <em>us-east-1 </em>as the target region, because this is where the AWS Cost Anomaly Detection service is located:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/639/1*7lydx0-SDKTsfOxo82Me4A.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/644/1*Ccq_vPp7ffWxGjsvmudEkQ.png" /></figure><p>After a few moments (depending on the size of your Organization), you should see that the stack was successfully rolled out to your member accounts. Each account now has their individual AWS Cost Anomaly Detection monitor set up, with a central e-mail recipient for alarms:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/542/1*vhhxrnQCVPMRJwpljoG4kA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/1*kas-mezKgkLwanQk23IhKw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/907/1*_v9fEKf2R7qlaPnOKprjYw.png" /></figure><p>If you wish to protect the deployed resources from unaware deletion or modification by account owners, you can use <a href="https://gist.github.com/michael-kirchner-at/4873f46d800d077733a79e041698a94e">this ready-made SCP</a> and apply it to your Organizations’ root or target OUs. The policy still allows rollouts for new accounts and modifications originating from the Organizations management account, but prevents account owners from directly interfering with the CloudFormation stack and the cost anomaly detection resources:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/359/1*LzfgKS-iHefXKzcLYwGhvQ.png" /></figure><p>As you can see, this second method comes with higher complexity, but also higher accuracy in detecting cost spikes.</p><p>No matter which method you choose, they will hopefully help you in fulfilling your role as a central team and avoiding surprises when the AWS bill comes in. If you need support in looking for AWS cost saving potentials in your environment, feel free to reach out! And that’s all for today :)</p><p>Kudos to Markus Ostertag, Philipp Garbe, Robert de Meyer, and Anders Bjørnestad for fruitful discussions and an exchange of ideas around this topic.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38b6313e2244" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/detecting-aws-cost-spikes-for-central-teams-38b6313e2244">Detecting AWS cost spikes for central teams</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Visualizing API call activity in your AWS account]]></title>
            <link>https://awstip.com/visualizing-api-call-activity-in-your-aws-account-e5b37b520106?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5b37b520106</guid>
            <category><![CDATA[aws-resources]]></category>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[aws-well-architected]]></category>
            <category><![CDATA[aws-iam]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Sat, 06 May 2023 09:41:44 GMT</pubDate>
            <atom:updated>2023-05-15T16:53:08.243Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article shows you how you can get a visual overview of the API call activities going on in your AWS account. Get an overview of which IAM principals are active, which API calls they make and in which regions.</h4><p>Whether you are doing a security assessment, trying to optimize a given application or just want to learn how a solution built on AWS actually works, there is a valuable source of information: CloudTrail. The CloudTrail service logs API call activity and shows which IAM principals actually use which functionality (AWS API calls), how often and in which regions.</p><p>CloudTrail provides its logs in text form (JSON), which make them suitable for further automated processing. However, it can be hard for humans to get a quick summary and overview based on text files.</p><p><a href="https://medium.com/aws-tip/how-to-get-an-overview-of-activities-going-on-within-an-aws-account-cb1608076819">In a previous article</a>, I was already writing about options to analyze CloudTrail data and introduced the <em>aws-summarize-account-activity</em> tool. I now extended the tool to turn CloudTrail data into PNG files that visualize AWS account activity.</p><p>To get started, first clone the following repository:</p><p><a href="https://github.com/welldone-cloud/aws-summarize-account-activity">GitHub - welldone-cloud/aws-summarize-account-activity</a></p><p>Then make sure you have credentials for your AWS account configured and run:</p><pre>python aws_summarize_account_activity.py --plot-results</pre><p>The script will iterate through all AWS regions and read your CloudTrail data. It will create a JSON output file that gives aggregated statistics on the activities in your AWS account. It will also create a series of PNG files that visualize the API call activity and allow you to get a nice overview of what is going on in your account:</p><p>First, it will show you a distribution of API calls across regions, allowing you to quickly identify your active geos:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*aFFdogZTL4ryQwYi" /></figure><p>You can then drill down into individual regions and see which API calls are happening there, and how many of them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*irl4PCBxsRcWz5Me" /></figure><p>Similarly, you are provided with an overview of which IAM principals are active in your account:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cl9xJOQ4VZ26YUg3" /></figure><p>You can again drill down into individual IAM principals and see what their specific API call activities are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*flT_ZTRdEQ--BT6s" /></figure><p>The generated visualizations should help you to quickly identify what is going on in an AWS account, from an API call perspective. Maybe you have activities in regions that you did not expect? Maybe you see IAM principals with an unexpectedly high amount of API calls, indicating potential for application optimization? Maybe there is an EC2 instance where you already wondered for a while whether it actually makes use of the IAM permissions it is granted? Happy visualizing!</p><p>And that’s all for today :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5b37b520106" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/visualizing-api-call-activity-in-your-aws-account-e5b37b520106">Visualizing API call activity in your AWS account</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to get an overview of activities going on within an AWS account]]></title>
            <link>https://awstip.com/how-to-get-an-overview-of-activities-going-on-within-an-aws-account-cb1608076819?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb1608076819</guid>
            <category><![CDATA[aws-well-architected]]></category>
            <category><![CDATA[aws-security]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-iam]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Mon, 03 Apr 2023 15:38:10 GMT</pubDate>
            <atom:updated>2023-04-11T16:42:31.067Z</atom:updated>
            <content:encoded><![CDATA[<h4>This article shows how the default CloudTrail logging available in each AWS account can be used to generate nice overviews of account activity (active IAM principals, API calls they made and regions they used). It also releases a new tool that creates such account activity overviews for you.</h4><p>In previous blog posts, I was writing about how to list resources that are configured in an AWS account (see <a href="https://medium.com/aws-tip/how-to-list-all-resources-in-your-aws-account-c3f18061f71b">here</a> and <a href="https://medium.com/@michael.kirchner/exploring-aws-resource-explorer-825498b5307d">here</a>). However, there is another angle to it: Besides resources, it is also interesting to learn more about the API activity that is going on within an account. The API activity shows which principals (IAM users or roles) actually use which functionality (AWS API actions), how often and where (regions).</p><p>Analyzing AWS account activity can serve many purposes: conducting security assessments, doing forensic investigations, separating dormant AWS resources from active ones, determining the primary use cases of AWS accounts, etc. AWS brings along a ready-made service that keeps track of API call activity, which is AWS CloudTrail.</p><h4>AWS CloudTrail</h4><p>CloudTrail can be regarded as a logging and auditing tool that works across many AWS services: it records API calls made and stores details such as the acting principal (IAM user or role), the API action called, client IP, request and response contents, etc.:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/551/1*-fsD1ujF--QuAyEpQcGsWQ.png" /></figure><p>CloudTrail can be configured to write its logs towards various destinations. S3 and CloudWatch Logs are the most prominent ones, but I have seen customers using external destinations as well that provide search and alarming capabilities (e.g., Elasticsearch or Splunk).</p><p>If you happen to be working with an AWS account where such a log destination is configured, I recommend working directly with that one to analyze account activity. As an example, CloudTrail data stored on S3 can be analyzed nicely using AWS Athena, as described here:</p><p><a href="https://docs.aws.amazon.com/athena/latest/ug/cloudtrail-logs.html">https://docs.aws.amazon.com/athena/latest/ug/cloudtrail-logs.html</a></p><p>Similarly, if your target AWS account happens to have the newer CloudTrail Lake service configured, you can analyze API activity using built-in SQL capabilities:<br><a href="https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html">https://docs.aws.amazon.com/awscloudtrail/latest/userguide/cloudtrail-lake.html</a></p><p>However, I regularly find myself working with AWS accounts where I do not have the luxury of CloudTrail logging destinations being configured (or just being inaccessible to me). These accounts may only write CloudTrail logs for single regions. Or there is an Organization-wide CloudTrail configured that I cannot access. Or I only have read permissions and thus cannot run Athena queries, etc.</p><p>Luckily, AWS CloudTrail keeps a history of the past 90 days of API activity, independent of whether any CloudTrail configuration was actively set up or a logging destination was configured. We can thus still use this event history to create a summary of activity that is going on within an AWS account.</p><h4>Introducing aws-summarize-account-activity</h4><p>I automated the process of iterating through all AWS regions, sending cloudtrail:LookupEvents API calls and showing aggregated statistics on account activity. You can find the tool here:</p><p><a href="https://github.com/welldone-cloud/aws-summarize-account-activity">https://github.com/welldone-cloud/aws-summarize-account-activity</a></p><p>By default, it reads the past 14 days of CloudTrail activity, but can be configured to read up to the full history of 90 days:</p><pre>python aws_summarize_account_activity.py</pre><p>The approach has the advantage that it does not require any specific configuration to be present in the target account: there is no need for CloudTrail to be actively enabled or configured in a certain way (e.g., logging to S3 or CloudWatch Logs). It comes with the drawback though that AWS throttles the LookupEvents API to two requests per second. The script will thus need proportionally more time for AWS accounts with lots of AWS API activity. In these cases, the above-described methods of using AWS Athena or CloudTrail Lake will be much more efficient.</p><p>The tool will write aggregated statistics on active IAM principals, AWS API calls made and regions used. Here is a truncated example:</p><pre>{<br>  &quot;_metadata&quot;: {<br>    &quot;account_id&quot;: &quot;123456789012&quot;,<br>    &quot;account_principal&quot;: &quot;arn:aws:iam::123456789012:user/myuser&quot;,<br>    &quot;cloudtrail_data_analyzed&quot;: {<br>      &quot;from_timestamp&quot;: &quot;20230315135630&quot;,<br>      &quot;to_timestamp&quot;: &quot;20230329135630&quot;<br>    },<br>    &quot;regions&quot;: [<br>      &quot;af-south-1&quot;,<br>      &quot;ap-northeast-1&quot;,<br>      &quot;ap-northeast-2&quot;,<br>      &quot;ap-northeast-3&quot;,<br>      &quot;ap-south-1&quot;,<br>      &quot;ap-southeast-1&quot;,<br>      &quot;ap-southeast-2&quot;,<br>      &quot;ca-central-1&quot;,<br>      &quot;eu-central-1&quot;,<br>      &quot;eu-north-1&quot;,<br>      &quot;eu-west-1&quot;,<br>      &quot;eu-west-2&quot;,<br>      &quot;eu-west-3&quot;,<br>      &quot;sa-east-1&quot;,<br>      &quot;us-east-1&quot;,<br>      &quot;us-east-2&quot;,<br>      &quot;us-west-1&quot;,<br>      &quot;us-west-2&quot;<br>    ],<br>    &quot;run_timestamp&quot;: &quot;20230329135630&quot;<br>  },<br>  &quot;activity_by_principal&quot;: {<br>    &quot;123456789012&quot;: {<br>      &quot;ssm.amazonaws.com:OpenDataChannel&quot;: 6<br>    },<br>    &quot;AWS Internal&quot;: {<br>      &quot;kms.amazonaws.com:Decrypt&quot;: 2,<br>      &quot;sts.amazonaws.com:AssumeRole&quot;: 1<br>    },<br>    &quot;arn:aws:iam::123456789012:user/myuser&quot;: {<br>      &quot;access-analyzer.amazonaws.com:ListPolicyGenerations&quot;: 5,<br>      &quot;access-analyzer.amazonaws.com:ValidatePolicy&quot;: 13,<br>      &quot;ce.amazonaws.com:GetCostAndUsage&quot;: 3,<br>      &quot;ce.amazonaws.com:GetCostForecast&quot;: 3,<br>      &quot;cloudtrail.amazonaws.com:DescribeTrails&quot;: 2,<br>      &quot;cloudtrail.amazonaws.com:GetTrailStatus&quot;: 1,<br>      &quot;cloudtrail.amazonaws.com:ListEventDataStores&quot;: 2,<br>      &quot;cloudtrail.amazonaws.com:LookupEvents&quot;: 44,<br>      &quot;config.amazonaws.com:DescribeConfigurationRecorderStatus&quot;: 1,<br>      &quot;config.amazonaws.com:DescribeConfigurationRecorders&quot;: 1,<br>      &quot;ec2.amazonaws.com:DescribeAccountAttributes&quot;: 3,<br>      &quot;ec2.amazonaws.com:DescribeRegions&quot;: 1,<br>      &quot;health.amazonaws.com:DescribeEventAggregates&quot;: 86,<br>      &quot;iam.amazonaws.com:AttachRolePolicy&quot;: 1,<br>      &quot;iam.amazonaws.com:CreateAccessKey&quot;: 1,<br>      &quot;iam.amazonaws.com:CreateRole&quot;: 1,<br>      &quot;iam.amazonaws.com:CreateUser&quot;: 1,<br>      &quot;iam.amazonaws.com:DeleteAccessKey&quot;: 1,<br>      &quot;iam.amazonaws.com:DeleteRole&quot;: 3,<br>      // ...<br>      &quot;signin.amazonaws.com:ConsoleLogin&quot;: 6,<br>      &quot;sso.amazonaws.com:DescribeRegisteredRegions&quot;: 1,<br>      &quot;sts.amazonaws.com:GetCallerIdentity&quot;: 1<br>    },<br>    &quot;arn:aws:sts::123456789012:assumed-role/EC2_role/i-04ba0448788198062&quot;: {<br>      &quot;s3.amazonaws.com:ListBuckets&quot;: 2,<br>      &quot;ssm.amazonaws.com:ListInstanceAssociations&quot;: 8,<br>      &quot;ssm.amazonaws.com:UpdateInstanceInformation&quot;: 14<br>    },<br>    // ...<br>    &quot;config.amazonaws.com&quot;: {<br>      &quot;sts.amazonaws.com:AssumeRole&quot;: 28<br>    },<br>    &quot;elasticfilesystem.amazonaws.com&quot;: {<br>      &quot;kms.amazonaws.com:Decrypt&quot;: 8,<br>      &quot;sts.amazonaws.com:AssumeRole&quot;: 9<br>    },<br>    // ...<br>  },<br>  &quot;activity_by_region&quot;: {<br>    &quot;af-south-1&quot;: {<br>      &quot;cloudtrail.amazonaws.com:LookupEvents&quot;: 2<br>    },<br>    &quot;ap-northeast-1&quot;: {<br>      &quot;cloudtrail.amazonaws.com:GetServiceLinkedChannel&quot;: 28,<br>      &quot;cloudtrail.amazonaws.com:LookupEvents&quot;: 7,<br>      &quot;dynamodb.amazonaws.com:ListTables&quot;: 3,<br>      &quot;ec2.amazonaws.com:DescribeAddresses&quot;: 3,<br>      &quot;ec2.amazonaws.com:DescribeCapacityReservationFleets&quot;: 3,<br>      &quot;ec2.amazonaws.com:DescribeCapacityReservations&quot;: 3,<br>      &quot;ec2.amazonaws.com:DescribeClientVpnEndpoints&quot;: 3,<br>      &quot;ec2.amazonaws.com:DescribeCustomerGateways&quot;: 3,<br>      &quot;ec2.amazonaws.com:DescribeDhcpOptions&quot;: 3,<br>      &quot;ec2.amazonaws.com:DescribeEgressOnlyInternetGateways&quot;: 3,<br>      // ...<br>    },<br>    // ...<br>    &quot;us-east-1&quot;: {<br>      &quot;access-analyzer.amazonaws.com:ListPolicyGenerations&quot;: 5,<br>      &quot;access-analyzer.amazonaws.com:ValidatePolicy&quot;: 13,<br>      &quot;ce.amazonaws.com:DescribeReport&quot;: 2,<br>      &quot;ce.amazonaws.com:GetCostAndUsage&quot;: 17,<br>      &quot;ce.amazonaws.com:GetCostForecast&quot;: 8,<br>      &quot;ce.amazonaws.com:GetDimensionValues&quot;: 5,<br>      &quot;ce.amazonaws.com:GetReservationPurchaseRecommendation&quot;: 1,<br>      &quot;ce.amazonaws.com:GetReservationUtilization&quot;: 2,<br>      &quot;cloudfront.amazonaws.com:ListCachePolicies&quot;: 47,<br>      &quot;cloudfront.amazonaws.com:ListCloudFrontOriginAccessIdentities&quot;: 46,<br>      &quot;cloudfront.amazonaws.com:ListDistributions&quot;: 46,<br>      &quot;cloudfront.amazonaws.com:ListFunctions&quot;: 43,<br>      &quot;cloudfront.amazonaws.com:ListOriginRequestPolicies&quot;: 46,<br>      // ...<br>    }<br>    // ...<br>  }<br>}</pre><p>API activity is broken down by IAM principal and region, along with information on how often an API action was invoked. In the example above, you can immediately see the summarized activity of an IAM user. Similarly, you can see that there is an IAM role associated with an EC2 instance that interacts with the S3 service. This gives you a nice starting point of what activities are going on within an AWS account and where you may want to investigate closer.</p><p>I hope that the tool will be useful to you and that’s all for today :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb1608076819" width="1" height="1" alt=""><hr><p><a href="https://awstip.com/how-to-get-an-overview-of-activities-going-on-within-an-aws-account-cb1608076819">How to get an overview of activities going on within an AWS account</a> was originally published in <a href="https://awstip.com/">AWS Tip</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring AWS Resource Explorer]]></title>
            <link>https://medium.com/@michael.kirchner/exploring-aws-resource-explorer-825498b5307d?source=rss-e98b8899684f------2</link>
            <guid isPermaLink="false">https://medium.com/p/825498b5307d</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-resources]]></category>
            <category><![CDATA[aws-security]]></category>
            <dc:creator><![CDATA[Michael Kirchner]]></dc:creator>
            <pubDate>Sun, 13 Nov 2022 18:28:10 GMT</pubDate>
            <atom:updated>2022-11-13T18:28:10.507Z</atom:updated>
            <content:encoded><![CDATA[<h4>I recently published a blog post on <a href="https://medium.com/@michael.kirchner/how-to-list-all-resources-in-your-aws-account-c3f18061f71b">how to list all resources in your AWS account</a>. Only a few weeks later, AWS launched a new service called AWS Resource Explorer, which aims at solving this exact problem. So it’s time to have a look at it and provide this update blog post.</h4><h4>A primer on AWS Resource Explorer</h4><p>AWS Resource Explorer is a free-of-charge service that allows you to search for resources that are configured within an AWS account. You can search for specific names or tags — or just list all resources that Resource Explorer currently supports. Searches query data across all regions you selected when enabling the service, as also highlighted in the AWS documentation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FHF0C-fV6AbXZdAh7R6rhg.png" /></figure><p>After enabling Resource Explorer and going through the initial waiting time where all indexes are created and synced, you have a central view available that will show resources within an account:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DR_37rcYfyptcsISF8Z88w.png" /></figure><p>Resources can be further filtered, for example by service, resource type or tags:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*68kOnKTn3ZSHtitwLB8HWw.png" /></figure><p>When you search through your data, the underlying queries are made against a central index that holds data aggregated from the regions. This means that queries you run do not cause live “Describe” or “List” calls in all regions. Search results are thus returned quite fast.</p><h4>The good</h4><p>There are many positive aspects regarding AWS Resource Explorer that make this a great service launch:</p><ul><li>The service is free of charge, making it a great alternative to other resource discovery mechanisms, such as AWS Config.</li><li>Resource Explorer was built with cross-region support from the very beginning. With other AWS services you recognize that their multi-region capability was somehow added later on top (such as AWS Security Hub). But that’s not the case here.</li><li>The service is not only available via the AWS Console, but also offers an API from day one. This allows to automate resource discovery and inventory analysis.</li><li>The aggregated resource index seems to be updated sufficiently fast: In a test scenario, I launched an EC2 instance in a different region than where my aggregated index lives. The EC2 instance was returned in Resource Explorer search queries less than two minutes from launching it.</li></ul><h4>The not-so-good</h4><p>There are two major drawbacks you need to be aware of when working with Resource Explorer:</p><p><strong>1.</strong> At the time of writing, the list of resource types that can be discovered with Resource Explorer is quite short (see <a href="https://docs.aws.amazon.com/resource-explorer/latest/userguide/supported-resource-types.html">here</a> for the details). In the <a href="https://medium.com/@michael.kirchner/how-to-list-all-resources-in-your-aws-account-c3f18061f71b">previous blog post</a>, I compared the number of different resource types that various methods are capable of finding. If we update the result graph by just adding AWS Resource Explorer, it looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*dV9-RmFkAkAqgvpugfgWrw.png" /></figure><p>You thus need to be aware that when you use Resource Explorer at the current stage, you will only get a limited view on the resources you potentially have configured in your account. A good aspect is that AWS is quite transparent about this and even links to the list of currently supported resource types directly from the Resource Explorer Console.</p><p><strong>2.</strong> When you enable AWS Resource Explorer initially, there is a waiting period of 36 hours until all region-local indexes are operating and aggregate their data to the central region. For many use cases, this waiting time will not be a problem. But when working on AWS security reviews, this can be a long time and you might want to go for alternative resource discovery methods instead.</p><h4>Summary and likely future</h4><p>Overall, AWS Resource Explorer is a great service and something that the AWS platform has needed for a long time. The relatively low number of supported resource types could be considered normal for a newly launched service. But it is something that still needs to ramp up. By a lot.</p><p>Besides increased resource type coverage, I think that AWS will continue to evolve Resource Explorer in the following areas:</p><ul><li>Integration with AWS Organizations, so that resources can be discovered both across regions and across AWS accounts.</li><li>Sharing Resource Explorer views across accounts, potentially via AWS RAM. This would allow to see resources from a different account, without granting direct access to the source account.</li><li>Adding a SQL-based query capability to explore the central index data, in addition to the filter functionality that is already available.</li></ul><p>And that’s all for today :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=825498b5307d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>