DEV Community: Bob Tordella The latest articles on DEV Community by Bob Tordella (@bobbot). https://dev.to/bobbot https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F745501%2Fa7f4c97d-7703-42de-af66-3309bae1ece5.png DEV Community: Bob Tordella https://dev.to/bobbot en Overcoming AWS Security Alert Fatigue Bob Tordella Fri, 25 Jul 2025 17:49:41 +0000 https://dev.to/aws-builders/overcoming-aws-security-alert-fatigue-e28 https://dev.to/aws-builders/overcoming-aws-security-alert-fatigue-e28 <p>If you're running AWS at any scale, you've likely experienced this scenario: your security tools are generating hundreds of findings every week, but only a fraction actually get addressed. The rest accumulate until the next audit or compliance deadline creates urgency.</p> <p>This scenario is playing out across organizations of every size. Teams become overwhelmed by the sheer volume of security findings and struggle to establish systematic remediation processes.</p> <p>Most organizations have excellent visibility into their security posture. AWS Security Hub, Config Rules, GuardDuty, Inspector, and third-party CSPM and CNAPP tools provide comprehensive coverage. Yet security findings continue to accumulate faster than teams can address them.</p> <h2> Phases of Security Alert Fatigue </h2> <p>You can't govern what you can't see. You need the ability to know what you have and what you can do to improve your posture. Organizations invest heavily in monitoring tools. However, comprehensive visibility often creates information overload that presents its own challenges.</p> <p><strong>Phase 1: Tool Implementation</strong><br> Organizations invest in CSPM and CNAPP tools, excited about gaining visibility into their entire AWS environment. Tools are configured with default rules and industry recommendations.</p> <p><strong>Phase 2: Information Overload</strong> <br> Hundreds or thousands of findings start flowing in daily. Security team is overwhelmed. Application teams receive scattered requests for fixes, often without context about priority or business impact.</p> <p><strong>Phase 3: Confusion and Inaction</strong><br> Teams become desensitized to security alerts when everything appears to be high priority. Application teams struggle to understand which findings require immediate attention versus those that can be addressed during planned maintenance.</p> <p><strong>Phase 4: Alert Accumulation</strong><br> Findings stack up faster than they can be addressed. Teams develop workarounds or learn to ignore certain types of alerts. Major security remediation programs are eventually created to tackle the backlog.</p> <p><strong>Phase 5: Whack-a-Mole</strong><br> Significant effort is invested to fix accumulated findings, but new problems arise as quickly as old ones are resolved. Without addressing root causes, the cycle repeats with each new application or environment.</p> <h2> When Alerts Become Background Noise </h2> <p>Most organizations approach security findings like a ticketing system - identify, assign, and continuous follow-ups for resolution. Treating security findings as isolated incidents creates fundamental problems that cause inaction in resolving issues:</p> <p><strong>Unclear Ownership:</strong> Organizations often lack clear processes for determining who should address specific types of findings. Security teams identify issues but may lack the application context to fix them effectively. Application teams understand their systems but may not fully grasp security implications. Additionally, team members change roles or leave the organization, breaking institutional knowledge about resource ownership and context.</p> <p><strong>Poor Communication:</strong> Many security alerts start shipping out to application teams without any education about why it matters. Teams do not understand how it relates to organizational standards, or what the business impact might be. Teams receive notifications about technical violations without understanding the underlying security or compliance rationale. This gap in communication creates confusion about which findings deserve immediate attention.</p> <p><strong>Missing Context:</strong> Security tools often apply generic rules without understanding workload context. A finding about an open port might be critical for a sensitive database but perfectly acceptable for a web-facing load balancer. Without workload context, teams either over-react to acceptable configurations or under-react to genuine risks.</p> <p><strong>Conflicting Prioritization:</strong> Teams struggle to prioritize security findings within their existing workload. Without clear service level agreements, risk assessments, or business impact guidance, application teams may delay security remediation in favor of feature development. This misalignment between security urgency and business priorities often results in prolonged inaction.</p> <p><strong>Constant Recurrence:</strong> Teams focus on fixing individual findings rather than addressing the underlying patterns that created them. This approach treats symptoms rather than causes, leading to repeated occurrences of similar issues across different resources and environments. Without investment in preventive controls or automated remediation, organizations find themselves in an endless cycle of manual fixes.</p> <h2> From Sending Alerts to Deploying Controls </h2> <p>Instilling <a href="proxy.php?url=https://cloudgovernance.org" rel="noopener noreferrer">Cloud Governance</a> practices into your security program transforms how you handle findings. This means shifting from reactive incident response to proactive standards and controls that are deployed systematically. The <a href="proxy.php?url=https://cloudgovernance.org/library/how-we-govern" rel="noopener noreferrer">5 Cloud Governance Practices</a> provide the framework for sustainable security remediation:</p> <p><strong>Standards:</strong> Define what secure AWS configurations look like for your organization. Instead of generic security rules, create specific standards that account for your workload types, risk tolerance, and operational requirements. Make these standards clear, practical, and co-created with the teams who will implement them.</p> <p><strong>Controls &amp; Automation:</strong> Enforce standards through preventive, detective, and corrective controls. Use AWS Config rules, Service Control Policies, and Infrastructure as Code templates to make secure configurations the default path. Automate remediation for low-risk findings and provide clear escalation paths for complex issues.</p> <p><strong>Adoption:</strong> Help teams embrace security standards through reusable tools, embedded guidance, and responsive support. Provide secure templates, clear documentation, and accessible channels for questions. Make following security standards easier than ignoring them.</p> <p><strong>Rollout:</strong> Deploy security standards systematically through the Draft → Preview → Check → Enforce lifecycle. Start with Draft where your cloud team tests the impact internally. Move to Preview to show application teams what would be flagged without affecting scores. Then Check, where everything is visible and counted but not yet enforced. Finally Enforce, where controls take action automatically. This progression reduces surprises and builds trust while giving teams time to adapt.</p> <p><strong>Measurement &amp; Improvement:</strong> Track the effectiveness of your Cloud Security Governance through both technical metrics (finding recurrence, remediation time) and organizational metrics (team adoption, exception patterns). Use this data to continuously improve your standards and rollout approaches.</p> <h2> Improving Security Posture with Cloud Governance </h2> <p>Cloud Governance transforms how you secure AWS at scale. Rather than chasing alerts, you create systems that prevent security issues from arising in the first place. Teams get secure defaults, clear standards, and automated guardrails that make compliance the easy path. This shift from reactive fixes to proactive prevention enables sustainable security improvement across your entire AWS environment.</p> aws security cloudgovernance devops [Boost] Bob Tordella Mon, 24 Mar 2025 14:25:47 +0000 https://dev.to/bobbot/-3go8 https://dev.to/bobbot/-3go8 <div class="ltag__link"> <a href="proxy.php?url=/mattstratton" class="ltag__link__link"> <div class="ltag__link__pic"> <img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F38834%2F68a98062-d7f1-4797-8a79-a34d8d217a27.jpg" alt="mattstratton"> </div> </a> <a href="proxy.php?url=https://dev.to/mattstratton/check-if-you-are-breaking-your-admin-rules-in-your-github-repos-467b" class="ltag__link__link"> <div class="ltag__link__content"> <h2>Check if you are breaking your admin rules in your GitHub repos</h2> <h3>Matty Stratton ・ Mar 24</h3> <div class="ltag__link__taglist"> </div> </div> </a> </div> github discuss development productivity Threat Detection for AWS CloudTrail Logs Bob Tordella Thu, 20 Mar 2025 13:04:29 +0000 https://dev.to/aws-builders/threat-detection-for-aws-cloudtrail-logs-mgl https://dev.to/aws-builders/threat-detection-for-aws-cloudtrail-logs-mgl <p>In my <a href="proxy.php?url=https://dev.to/aws-builders/query-aws-cloudtrail-logs-locally-with-sql-4jcj">previous post</a>, I showed how to use <a href="proxy.php?url=https://tailpipe.io" rel="noopener noreferrer">Tailpipe</a> to query your AWS CloudTrail logs locally with SQL. Now let's take it to the next level: visualizing those logs with powerful dashboards for advanced threat detection and investigation.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqd6b3zfs3nz7lrjdfgb.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqd6b3zfs3nz7lrjdfgb.png" alt="Powerpipe AWS CloudTrail Logs MITRE ATT&amp;CK benchmark" width="800" height="451"></a></p> <h2> Threat Detection Benchmarks </h2> <p>When investigating suspicious AWS activity, having both powerful queries and interactive visualizations can make all the difference. Whether you're responding to a security incident or proactively hunting for threats, you need to quickly separate normal activity from potential risks.</p> <p>Enter <a href="proxy.php?url=https://hub.powerpipe.io/mods/turbot/tailpipe-mod-aws-cloudtrail-log-detections" rel="noopener noreferrer">Powerpipe AWS CloudTrail Detections mod</a>: pre-built dashboards and detections that work with your locally collected CloudTrail logs from the <a href="proxy.php?url=https://hub.tailpipe.io/plugins/turbot/aws" rel="noopener noreferrer">Tailpipe AWS plugin</a> to provide security insights based on industry frameworks like <a href="proxy.php?url=https://attack.mitre.org/" rel="noopener noreferrer">MITRE ATT&amp;CK</a>. And the best part? It all runs locally without sending your sensitive log data anywhere.</p> <h2> Getting Started </h2> <p>If you haven't set up Tailpipe to collect your CloudTrail logs, you can learn how to do that from our <a href="proxy.php?url=https://dev.to/aws-builders/query-aws-cloudtrail-logs-locally-with-sql-4jcj#getting-started">prior post</a>.</p> <p>After you have Tailpipe set-up, add Powerpipe to visualize this data:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code><span class="c"># Install Powerpipe</span> brew <span class="nb">install </span>turbot/tap/powerpipe <span class="c"># Or using the install script</span> <span class="nb">sudo</span> /bin/sh <span class="nt">-c</span> <span class="s2">"</span><span class="si">$(</span>curl <span class="nt">-fsSL</span> https://powerpipe.io/install/powerpipe.sh<span class="si">)</span><span class="s2">"</span> <span class="c"># Create a directory for the dashboards and install the mod</span> <span class="nb">mkdir </span>dashboards <span class="nb">cd </span>dashboards powerpipe mod <span class="nb">install </span>github.com/turbot/tailpipe-mod-aws-cloudtrail-log-detections </code></pre> </div> <p>And now start the dashboard server:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>powerpipe server </code></pre> </div> <p>Visit <code>http://localhost:9033</code> in your browser, and you're ready to explore your CloudTrail logs dashboards.</p> <h2> Viewing CloudTrail Activity Through a Security Lens </h2> <p>The mod provides multiple benchmarks with 100 pre-built detections to help visualize suspicious activity. Let's walk through the key views and capabilities this gives you:</p> <h3> Detections by AWS Service </h3> <p>The <a href="proxy.php?url=https://hub.powerpipe.io/mods/turbot/tailpipe-mod-aws-cloudtrail-log-detections/benchmarks/benchmark.cloudtrail_log_detections" rel="noopener noreferrer">CloudTrail Log Detections Benchmark</a> organizes findings by AWS service, making it easy to focus on specific areas like IAM, S3, or EC2.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F768kschdaxbet52lzfoj.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F768kschdaxbet52lzfoj.png" alt="Powerpipe AWS CloudTrail Log Detections dashboard" width="800" height="554"></a></p> <p>Each detection is pre-built to identify potentially suspicious activity, such as:</p> <ul> <li>IAM root user console logins</li> <li>S3 bucket policy changes</li> <li>EC2 security group modifications</li> <li>CloudWatch log deletion events</li> </ul> <p>Click on any detection to see the specific CloudTrail events that triggered it, complete with timestamps, usernames, and other contextual details.</p> <h3> Hunt for Bad Actors </h3> <p>Security analysis is all about finding needles in haystacks. Powerpipe has built-in filtering capabilities to help you narrow down and focus on the log entries found by detections; hover over any cell to reveal a row of four icons:</p> <ul> <li> <strong>Copy value:</strong> Quickly grab data for use in other tools</li> <li> <strong>Filter by this value:</strong> Focus only on rows with this specific value</li> <li> <strong>Exclude value from results:</strong> Remove these rows from your current view</li> <li> <strong>View row:</strong> Examine all details about a specific event</li> </ul> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcdhu7btsbohizpsufli9.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fcdhu7btsbohizpsufli9.png" alt="Powerpipe Detections Filtering" width="800" height="215"></a></p> <p>If you want to keep only rows with the <code>/aws/lambda/Level6</code> resource, select the <strong>Filter</strong> icon. Conversely if you want to toss that set of rows to focus on everything else, select the <strong>Exclude</strong> icon. Using these tools you can refine the set of detected rows to ignore those that are benign and focus on the ones that might be malicious.</p> <p>When you find an interesting row, use the <strong>View</strong> icon to explore it in detail:</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3m2j23ksqv5qukl1fbxy.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3m2j23ksqv5qukl1fbxy.png" alt="Powerpipe Detections Filtering Detailed View" width="800" height="426"></a></p> <h3> View Through the MITRE ATT&amp;CK Lens </h3> <p>To view results through a different lens, Powerpipe offers a <a href="proxy.php?url=https://hub.powerpipe.io/mods/turbot/tailpipe-mod-aws-cloudtrail-log-detections/benchmarks/benchmark.mitre_attack_v161" rel="noopener noreferrer">MITRE ATT&amp;CK benchmark</a> that maps the same CloudTrail events to the MITRE ATT&amp;CK framework. This helps security teams understand the potential security implications of each activity and how it might fit into a larger attack chain.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqd6b3zfs3nz7lrjdfgb.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbqd6b3zfs3nz7lrjdfgb.png" alt="Powerpipe AWS CloudTrail Logs MITRE ATT&amp;CK benchmark" width="800" height="451"></a></p> <p>For example, an IAM root user login might appear under:</p> <ul> <li> <strong>TA0001: Initial Access</strong> - is a high-level tactic, representing an adversary's goal to gain an initial foothold in a system.</li> <li> <strong>T1078: Valid Accounts</strong> - is a technique related to use of valid credentials (stolen, guessed, or default) to access systems.</li> <li> <strong>T1078.001: Valid Accounts: Default Accounts</strong> - narrows that down to focus on root accounts or accounts with default passwords. That's the context for the IAM Root User Console Login detection.</li> </ul> <p>It's not the only context though, as the same detection also appears under tactic <strong>TA0004: Privilege Escalation</strong> providing different perspectives to evaluate how an action fits into the overall attack chain.</p> <p>And the same filtering features are available to investigate further. For example, if the actor performing the login is known and trusted, exclude all console logins from that actor with a single click in order to focus on others that may warrant scrutiny.</p> <h2> Conclusion </h2> <p>With Tailpipe handling log collection and queries, and Powerpipe providing interactive visualization, you have a powerful, local, open-source solution for security analysis. You can analyze logs offline, quickly filter massive datasets, and investigate potential security incidents all while maintaining complete control over your sensitive data.</p> aws opensource tailpipe powerpipe Query AWS CloudTrail Logs Locally with SQL Bob Tordella Fri, 31 Jan 2025 21:38:25 +0000 https://dev.to/aws-builders/query-aws-cloudtrail-logs-locally-with-sql-4jcj https://dev.to/aws-builders/query-aws-cloudtrail-logs-locally-with-sql-4jcj <p>When investigating AWS activity or analyzing usage patterns, being able to quickly query your CloudTrail logs can make all the difference. Whether you're responding to a security event, optimizing costs, or just trying to understand how your team uses AWS, you need fast, iterative access to your log data.</p> <p>Enter <a href="proxy.php?url=https://tailpipe.io" rel="noopener noreferrer">Tailpipe</a>: a lightweight, open-source tool that lets you analyze logs right from your terminal using SQL. It runs entirely on your local machine, using DuckDB to process millions of records in seconds. This means you can pull down your logs locally and start querying immediately - perfect for rapid investigations, offline analysis, or when you need to quickly test different queries.</p> <p>Just pipe your CloudTrail logs to your local machine, and you're ready to start querying with familiar SQL. No infrastructure to set up, no services to configure - just straightforward log analysis when you need it.</p> <h2> Getting Started </h2> <p>First, let's install Tailpipe. You have two options:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code><span class="c"># Using Homebrew</span> brew <span class="nb">install </span>turbot/tap/tailpipe <span class="c"># Or using the install script</span> <span class="nb">sudo</span> /bin/sh <span class="nt">-c</span> <span class="s2">"</span><span class="si">$(</span>curl <span class="nt">-fsSL</span> https://tailpipe.io/install/tailpipe.sh<span class="si">)</span><span class="s2">"</span> </code></pre> </div> <p>Next, install the AWS plugin:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>tailpipe plugin <span class="nb">install </span>aws </code></pre> </div> <h2> Configuration </h2> <p>Create a simple configuration file to connect Tailpipe to your AWS CloudTrail logs. Create a <code>tailpipe.hcl</code> file:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight hcl"><code><span class="nx">connection</span> <span class="s2">"aws"</span> <span class="s2">"prod"</span> <span class="p">{</span> <span class="nx">profile</span> <span class="p">=</span> <span class="s2">"log-admin"</span> <span class="c1"># Your AWS profile name</span> <span class="p">}</span> <span class="nx">partition</span> <span class="s2">"aws_cloudtrail_log"</span> <span class="s2">"prod"</span> <span class="p">{</span> <span class="nx">source</span> <span class="s2">"aws_s3_bucket"</span> <span class="p">{</span> <span class="nx">connection</span> <span class="p">=</span> <span class="nx">connection</span><span class="p">.</span><span class="nx">aws</span><span class="p">.</span><span class="nx">prod</span> <span class="nx">bucket</span> <span class="p">=</span> <span class="s2">"aws-cloudtrail-logs-12345"</span> <span class="c1"># Your CloudTrail bucket</span> <span class="p">}</span> <span class="p">}</span> </code></pre> </div> <h2> Collecting Logs </h2> <p>Now you're ready to collect some logs. Start with the last 7 days:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>tailpipe collect aws_cloudtrail_log </code></pre> </div> <p>Want more history? Specify a start date:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight shell"><code>tailpipe collect aws_cloudtrail_log <span class="nt">--from</span> 2024-01-01 </code></pre> </div> <h2> Understanding Your AWS API Usage </h2> <p>Let's start with a fundamental question: which AWS services and APIs are most frequently used in your environment? This query helps you understand your AWS usage patterns:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight sql"><code><span class="k">select</span> <span class="n">event_source</span><span class="p">,</span> <span class="n">event_name</span><span class="p">,</span> <span class="k">count</span><span class="p">(</span><span class="o">*</span><span class="p">)</span> <span class="k">as</span> <span class="n">event_count</span> <span class="k">from</span> <span class="n">aws_cloudtrail_log</span> <span class="k">group</span> <span class="k">by</span> <span class="n">event_source</span><span class="p">,</span> <span class="n">event_name</span> <span class="k">order</span> <span class="k">by</span> <span class="n">event_count</span> <span class="k">desc</span> <span class="k">limit</span> <span class="mi">10</span><span class="p">;</span> </code></pre> </div> <p>Running this query on a typical AWS environment might give you output like this:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight sql"><code><span class="o">+</span><span class="c1">-------------------+---------------------------+-------------+</span> <span class="o">|</span> <span class="n">event_source</span> <span class="o">|</span> <span class="n">event_name</span> <span class="o">|</span> <span class="n">event_count</span> <span class="o">|</span> <span class="o">+</span><span class="c1">-------------------+---------------------------+-------------+</span> <span class="o">|</span> <span class="n">ec2</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">RunInstances</span> <span class="o">|</span> <span class="mi">1225268</span> <span class="o">|</span> <span class="o">|</span> <span class="n">ec2</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">DescribeSnapshots</span> <span class="o">|</span> <span class="mi">101158</span> <span class="o">|</span> <span class="o">|</span> <span class="n">sts</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">AssumeRole</span> <span class="o">|</span> <span class="mi">78380</span> <span class="o">|</span> <span class="o">|</span> <span class="n">s3</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">GetBucketAcl</span> <span class="o">|</span> <span class="mi">19095</span> <span class="o">|</span> <span class="o">|</span> <span class="n">ec2</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">DescribeInstances</span> <span class="o">|</span> <span class="mi">18366</span> <span class="o">|</span> <span class="o">|</span> <span class="n">sts</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">GetCallerIdentity</span> <span class="o">|</span> <span class="mi">16512</span> <span class="o">|</span> <span class="o">|</span> <span class="n">iam</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">GetPolicyVersion</span> <span class="o">|</span> <span class="mi">14737</span> <span class="o">|</span> <span class="o">|</span> <span class="n">s3</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">ListBuckets</span> <span class="o">|</span> <span class="mi">13206</span> <span class="o">|</span> <span class="o">|</span> <span class="n">ec2</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">DescribeSpotPriceHistory</span> <span class="o">|</span> <span class="mi">10714</span> <span class="o">|</span> <span class="o">|</span> <span class="n">ec2</span><span class="p">.</span><span class="n">amazonaws</span><span class="p">.</span><span class="n">com</span> <span class="o">|</span> <span class="n">DescribeSnapshotAttribute</span> <span class="o">|</span> <span class="mi">9107</span> <span class="o">|</span> <span class="o">+</span><span class="c1">-------------------+---------------------------+-------------+</span> </code></pre> </div> <p>Looking at this output, you'll notice that many of these operations are read-only actions like <code>Describe*</code>, <code>Get*</code>, and <code>List*</code>. While this gives us a good overview of API usage, we might be more interested in write operations that actually change our AWS environment.</p> <p>Let's modify our query to focus on these change-making operations:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight sql"><code><span class="k">select</span> <span class="n">event_source</span><span class="p">,</span> <span class="n">event_name</span><span class="p">,</span> <span class="k">count</span><span class="p">(</span><span class="o">*</span><span class="p">)</span> <span class="k">as</span> <span class="n">event_count</span> <span class="k">from</span> <span class="n">aws_cloudtrail_log</span> <span class="k">where</span> <span class="k">not</span> <span class="n">read_only</span> <span class="k">group</span> <span class="k">by</span> <span class="n">event_source</span><span class="p">,</span> <span class="n">event_name</span> <span class="k">order</span> <span class="k">by</span> <span class="n">event_count</span> <span class="k">desc</span> <span class="k">limit</span> <span class="mi">10</span><span class="p">;</span> </code></pre> </div> <p>Now we're seeing a very different picture!<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>+----------------------+---------------------------+-------------+ | event_source | event_name | event_count | +----------------------+---------------------------+-------------+ | ec2.amazonaws.com | RunInstances | 1225268 | | sts.amazonaws.com | AssumeRole | 78380 | | ec2.amazonaws.com | CreateTags | 8456 | | ec2.amazonaws.com | CreateVolume | 5231 | | s3.amazonaws.com | PutObject | 4521 | | iam.amazonaws.com | CreateRole | 3242 | | ec2.amazonaws.com | ModifyInstanceAttribute | 2890 | | rds.amazonaws.com | CreateDBInstance | 2456 | | lambda.amazonaws.com | CreateFunction | 2123 | | eks.amazonaws.com | CreateCluster | 1890 | +----------------------+---------------------------+-------------+ </code></pre> </div> <p>This filtered view highlights the actual resource creation and modifications in your AWS environment, quickly showing you where new infrastructure is being deployed and potential areas for optimization.</p> <p>You can modify these queries further to focus on specific time periods, services, or add additional filters based on your needs.</p> <h2> Learn More </h2> <p>There's much more you can do with Tailpipe. The <a href="proxy.php?url=https://hub.tailpipe.io" rel="noopener noreferrer">Tailpipe Hub</a> has 110+ ready-to-use <a href="proxy.php?url=https://hub.tailpipe.io/plugins/turbot/aws" rel="noopener noreferrer">CloudTrail queries</a> along with other log sources you can collect &amp; analyze. As part of the Turbot open source ecosystem, you can also use the Powerpipe <a href="proxy.php?url=https://hub.powerpipe.io/mods/turbot/tailpipe-mod-aws-cloudtrail-log-detections" rel="noopener noreferrer">AWS CloudTrail Logs Detections mod</a> to visualize pre-built dashboards and detections of your AWS activity.</p> aws security opensource tailpipe How to run an AWS CIS v3.0 assessment in CloudShell Bob Tordella Thu, 08 Feb 2024 19:42:32 +0000 https://dev.to/aws-builders/how-to-run-an-aws-cis-v30-assessment-in-cloudshell-16o4 https://dev.to/aws-builders/how-to-run-an-aws-cis-v30-assessment-in-cloudshell-16o4 <p>AWS CloudShell makes it easy to spin up a terminal right in your AWS account. Since CloudShell is just like any other terminal, you have the ability to bootstrap other tools without the need to spin up an instance.</p> <p>In a <a href="proxy.php?url=https://dev.to/aws-builders/instantly-query-aws-with-sql-in-cloudshell-hd0">prior post</a> I showed how to install <a href="proxy.php?url=https://steampipe.io/" rel="noopener noreferrer">Steampipe</a> in AWS CloudShell to instantly query over 460+ resource types from your AWS APIs using SQL, and <a href="proxy.php?url=https://dev.to/aws-builders/how-to-perform-a-security-audit-of-your-aws-account-in-aws-cloudshell-2jn1">another post</a> on how to use the <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/aws_compliance" rel="noopener noreferrer">Steampipe AWS Compliance mod</a> to assess over 25+ security benchmarks across your AWS accounts.</p> <p>In this post we are going to show how to run the latest <a href="proxy.php?url=https://steampipe.io/blog/cis-v30-aws-benchmark" rel="noopener noreferrer">AWS CIS benchmark v3.0</a> in AWS CloudShell.</p> <h2> How to run an AWS CIS v3.0 assessment </h2> <p><strong>Here's how to get started:</strong><br> If you've already completed steps 1 - 3, skip to step 4:</p> <p><strong>1. Install Steampipe</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)" </code></pre> </div> <p><strong>2. Install the AWS plugin</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe plugin install aws </code></pre> </div> <p><strong>3. Install the AWS Compliance Mod</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>git clone https://github.com/turbot/steampipe-mod-aws-compliance cd steampipe-mod-aws-compliance </code></pre> </div> <p><strong>4. Run the AWS CIS v3.0 benchmark:</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe check aws_compliance.benchmark.cis_v300 </code></pre> </div> <p>There are over 60 controls in that benchmark, so the command produces many screenfuls of output, here's the last one:</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk0ttvu8zexqffjh56vqg.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fk0ttvu8zexqffjh56vqg.png" alt="Steampipe AWS CIS v3.0 benchmark assessment" width="800" height="405"></a></p> <h2> Export and Review the Findings </h2> <p>The summary is helpful, but you may want to digest the full report in varying formats. You can export to <code>CSV</code>, <code>Markdown</code>, <code>HTML</code>. Example of an <code>HTML</code> format:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe check aws_compliance.benchmark.cis_v300 --export=output.html </code></pre> </div> <p>Using <code>Files -&gt; Download File</code> in AWS CloudShell's <code>Actions</code> menu, you can download your output file <code>steampipe-mod-aws-compliance/output.html</code> and work with it locally. </p> <p>Here's what the HTML report looks like:</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftw1b4vh2nxcx51gl4fr9.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftw1b4vh2nxcx51gl4fr9.png" alt="Steampipe AWS CIS v3.0 benchmark assessment - HTML Output" width="800" height="842"></a></p> <h2> Final Thoughts </h2> <p>I really enjoy using AWS CloudShell + Steampipe for these type of quick win use cases within an AWS account. It's remarkably easy to install your CLI tools like Steampipe, with no configuration required and instant gratification! </p> <p>CloudShell is just one place to run Steampipe in AWS, beyond ECS containers, EC2 instances and AWS Workspaces, you can also run Steampipe in <a href="proxy.php?url=https://steampipe.io/docs/integrations/cloud9" rel="noopener noreferrer">Cloud9</a> and <a href="proxy.php?url=https://steampipe.io/docs/integrations/aws_codebuild" rel="noopener noreferrer">CodeBuild</a>.</p> <p>Try <a href="proxy.php?url=https://steampipe.io/downloads" rel="noopener noreferrer">Steampipe</a> for other AWS use cases, and let me know how you go.</p> turbot steampipe aws cloudsecurity Keeping ServiceNow Updated with Automated AWS Discovery Bob Tordella Wed, 24 Jan 2024 05:24:14 +0000 https://dev.to/aws-builders/keeping-servicenow-updated-with-automated-aws-discovery-3p08 https://dev.to/aws-builders/keeping-servicenow-updated-with-automated-aws-discovery-3p08 <p>As AWS builders, we know how fast cloud environments evolve. Resources get added, changed, and removed continuously. If your inventory reporting or cloud discovery is not capturing changes in real-time, before you know it, your CMDB is full of blindspots and outdated data.</p> <p>Relying on manual cloud discovery and scheduled updates leads to inaccuracy. And when using native tools they often only cover a handful of core AWS services while leaving 100+ for custom development work.</p> <p>Recently our enterprise customers were expressing these struggles with keeping accurate records of cloud resources in their ServiceNow CMDB. So as part of our last <a href="proxy.php?url=https://turbot.com/launch-week" rel="noopener noreferrer">Launch Week</a> we built an <a href="proxy.php?url=https://turbot.com/guardrails/blog/2023/12/cmdb-sync-guardrails-servicenow-integration" rel="noopener noreferrer">integration</a> in <a href="proxy.php?url=https://turbot.com" rel="noopener noreferrer">Turbot Guardrails</a> in response to help customers capture real-time resource changes from multi-cloud to ServiceNow.</p> <h2> Automated AWS Discovery with Guardrails </h2> <p>This AWS &amp; ServiceNow integration via Turbot Guardrails provides a real-time automation to discover resources across 100+ AWS services. As your infrastructure changes, Guardrails detects it and handles updating integrated systems like ServiceNow.</p> <p>It augments native discovery capabilities by:</p> <ul> <li>Adding more comprehensive AWS resource coverage</li> <li>Handling deletions and archiving records</li> <li>Flexibly mapping data to different CMDB tables</li> <li>Eliminating dependency on legacy scheduled jobs</li> </ul> <p>This means you get complete visibility and accuracy as changes occur without the overhead.</p> <h2> How to configure automated AWS resource discovery for your ServiceNow CMDB </h2> <p>After you have <a href="proxy.php?url=https://turbot.com/guardrails/docs/integrations/servicenow" rel="noopener noreferrer">integrated</a> your ServiceNow instance to Turbot Guardrails; each AWS resource type can be configured to sync to the ServiceNow CMDB. Most often you would set the scope of the policy across many AWS resources from all your AWS accounts. In this example we will show how to enable syncing AWS S3 Buckets.</p> <p>Simply set the Turbot Guardrails policy to “Enforce: Sync” and apply to all or specific AWS accounts:</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjy3app8tx12lhd8d9rw.jpg" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmjy3app8tx12lhd8d9rw.jpg" alt="Turbot Guardrails policy to Enforce AWS Syncing to ServiceNow" width="800" height="706"></a></p> <p>For the AWS account we enabled the integration for, the following AWS resources will be in scope for the AWS discovery:</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7bvi6aa376qqu9tksos3.jpg" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7bvi6aa376qqu9tksos3.jpg" alt="AWS S3 Buckets Managed by Turbot Guardrails Example" width="800" height="401"></a></p> <p>Instantly the AWS resources will be added to the associated ServiceNow CMDB table:</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkjm1tttv83nvzuzag25b.jpg" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkjm1tttv83nvzuzag25b.jpg" alt="AWS S3 Buckets Synced to ServiceNow by Turbot Guardrails Example" width="800" height="226"></a></p> <p>As AWS resources are added, updated, or deleted, Turbot Guardrails handles the configuration drift and keeps ServiceNow CMDB updated.</p> <p>For example, when an AWS resource changes, Turbot Guardrails captures the configuration drift and updates ServiceNow CMDB:</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5dd6zpt868cuxnrdh9hh.jpg" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5dd6zpt868cuxnrdh9hh.jpg" alt="AWS Configuration Drift Captured by Turbot Guardrails" width="800" height="869"></a></p> <p>AWS resource deletion can be managed as a complete synchronization where the record in ServiceNow is deleted as well, or archived to retain its record with an archive status.</p> <h2> Configure AWS Discovery to your CMDB Tables </h2> <p>You can configure the AWS to ServiceNow discovery sync behavior by:</p> <ul> <li>Scoping to specific AWS services</li> <li>Defining archive vs delete flow for resource deletions</li> <li>Adding custom CMDB table columns and mappings</li> </ul> <p>This level of control lets you tailor it to your unique <a href="proxy.php?url=https://turbot.com/guardrails/blog/2024/01/servicenow-aws-discovery#map-aws-resource-details-to-servicenow-cmdb-ci-tables" rel="noopener noreferrer">CMDB table definitions</a> whether directly to a table or table extension.</p> <h2> Keep your AWS to ServiceNow Discovery Simple </h2> <p>Managing AWS cloud discovery to ServiceNow does not need to be difficult and time-consuming. Using this <a href="proxy.php?url=https://turbot.com/guardrails/blog/2024/01/servicenow-aws-discovery" rel="noopener noreferrer">Guardrails integration</a>, you can automate AWS resource discovery across 100+ AWS services and sync to ServiceNow CMDB in just minutes. This can accelerate new integration efforts or augment existing methods with more accuracy and timely updates when changes occur.</p> <p>Whether you are new to cloud discovery or looking to enhance existing capabilities, try a 14-day free trial by <a href="proxy.php?url=https://turbot.com/start" rel="noopener noreferrer">signing up</a> directly with Turbot or through the <a href="proxy.php?url=https://aws.amazon.com/marketplace/pp/prodview-xhmht6ul72y2q" rel="noopener noreferrer">AWS Marketplace</a>.</p> turbot aws servicenow cmdb What's new in the CIS v2.0 benchmark for AWS Bob Tordella Fri, 07 Jul 2023 13:56:52 +0000 https://dev.to/aws-builders/whats-new-in-the-cis-v20-benchmark-for-aws-3d77 https://dev.to/aws-builders/whats-new-in-the-cis-v20-benchmark-for-aws-3d77 <p>The <a href="proxy.php?url=https://www.cisecurity.org/" rel="noopener noreferrer">Center for Internet Security</a> (CIS) just released an updated version (v2.0) of their CIS AWS Benchmark. The new version of the benchmark includes 2 new recommendations, 1 removed, and updates to descriptions and remediation steps.</p> <h2> What are the latest major changes? </h2> <ul> <li><p><strong>Added - 1.22 Ensure access to AWSCloudShellFullAccess is restricted:</strong><br> AWS CloudShell allows running CLI commands with full access, including file upload/download and sudo permissions. This presents a potential data exfiltration channel for malicious cloud admins. Restricting access and denying file transfer permissions through a more restrictive IAM policy is recommended. Personally, CloudShell is a great way to run commands in your account <a href="proxy.php?url=https://dev.to/aws-builders/instantly-query-aws-with-sql-in-cloudshell-hd0">quickly and quickly enable tools like Steampipe</a>. However, with any highly privileged role, boundary and lockdown permissions should be considered for the least privilege restrictions.</p></li> <li><p><strong>Added - 5.6 Ensure that EC2 Metadata Service only allows IMDSv2:</strong><br> Instance Metadata Service Version 2 (IMDSv2), which is a session-oriented method which provides temporary, frequently rotated credentials. Version 2 adds new protections to mitigate vulnerabilities from open website application firewalls, open reverse proxies, SSRF, etc. This is a common recommendation used across many other <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/aws_compliance/controls/control.ec2_instance_uses_imdsv2" rel="noopener noreferrer">frameworks</a> like NIST, FedRamp, and HIPAA.</p></li> <li><p><strong>Removed - 2.1.1 Ensure all S3 buckets employ encryption-at-rest:</strong><br> In Benchmark v1.5, the requirement for encryption-at-rest in S3 buckets (2.1.1) was removed since AWS now automatically encrypts all new objects using SSE-S3 as the default encryption setting since January 2023. Existing buckets with S3 Default Encryption remain unchanged, so you may want to still check for encryption-at-rest for legacy buckets. However, moving forward at a minimum all new buckets will be encrypted and you cannot remove encryption any longer. With the removal of the control, all other Storage recommendations have changed their IDs in section 2.0.</p></li> </ul> <h2> Try the new AWS CIS v2.0 controls! </h2> <p>The <a href="proxy.php?url=https://github.com/turbot/steampipe-mod-aws-compliance" rel="noopener noreferrer">Steampipe AWS Compliance mod</a>, is packed with hundreds of controls that check your AWS accounts for compliance with 25 benchmarks including NIST, PCI, HIPAA, SOC2, FedRAMP and more, now includes new controls for AWS CIS v2.0. If you're new to Steampipe, <a href="proxy.php?url=https://steampipe.io/downloads" rel="noopener noreferrer">download</a> Steampipe, <a href="proxy.php?url=https://hub.steampipe.io/plugins/turbot/aws#get-started" rel="noopener noreferrer">install and configure</a> the AWS plugin, and run these commands.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe plugin update aws git clone https://github.com/turbot/steampipe-mod-aws-compliance.git cd steampipe-mod-aws-compliance steampipe check aws_compliance.benchmark.cis_v200 </code></pre> </div> <p>If you've already installed Steampipe and the AWS plugin, and cloned the AWS Compliance mod, then just do this.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>cd steampipe-mod-aws-compliance git pull steampipe check aws_compliance.benchmark.cis_v200 </code></pre> </div> <p>Here's a sample report in the console.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpsuypksluqmgu1xpuv9.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwpsuypksluqmgu1xpuv9.png" alt="Steampipe AWS CIS v2.0 Benchmark console report" width="800" height="455"></a></p> <p>You can output results to formats including JSON, CSV, HTML, and ASFF, or use custom output templates to create new output formats.</p> <p>To view the AWS CIS v2.0 benchmark report in your browser, run this command in the same cloned repo.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe dashboard </code></pre> </div> <p>Then open <code>http://localhost:9194</code> in your browser and view the dashboard.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ynjzgs4rel6svmmqstm.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5ynjzgs4rel6svmmqstm.png" alt="Steampipe AWS CIS v2.0 Benchmark interactive dashboard" width="800" height="420"></a></p> <h2> Extensible compliance controls </h2> <p>Steampipe delivers a full suite of tools to build, execute and share cloud configuration, compliance, and security frameworks using HCL + SQL! The community is constantly expanding the open source documentation and control coverage for CIS, PCI, HIPAA, NIST, and more. You can <a href="proxy.php?url=https://steampipe.io/community/join" rel="noopener noreferrer">join the Steampipe Slack community</a> to collaborate with other community members on your use cases.</p> security steampipe opensource aws Visualizing AWS EKS Kubernetes Clusters with Relationship Graphs Bob Tordella Fri, 21 Apr 2023 18:35:08 +0000 https://dev.to/aws-builders/visualizing-aws-eks-kubernetes-clusters-with-relationship-graphs-46a4 https://dev.to/aws-builders/visualizing-aws-eks-kubernetes-clusters-with-relationship-graphs-46a4 <p><a href="proxy.php?url=https://steampipe.io" rel="noopener noreferrer">Steampipe</a> is an open-source tool that helps users query, explore, and visualize their cloud environments. Relationship graphs in Steampipe are helpful visualizations that provide quick context and highlight important information about your resources. You can use these dashboards to visualize your AWS resources and also your AWS Elastic Kubernetes Service (EKS) clusters. </p> <p>AWS EKS is a managed Kubernetes service that makes it easier to deploy, manage, and scale containerized applications using Kubernetes. Using Steampipe with EKS, you can visualize inside the cluster to gain insights:</p> <ul> <li>How many resources do I have?</li> <li>How old are my resources?</li> <li>What are the various configurations of my resources?</li> <li>What are the relationships between closely connected resources like clusters, nodes, pods, deployments, and jobs?</li> <li>Who can perform operations like list, get, read, etc., on my resources?</li> </ul> <h2> Getting started </h2> <p>To get started with visualizing your EKS clusters through interactive dashboards, you can install Steampipe in your terminal.</p> <p><strong>First, install Steampipe:</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)" </code></pre> </div> <p><strong>Then, install the Kubernetes plugin:</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe plugin install kubernetes </code></pre> </div> <p><strong>Finally, install the <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/kubernetes_insights" rel="noopener noreferrer">Kubernetes Insights mod</a> by following these steps:</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>git clone https://github.com/turbot/steampipe-mod-kubernetes-insights cd steampipe-mod-kubernetes-insights steampipe dashboard </code></pre> </div> <p>Now visit <code>localhost:9194</code> in your browser to view and interact with the dashboards.</p> <p>If you already have an AWS EKS Kubernetes cluster in <code>~/.kube/config</code>, Steampipe will automatically pick up your default context. If you would like to set up multiple clusters, you can update your Steampipe configurations to aggregate <a href="proxy.php?url=https://hub.steampipe.io/plugins/turbot/kubernetes#multiple-context-connections" rel="noopener noreferrer">multiple contexts</a> at once.</p> <h2> Kubernetes Relationship Graphs </h2> <p>In this section, we will explore various dashboards provided by Steampipe to visualize different aspects of your EKS clusters. We will look at the Namespace, Deployment, Service, Pod, Service Account, and Role dashboards, and discuss how they can help you better understand and manage your AWS EKS Kubernetes resources.</p> <h3> Namespace dashboard </h3> <p>Here's a high-level view of the <code>kube-system</code> namespace in the <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/kubernetes_insights/dashboards/dashboard.namespace_detail" rel="noopener noreferrer">Namespace Detail</a> dashboard.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32pwh53vbkwpfayt71bj.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F32pwh53vbkwpfayt71bj.png" alt=" " width="800" height="263"></a></p> <p>The application runs as a Service. On initial view, the dashboard folds them all into an individual node, and folds the related DaemonSets, ReplicaSets and Deployments into their own individual nodes.</p> <h3> Deployment dashboard </h3> <p>If we open Deployments and click on the <code>coredns</code> Deployment we land in the <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/kubernetes_insights/dashboards/dashboard.deployment_detail" rel="noopener noreferrer">Deployment Detail</a> dashboard where we see the <code>kube-dns</code> Service linked to that Deployment. On hover we see details for one of the 2 pods in that Deployment's ReplicaSet: it's running, and it uses the <code>coredns</code> service account.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjao03k67ocqvfu4qw6g.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnjao03k67ocqvfu4qw6g.png" alt=" " width="800" height="1042"></a></p> <h3> Service dashboard </h3> <p>Clicking into the <code>kube-dns</code> Service takes us to the <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/kubernetes_insights/dashboards/dashboard.service_detail" rel="noopener noreferrer">Service Detail</a> dashboard where we can see the path from a load balancer to the <code>wordpress</code> service to the <code>wordpress</code> Deployment with its ReplicaSet consisting of a single pod.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh7t6fch4mzoa4afsg0ln.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh7t6fch4mzoa4afsg0ln.png" alt=" " width="800" height="1398"></a></p> <h3> Pod dashboard </h3> <p>Visiting the Pod takes us to the <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/kubernetes_insights/dashboards/dashboard.pod_detail" rel="noopener noreferrer">Pod Detail</a> dashboard. Here we can see, from another perspective, that it runs as the <code>coredns</code> service account. We can also see the single container in the pod, and we can see there are multiple read-only volumes mounted.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd82x5e4m9b55c8ecngar.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd82x5e4m9b55c8ecngar.png" alt=" " width="800" height="1060"></a></p> <h3> Service Account dashboard </h3> <p>The <code>coredns</code> service account is pretty simple. Here <code>coredns</code> runs as the service account. If we open that in the <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/kubernetes_insights/dashboards/dashboard.service_account_detail" rel="noopener noreferrer">Service Account Detail</a> dashboard, we see the 2 pods that run as that service account. However we can see the service account does not have any role bindings or secrets associated, which may indicate these pods may not have the necessary credentials needed.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fklkwllonzykeuixy8408.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fklkwllonzykeuixy8408.png" alt=" " width="714" height="466"></a></p> <h3> Role dashboard </h3> <p>The role shown here, is again simple, so let's open a more interesting one in the <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/kubernetes_insights/dashboards/dashboard.role_detail" rel="noopener noreferrer">Role Detail</a> dashboard. Here we see that the <code>eks:certificate-controller</code> role has broader permissions to all resources, but specific <code>get</code> and <code>update</code> permissions on a specific certificate resource.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6uvxxt61v6ybz1ds2tn.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft6uvxxt61v6ybz1ds2tn.png" alt=" " width="800" height="984"></a></p> <h3> Making Kubernetes legible </h3> <p>These interconnected graphs work hand-in-hand with their dashboards' infocards, charts, and tables to make Kubernetes systems legible in a whole new way. Which of these seem most useful to you? What other kinds of relationships will help you understand your K8s environments and manage them more effectively? We look forward to hearing about your experiences with Kubernetes Insights, and our <a href="proxy.php?url=https://steampipe.io/community/join" rel="noopener noreferrer">Slack community</a> is the place to share them.</p> steampipe aws opensource kubernetes Where are those CloudTrail IP addresses coming from? Bob Tordella Tue, 19 Jul 2022 19:47:29 +0000 https://dev.to/aws-builders/where-are-those-cloudtrail-ip-addresses-coming-from-3hae https://dev.to/aws-builders/where-are-those-cloudtrail-ip-addresses-coming-from-3hae <p>Setting up CloudTrail is essential to understanding your users' AWS API activity: what happened, by whom and from where. One field in the event logs is source IP address. But that doesn't tell you where in the world those AWS API actions are coming from. In this post we'll show how to use <a href="proxy.php?url=https://steampipe.io" rel="noopener noreferrer">Steampipe</a> with the <a href="proxy.php?url=https://hub.steampipe.io/plugins/turbot/aws" rel="noopener noreferrer">AWS</a> and <a href="proxy.php?url=https://hub.steampipe.io/plugins/turbot/ipstack" rel="noopener noreferrer">ipstack</a> plugins to enrich your CloudTrail events with location information.</p> <p>As in previous <a href="proxy.php?url=https://dev.to/bobbot">posts</a> we'll use AWS CloudShell for a quick-start experience that leverages your logged-in AWS credentials. Start your own CloudShell in the account with your CloudTrail information and follow along!</p> <h2> Setup </h2> <p>First install Steampipe:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)" </code></pre> </div> <p>Then install the AWS plugin:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe plugin install aws </code></pre> </div> <p>And then the ipstack plugin:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe plugin install ipstack </code></pre> </div> <h2> Find the CloudTrail CloudWatch Log Group </h2> <p>Actions taken by a user, role, or an AWS service are recorded as events in CloudTrail. These events can be sent to a CloudWatch log group to allow for easy monitoring. Steampipe has an associated table that reads CloudTrail event data from a CloudWatch log group that is configured to log events from a trail.</p> <p>Now with Steampipe and the plugins installed, you can run <code>steampipe query</code> and write SQL queries that reference tables provided by the <code>AWS</code> and <code>ipstack</code> plugins. For starters, let's query the <code>aws_cloudtrail_trail</code> table to find the CloudTrail and the related CloudWatch Log Group we'll use in this example:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>$ steampipe query Welcome to Steampipe v0.15.0 For more information, type .help &gt; select name, region, log_group_arn, latest_delivery_time from aws_cloudtrail_trail +-----------------------+-----------+----------------------+----------------------------------------------------------+ | name | region | latest_delivery_time | log_group_arn | +-----------------------+-----------+----------------------+----------------------------------------------------------+ | cloudtrail-for-devto | us-east-1 | 2022-07-06T20:38:09Z | arn:aws:logs:us-east-1:810361751552:cloudtrail-cwg-devto | +-----------------------+-----------+----------------------+----------------------------------------------------------+ </code></pre> </div> <h2> List the IP addresses in the log </h2> <p>Now let's review the source IP addresses in that trail:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>select source_ip_address from aws_cloudtrail_trail_event where log_group_name = 'cloudtrail-cwg-devto' and source_ip_address ~ '^\d+\.\d+' -- filter ipv4 addresses +-------------------+ | source_ip_address | +-------------------+ | 104.53.216.85 | | 82.102.17.180 | | 89.248.165.99 | | 107.170.20.63 | | 212.102.58.164 | +-------------------+ </code></pre> </div> <h2> Geolocate the IP addresses </h2> <p>Finally, let's join those addresses with <code>ipstack_ip</code> to find out where they are coming from:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>with addrs as ( select a.source_ip_address::inet from aws_cloudtrail_trail_event a where a.log_group_name = 'cloudtrail-cwg-devto' and a.source_ip_address ~ '^\d+\.\d+' -- filter ipv4 addresses ) select a.source_ip_address as ip, i.continent_name, i.country_name, i.region_name, i.city from addrs a join ipstack_ip i on a.source_ip_address = i.ip +-----------------+----------------+----------------+-------------------+------------+ | ip | continent_name | country_name | region_name | city | +-----------------+----------------+----------------+-------------------+------------+ | 104.53.216.85 | North America | United States | California | Windsor | | 82.102.17.180 | Europe | Spain | Madrid | Madrid | | 89.248.165.99 | Europe | Netherlands | North Holland | Diemen | | 107.170.20.63 | North America | United States | New York | Manhattan | | 157.230.162.15 | North America | United States | California | Palo Alto | | 212.102.58.164 | North America | United States | Illinois | Chicago | +-----------------+----------------+----------------+-------------------+------------+ </code></pre> </div> <h2> More ways to enrich IP addresses in logs </h2> <p>The <a href="proxy.php?url=https://hub.steampipe.io/plugins/turbot/net" rel="noopener noreferrer">Net</a> plugin can provide reverse DNS lookups, the <a href="proxy.php?url=https://hub.steampipe.io/plugins/turbot/abuseipdb" rel="noopener noreferrer">AbuseIPDB</a> plugin looks for malicious activity associated with IP addresses, and the <a href="proxy.php?url=https://steampipe.io/blog/use-shodan-to-test-aws-public-ip" rel="noopener noreferrer">Shodan</a> plugin scans for exploitable vulnerabilities. You can use the same technique shown here with these other plugins -- separately or in combination -- to further enrich IP addresses captured in your AWS CloudTrail logs.</p> aws steampipe opensource sql How to perform a security audit of your AWS account in AWS CloudShell Bob Tordella Fri, 20 May 2022 10:41:25 +0000 https://dev.to/aws-builders/how-to-perform-a-security-audit-of-your-aws-account-in-aws-cloudshell-2jn1 https://dev.to/aws-builders/how-to-perform-a-security-audit-of-your-aws-account-in-aws-cloudshell-2jn1 <p>AWS CloudShell makes it easy to spin up a terminal right in your AWS account. Since CloudShell is just like any other terminal, you have the ability to bootstrap other tools without the need to spin up an instance.</p> <p>In <a href="proxy.php?url=https://dev.to/aws-builders/instantly-query-aws-with-sql-in-cloudshell-hd0">my last post</a> I showed how to install <a href="proxy.php?url=https://steampipe.io/" rel="noopener noreferrer">Steampipe</a> and use it to instantly query your AWS APIs using SQL right in AWS CloudShell. For example here's a query that uses the Steampipe <a href="proxy.php?url=https://hub.steampipe.io/plugins/turbot/aws" rel="noopener noreferrer">AWS plugin</a> to query which AWS IAM users have MFA enabled:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>select title, create_date, mfa_enabled from aws_iam_user +-----------------+---------------------+-------------+ | title | create_date | mfa_enabled | +-----------------+---------------------+-------------+ | pam_beesly | 2005-03-24 21:30:00 | false | | creed_bratton | 2005-03-24 21:30:00 | true | | stanley_hudson | 2005-03-24 21:30:00 | false | | michael_scott | 2005-03-24 21:30:00 | false | | dwight_schrute | 2005-03-24 21:30:00 | true | +-----------------+---------------------+-------------+ </code></pre> </div> <p>You can simply query your environment for these type of security configuration questions using SQL. There's thousands of examples you can leverage to get you started, and a wealth of possibilities to uncover details about your AWS configurations.</p> <h2> Running Security and Compliance Checks </h2> <p>While you can explore your AWS configurations running queries, Steampipe also provides modules which are collections of related dashboards, benchmarks, queries, and controls. Steampipe mods and mod resources are defined in HCL wrapping your SQL queries to create a benchmark. There are many published mod examples to get you started with thousands of controls readily available for security, compliance, tagging, and cost controls. Published modules can be found on the <a href="proxy.php?url=https://hub.steampipe.io/mods" rel="noopener noreferrer">Steampipe Hub</a>, and custom mods may be shared with others from any public git repository.</p> <p>For example, the <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/aws_compliance" rel="noopener noreferrer">AWS Compliance Mod</a> layers benchmarks and controls covering 13 compliance standards including CIS, HIPAA, NIST, PCI, FedRAMP, SOC 2 and more. Each benchmark includes a set of pass/fail controls. Each control tests for a compliance recommendation such as "EC2 instances" should be managed by AWS Systems Manager" and reports <code>OK</code> or <code>Alarm</code>.</p> <p><strong>Here's how to run the NIST 800-53 benchmark:</strong><br> If you've already completed steps 1 - 3, skip to step 4:</p> <p><strong>1. Install Steampipe</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)" </code></pre> </div> <p><strong>2. Install the AWS plugin</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe plugin install aws </code></pre> </div> <p><strong>3. Install the AWS Compliance Mod</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>git clone https://github.com/turbot/steampipe-mod-aws-compliance cd steampipe-mod-aws-compliance </code></pre> </div> <p><strong>4. Run the NIST 800-53 benchmark:</strong><br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe check benchmark.nist_800_53_rev_4 </code></pre> </div> <p>There are over 370 controls in that benchmark, so the command produces many screenfuls of output, here's the last one:</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9mpihmvsa0h7f5obljoi.png" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9mpihmvsa0h7f5obljoi.png" alt="Steampipe AWS NIST 800-53 Revision 4" width="800" height="523"></a></p> <h2> Export and Review the Findings </h2> <p>The summary is helpful, but you may want to digest the full report in varying formats. You can export to <code>CSV</code>, <code>Markdown</code>, <code>HTML</code>. Example of an <code>HTML</code> format:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>steampipe check benchmark.nist_800_53_rev_4 --export=output.html </code></pre> </div> <p>Using <code>Files -&gt; Download File</code> in AWS CloudShell's <code>Actions</code> menu, you can download your output file <code>steampipe-mod-aws-compliance/output.html</code> and work with it locally. </p> <p>Here's what the HTML report looks like:<br> <a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1x4fn1nojpqyphmp79hk.PNG" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1x4fn1nojpqyphmp79hk.PNG" alt="Steampipe AWS NIST 800-53 Revision 4 - HTML Output" width="800" height="712"></a></p> <h2> AWS Compliance Quick Start </h2> <p>We put together a quick start script to bootstrap the flow above and prompt the user to select from the 13 available compliance benchmarks. </p> <p>To get started with the quick start, spin up a new CloudShell and install Steampipe:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)" </code></pre> </div> <p>Then bring down the Steampipe AWS Compliance Quick Start script to install the AWS Plugin, AWS Compliance Mod, and receive the selection prompt asking which benchmark to run:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>/bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe-samples/main/all/aws-compliance-quickstart/quickstart.sh)" </code></pre> </div> <p>See it in action:<br> <a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F534oewtu8wcuhdilkjb0.gif" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F534oewtu8wcuhdilkjb0.gif" alt="Steampipe AWS Compliance Run with AWS CIS v1.4" width="800" height="497"></a></p> <p>You can always run the last command again and it will skip the setup steps and prompt you for another compliance benchmark to run. Note: This last script was just a fun sample, generally you should stick to the official <a href="proxy.php?url=https://hub.steampipe.io/mods/turbot/aws_compliance/controls" rel="noopener noreferrer">AWS Compliance Mod Controls</a> to evaluate the controls, definitions and up to date information on available benchmarks.</p> <h2> Final Thoughts </h2> <p>I really enjoy using AWS CloudShell for these type of quick win use cases within an AWS account. It's remarkably easy to install your CLI tools like Steampipe, with no configuration required and instant gratification! Let me know how you use AWS CloudShell with your favorite CLI tools in the comments below.</p> aws cloudshell steampipe cloudsecurity Instantly query AWS with SQL in CloudShell Bob Tordella Tue, 03 May 2022 13:58:43 +0000 https://dev.to/aws-builders/instantly-query-aws-with-sql-in-cloudshell-hd0 https://dev.to/aws-builders/instantly-query-aws-with-sql-in-cloudshell-hd0 <p>AWS CloudShell makes it easy to spin up a terminal right in your AWS account. CloudShell comes preinstalled with the AWS CLI and your credentials within the applicable account. Since CloudShell is just like any other terminal, you have the ability to bootstrap other tools without the need to spin up an instance. I personally find CloudShell useful for ad hoc actions I need to take in AWS CLI or with other open source tools. </p> <p>As a lead on our open source tool Steampipe.io, I am a heavy user of the Steampipe CLI often running Steampipe on my local machine to run aggregated queries &amp; reports across an AWS multi-account environment and other cloud accounts. When I am working with clients in their AWS accounts, I find it easy to work within their account structure vs setting up a local profile. In this case I find AWS CloudShell a quick win for being a guest in another account to bootstrap my tools in a temporary environment under their control.</p> <p><strong>In this post will walk through how to install Steampipe in your AWS CloudShell.</strong></p> <h2> Steampipe Background </h2> <p>With Steampipe, you can instantly query your AWS APIs using SQL right in your terminal.<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>select title, create_date, mfa_enabled from aws_iam_user +-----------------+---------------------+-------------+ | title | create_date | mfa_enabled | +-----------------+---------------------+-------------+ | pam_beesly | 2005-03-24 21:30:00 | false | | creed_bratton | 2005-03-24 21:30:00 | true | | stanley_hudson | 2005-03-24 21:30:00 | false | | michael_scott | 2005-03-24 21:30:00 | false | | dwight_schrute | 2005-03-24 21:30:00 | true | +-----------------+---------------------+-------------+ </code></pre> </div> <p>It takes just a few seconds to <a href="proxy.php?url=https://steampipe.io/downloads" rel="noopener noreferrer">install Steampipe</a> itself, along with the <a href="proxy.php?url=https://hub.steampipe.io/plugins/turbot/aws" rel="noopener noreferrer">AWS plugin</a> that maps AWS API calls to <a href="proxy.php?url=https://hub.steampipe.io/plugins/turbot/aws/tables" rel="noopener noreferrer">Postgres tables</a>.</p> <p>Steampipe will resolve your region and credentials using the same mechanism as the AWS CLI (AWS environment variables, default profile, etc). Note: more can be extended for querying multiple accounts, regions, configuring credentials from your AWS Profiles, SSO, aws-vault etc.</p> <h2> AWS CloudShell + Steampipe </h2> <p>Alternatively you can use CloudShell to install Steampipe directly in your AWS Account. With CloudShell your credentials you use to sign into the AWS console are already forwarded to CloudShell. Since Steampipe will default to your local AWS credentials, from a cold start, you're querying AWS APIs with SQL in a matter of seconds.</p> <h3> Install Steampipe in CloudShell </h3> <p>Go to your AWS CloudShell, install Steampipe:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>$ sudo /bin/sh -c "$(curl -fsSL https://raw.githubusercontent.com/turbot/steampipe/main/install.sh)" ... Installing Applying necessary permissions Steampipe was installed successfully to /usr/local/bin/steampipe </code></pre> </div> <h3> Install the AWS plugin </h3> <p>Now with Steampipe installed, you can install the AWS plugin:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>$ steampipe plugin install aws Installed plugin: aws v0.57.0 Documentation: https://hub.steampipe.io/plugins/turbot/aws </code></pre> </div> <h3> Run a SQL query! </h3> <p>Now you are ready to run a SQL query. Since CloudShell already has the credentials in place, you can simply get started:<br> </p> <div class="highlight js-code-highlight"> <pre class="highlight plaintext"><code>$ steampipe query Welcome to Steampipe v0.13.6 For more information, type .help &gt; select * from aws_s3_bucket +--------------------------------------+ | name | +--------------------------------------+ | jon-turbot-test-bucket-01 | | cf-templates-1s5tzrjxv4j52-us-west-1 | +--------------------------------------+ </code></pre> </div> <p>CloudShell takes full advantage of the Steampipe CLI components so you can inspect tables, configure environment variables, visualize syntax highlighting, select autofill suggestions, etc.</p> <p><a href="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi89pabdtdrmaz4afvsid.gif" class="article-body-image-wrapper"><img src="proxy.php?url=https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fi89pabdtdrmaz4afvsid.gif" alt=" " width="760" height="427"></a></p> <h2> Final Thoughts </h2> <p>I enjoy using AWS CloudShell for ad hoc actions with AWS CLI and Steampipe within a specific AWS Account. Interested to learn from others on how you use CloudShell in your environment; what are your use cases and how often do you use CloudShell?</p> aws sql cloudshell steampipe