<?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[superluminar - Medium]]></title>
        <description><![CDATA[superluminar Blog - Medium]]></description>
        <link>https://medium.com/superluminar?source=rss----822c705d0924---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>superluminar - Medium</title>
            <link>https://medium.com/superluminar?source=rss----822c705d0924---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 11:17:34 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/superluminar" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Getting notified for underutilized AWS Savings Plans or Reserved Instances with CDK Typescript]]></title>
            <link>https://medium.com/superluminar/getting-notified-for-underutilized-aws-savings-plans-or-reserved-instances-with-cdk-typescript-f55d60c57145?source=rss----822c705d0924---4</link>
            <guid isPermaLink="false">https://medium.com/p/f55d60c57145</guid>
            <dc:creator><![CDATA[Soenke Ruempler]]></dc:creator>
            <pubDate>Thu, 06 May 2021 08:57:30 GMT</pubDate>
            <atom:updated>2021-05-06T09:10:43.514Z</atom:updated>
            <content:encoded><![CDATA[<h3>Situation</h3><p>You want to be notified via email whenever an AWS Savings Plan or Reserved Instances (e.g. EC2, RDS, ES Service) is not utilized completely. You want to use CDK/Typescript as Infrastructure-as-Code tooling.</p><h3>Challenge</h3><p>When using CDK, there is currently no L2 construct available, so finding out the correct syntax (Typescript) might be cumbersome.</p><h3>Solution</h3><h4>Example 1: Compute Savings Plan (replace &lt;YOUR EMAIL ADDRESS&gt; with your email address):</h4><pre>import * as cdk from &#39;@aws-cdk/core&#39;;<br>import { CfnBudget } from &#39;@aws-cdk/aws-budgets&#39;;<br><br>export class SavingsPlanBudgetAlarmStack extends cdk.Stack {<br>  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {<br>    super(scope, id, props);<br><br>    new CfnBudget(this, &#39;SavingsPlanUtilizationBudgetAlarm&#39;, {<br>      budget: {<br>        budgetType: &#39;SAVINGS_PLANS_UTILIZATION&#39;,<br>        timeUnit: &#39;DAILY&#39;,<br>      },<br>      notificationsWithSubscribers: [<br>        {<br>          notification: {<br>            comparisonOperator: &#39;LESS_THAN&#39;,<br>            notificationType: &#39;ACTUAL&#39;,<br>            threshold: 100,<br>            thresholdType: &#39;PERCENTAGE&#39;,<br>          },<br>          subscribers: [ { address: &#39;<strong>&lt;YOUR EMAIL ADDRESS&gt;</strong>&#39;, subscriptionType: &#39;EMAIL&#39; },<br>        },<br>      ],<br>    });<br>  }<br>}</pre><h4>Example 2: RDS Reserved Instances (replace &lt;YOUR EMAIL ADDRESS&gt; with your email address):</h4><pre>import * as cdk from &#39;@aws-cdk/core&#39;;<br>import { CfnBudget } from &#39;@aws-cdk/aws-budgets&#39;;<br><br>export class RdsRIBudgetAlarmStack extends cdk.Stack {<br>  constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {<br>    <br>    super(scope, id, props);<br>    new CfnBudget(this, &#39;RIUtilizationRDSBudgetAlarm&#39;, {<br>      budget: {<br>        budgetType: &#39;RI_UTILIZATION&#39;,<br>        timeUnit: &#39;DAILY&#39;,<br>        costFilters: {<br>          Service: [&#39;Amazon Relational Database Service&#39;],<br>        },<br>      },<br>      notificationsWithSubscribers: [<br>        {<br>          notification: {<br>            comparisonOperator: &#39;LESS_THAN&#39;,<br>            notificationType: &#39;ACTUAL&#39;,<br>            threshold: 100,<br>            thresholdType: &#39;PERCENTAGE&#39;,<br>          },<br>          subscribers: [ { address: &#39;<strong>&lt;YOUR EMAIL ADDRESS&gt;</strong>&#39;, subscriptionType: &#39;EMAIL&#39; },<br>        },<br>      ],<br>    });<br>  }<br>}</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f55d60c57145" width="1" height="1" alt=""><hr><p><a href="https://medium.com/superluminar/getting-notified-for-underutilized-aws-savings-plans-or-reserved-instances-with-cdk-typescript-f55d60c57145">Getting notified for underutilized AWS Savings Plans or Reserved Instances with CDK Typescript</a> was originally published in <a href="https://medium.com/superluminar">superluminar</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debugging failing OU (re-)registering in AWS Control Tower]]></title>
            <link>https://medium.com/superluminar/debugging-failing-ou-re-registering-in-aws-control-tower-b5e0a8b13845?source=rss----822c705d0924---4</link>
            <guid isPermaLink="false">https://medium.com/p/b5e0a8b13845</guid>
            <dc:creator><![CDATA[Soenke Ruempler]]></dc:creator>
            <pubDate>Wed, 05 May 2021 15:07:44 GMT</pubDate>
            <atom:updated>2021-05-07T06:49:00.489Z</atom:updated>
            <content:encoded><![CDATA[<h4>Situation</h4><p>You want to register or re-register an AWS Organizations OU in AWS Control Tower, e.g. to trigger the UpdateManagedAccount event.</p><p>If the re-registering fails, Contol Tower only shows “Internal failure” and no more debugging information.</p><h4>Challenge</h4><p>There is a good chance that Control Tower failed to update its own CloudFormation StackSets (those prefixed with AWSControlTowerBP-BASELINE-). For performance reasons, Control Tower starts stack set operations with a fault tolerance of 100% which in turn cascades individual errors in stack instances. This information is not shown in the AWS Console, but in the CLI/API:</p><pre>$ aws cloudformation describe-stack-set-operation --operation-id nnnnnn-nnnn-nnnn-nnnn-nnnnnnnnn  --stack-set-name AWSControlTowerBP-BASELINE-CLOUDWATCH<br>{<br>    &quot;StackSetOperation&quot;: {<br>        &quot;OperationId&quot;: &quot;nnnnnn-nnnn-nnnn-nnnn-nnnnnnnnn&quot;,<br>        &quot;StackSetId&quot;: &quot;AWSControlTowerBP-BASELINE-CLOUDWATCH:nnnnn-07fd-4162-96dd-ccb2d884ff4d&quot;,<br>        &quot;Action&quot;: &quot;UPDATE&quot;,<br>        &quot;Status&quot;: &quot;SUCCEEDED&quot;,<br>        &quot;OperationPreferences&quot;: {<br>            &quot;RegionOrder&quot;: [],<br><strong>            &quot;FailureTolerancePercentage&quot;: 100,<br>            &quot;MaxConcurrentPercentage&quot;: 100</strong><br>        },<br>        &quot;AdministrationRoleARN&quot;: &quot;arn:aws:iam::123456789012:role/service-role/AWSControlTowerStackSetRole&quot;,<br>        &quot;ExecutionRoleName&quot;: &quot;AWSControlTowerExecution&quot;,<br>        &quot;CreationTimestamp&quot;: &quot;2021-05-05T14:13:05.709000+00:00&quot;,<br>        &quot;EndTimestamp&quot;: &quot;2021-05-05T14:15:00.903000+00:00&quot;<br>    }<br>}</pre><h4>Solution</h4><p>To find individual failed stack instances, one has to look through the stack set operations of the AWSControlTowerBP-BASELINE- stack sets. This can be done with the following command:</p><pre>$ aws cloudformation list-stack-set-operation-results --operation-id nnnnnn-nnnn-nnnn-nnnn-nnnnnnnnn  --stack-set-name AWSControlTowerBP-BASELINE-CLOUDWATCH --query &#39;Summaries[?Status == `FAILED`]&#39;<br>[<br>    {<br>        &quot;Account&quot;: &quot;&lt;<strong>ACCOUNT_ID_OF_FAILED_STACK&gt;</strong>&quot;,<br>        &quot;Region&quot;: &quot;&lt;<strong>REGION_OF_FAILED_STACK&gt;</strong>&quot;,<br>        &quot;Status&quot;: &quot;FAILED&quot;,<br>        &quot;StatusReason&quot;: &quot;Stack:arn:aws:cloudformation:&lt;<strong>REGION_OF_FAILED_STACK&gt;</strong>:&lt;<strong>ACCOUNT_ID_OF_FAILED_STACK&gt;</strong>:stack/StackSet-AWSControlTowerBP-BASELINE-CLOUDWATCH-nnnnnn-nnnn-nnnn-nnnn-nnnnnnnnn/nnnnnn-nnnn-nnnn-nnnn-nnnnnnnnn is in DELETE_FAILED state and can not be updated.&quot;,<br>         ...<br>    }<br>]</pre><p>Now with this information, it’s possible to debug the failed stack operation in the ACCOUNT_ID_OF_FAILED_STACK AWS sub-account in the REGION_OF_FAILED_STACK region. Good luck!</p><p>Special thanks go to the Control Tower Support Engineer Karan who helped us with this debugging session!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b5e0a8b13845" width="1" height="1" alt=""><hr><p><a href="https://medium.com/superluminar/debugging-failing-ou-re-registering-in-aws-control-tower-b5e0a8b13845">Debugging failing OU (re-)registering in AWS Control Tower</a> was originally published in <a href="https://medium.com/superluminar">superluminar</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 wait for and intercept a particular HTTP request in Puppeteer]]></title>
            <link>https://medium.com/superluminar/how-to-wait-for-and-intercept-a-particular-http-request-in-puppeteer-66863a8403fe?source=rss----822c705d0924---4</link>
            <guid isPermaLink="false">https://medium.com/p/66863a8403fe</guid>
            <dc:creator><![CDATA[Soenke Ruempler]]></dc:creator>
            <pubDate>Tue, 23 Feb 2021 13:41:18 GMT</pubDate>
            <atom:updated>2021-08-17T11:14:21.555Z</atom:updated>
            <content:encoded><![CDATA[<p>Situation: In Puppeteer, one sometimes needs to wait for a particular HXR request (e.g., a particular URL has been called to happen) after a particular action (e.g., clicking a button), and you need the HTTP response object of that particular request.</p><p>Complication: There is page.waitForResponse but it only returns the values after e.g. Puppeteer.click has been called:</p><pre>await page.click(&#39;some_identifier&#39;)</pre><pre>// HXR request to wait for / intercept happens here</pre><pre>const httpResponseWeWaitFor = await page.waitForResponse((response) =&gt; {<br>    // it&#39;s already too late here to wait for / intercept the XHR request<br>    return response.url().startsWith(&quot;https://somesample&quot;) // this signals to puppeteer that we found the response we waited for<br>});</pre><p>Solution:</p><p>Use a promise to wait for the correct HTTP response (remove the await, do the action which fires the XHR (click in this example), and then solve the promise with await :</p><pre>// don&#39;t wait for waitForResponse, but continue by omitting await<br>const httpResponseWeWaitForPromise = page.waitForResponse((response) =&gt; {<br>    return response.url().startsWith(&quot;https://somesample&quot;)<br>});</pre><pre>// HXR request to wait for / intercept happens here<br>await page.click(&#39;some_identifier&#39;)</pre><pre>// wait for the Promise to get resolved<br>const httpResponseWeWait = await httpResponseWeWaitForPromise;</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=66863a8403fe" width="1" height="1" alt=""><hr><p><a href="https://medium.com/superluminar/how-to-wait-for-and-intercept-a-particular-http-request-in-puppeteer-66863a8403fe">How to wait for and intercept a particular HTTP request in Puppeteer</a> was originally published in <a href="https://medium.com/superluminar">superluminar</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Waiting for AWS EventBridge events with AWS CloudFormation wait conditions]]></title>
            <link>https://medium.com/superluminar/waiting-for-aws-eventbridge-events-with-aws-cloudformation-wait-conditions-456d0326f95b?source=rss----822c705d0924---4</link>
            <guid isPermaLink="false">https://medium.com/p/456d0326f95b</guid>
            <dc:creator><![CDATA[Soenke Ruempler]]></dc:creator>
            <pubDate>Tue, 10 Nov 2020 08:23:57 GMT</pubDate>
            <atom:updated>2020-11-10T08:26:33.235Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS CloudFormation has a feature called <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-waitcondition.html">wait conditions</a>, which is basically a generic way to wait for something to finish in CloudFormation before continuing resource creation. Typical examples include waiting for an EC2 instance to be set up to be attached to a load balancer.</p><p>But there are other use cases, for example:</p><ul><li>Waiting for CloudWatch Alarm to become OK,</li><li>Control Tower Landing Zone set up to be finished.</li></ul><p>In this post, we will walk through an example which creates a Wait Condition that waits for a CloudWatch Alarm to become “green” / OK state.</p><p>We use the following building blocks:</p><ul><li>A CloudFormation <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-waitcondition.html">WaitCondition</a> and <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-waitconditionhandle.html">WaitConditionHandle</a></li><li>A CloudWatch alarm that <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/monitoring/cloudwatch-and-eventbridge.html">emits state changes via CloudWatch Events / EventBridge</a></li><li>A Lambda function which will get triggered by EventBridge and signals CloudFormation to continue</li><li><a href="https://docs.aws.amazon.com/serverless-application-model/latest/developerguide/sam-specification.html">SAM Serverless transforms</a> to ease the setup of the Lambda function</li></ul><p>First, let’s start with the CloudFormation header. As mentioned, we use Serverless transforms.</p><pre>AWSTemplateFormatVersion: 2010-09-09<br>Transform: AWS::Serverless-2016-10-31</pre><p>Next, we add the wait condition and its handle:</p><pre>AlarmOkHandle:<br>  Type: AWS::CloudFormation::WaitConditionHandle<br><br>AlarmOkWaitCondition:<br>  Type: AWS::CloudFormation::WaitCondition<br>  Properties:<br>    Handle: !Ref AlarmOkHandle<br>    Timeout: 3600</pre><p>Now let’s add an example CloudWatch alarm, which should become OK during CloudFormation stack creation.</p><pre>Alarm:<br>  Type: AWS::CloudWatch::Alarm<br>  Properties:<br>    ComparisonOperator: GreaterThanOrEqualToThreshold<br>    Dimensions:<br>      - Name: FunctionName<br>        Value: SampleFunction<br>    EvaluationPeriods: 1<br>    MetricName: Errors<br>    Namespace: AWS/Lambda<br>    Period: 180<br>    Statistic: Sum<br>    Threshold: &#39;1&#39;</pre><p>This sample alarm checks for errors in Lambda invocations of the functionSampleFunction. But you can use any CloudWatch Alarm you want here.</p><p>Okay, now let&#39;s add the “magic” that wires the CludFormation wait condition and the CloudWatch alarm. For that, we use a Lambda function which listens on an EventBridge event which CloudWatch Alarm emits on Alarm State changes, such as transitioning from ALARM to OK:</p><pre>AlarmOkTriggerFunction:<br>  Type: AWS::Serverless::Function<br>  Properties:<br>    Events:<br>      Alarm:<br>        Type: CloudWatchEvent<br>        Properties:<br>          Pattern:<br>            detail-type:<br>              - CloudWatch Alarm State Change<br>            source:<br>              - aws.cloudwatch<br>            detail:<br>              alarmName:<br>                - !Ref Alarm<br>              state:<br>                value:<br>                  - OK<br>    Handler: index.handler<br>    Environment:<br>      Variables:<br>        SIGNAL_URL: !Ref AlarmOkHandle<br>    InlineCode: |-<br>      import json<br>      import os<br>      import urllib3<br>      import uuid<br><br>      def handler(event, context):<br><br>        encoded_body = json.dumps({<br>            &quot;Status&quot;: &quot;SUCCESS&quot;,<br>            &quot;Reason&quot;: &quot;Rootmail Setup completed&quot;,<br>            &quot;UniqueId&quot;: str(uuid.uuid4()),<br>            &quot;Data&quot;: &quot;Rootmail Setup completed&quot;<br>        })<br><br>        http = urllib3.PoolManager()<br>        http.request(&#39;PUT&#39;, os.environ[&#39;SIGNAL_URL&#39;], body=encoded_body)<br>    Runtime: python3.7<br>    Timeout: 10</pre><p>Several things to consider for the AlarmOkTriggerFunction Lambda function:</p><ul><li>We use AWS SAM TransformAWS::Serverless::Function which eases the Event trigger part and the permissions: We don’t have to mess around with IAM.</li><li>The function listens on one event called Alarm . This event is triggered on every state change to OKof the alarm specified in alarmName .</li><li>The function consists of a few lines of inline code that will post to the signal URL provided by CloudFormation. An environment variable passes the signal URL.</li></ul><p>CloudFormation will now wait for the wait condition AlarmOkWaitCondition to be created (until the AlarmOkTriggerFunction Lambda sends the signal) before continuing.</p><p>Now we can make other resource creations in the CloudFormation template depending on AlarmOkWaitConditionto finish by using the DependsOn CloudFormation feature.</p><h3>Summary</h3><p>In this article, you learned how to combine CloudFormation wait conditions, EventBridge, and Lambda to wait in CloudFormation stacks for a particular EventBridge event to happen.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=456d0326f95b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/superluminar/waiting-for-aws-eventbridge-events-with-aws-cloudformation-wait-conditions-456d0326f95b">Waiting for AWS EventBridge events with AWS CloudFormation wait conditions</a> was originally published in <a href="https://medium.com/superluminar">superluminar</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Painlessly assume IAM roles in CLI scripts with dynamic AWS CLI profiles]]></title>
            <link>https://medium.com/superluminar/painlessly-assume-iam-roles-in-cli-scripts-with-dynamic-aws-cli-profiles-bd28ed22c8bb?source=rss----822c705d0924---4</link>
            <guid isPermaLink="false">https://medium.com/p/bd28ed22c8bb</guid>
            <category><![CDATA[aws-cli]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-codebuild]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[aws-security]]></category>
            <dc:creator><![CDATA[Soenke Ruempler]]></dc:creator>
            <pubDate>Sun, 26 Jul 2020 19:13:23 GMT</pubDate>
            <atom:updated>2020-07-27T08:39:41.506Z</atom:updated>
            <content:encoded><![CDATA[<p>Often, it’s necessary to assume another IAM role in AWS CLI scripts — apart from the current IAM role, e.g., in CI systems like AWS CodeBuild. For example:</p><ul><li><strong>Cross AWS account access:</strong> In a multi-account AWS Setup, several tasks require assuming an IAM role in another AWS account.</li><li><strong>Functional roles:</strong> To scope down privileges or to gain privileged access, sometimes AWS users have to assume another IAM role for a temporary session.</li></ul><p>In a local/static environment, one would preferably use AWS CLI profiles with source_profile.</p><p>But what about more dynamic environments with no AWS CLI config and profiles previously set up, for example, a CI environment? Or, situations, when the IAM role to assume is not yet known and dynamically synthesized based on input to the CI build step? Then (e.g., without AWS CLI profiles at hand) assuming another IAM role usually works like this:</p><ul><li>Call aws sts assume-role</li><li>Export the credentials into the environment.</li></ul><p>Such assume-role “hacks” with <a href="https://bliskavka.com/2019/08/14/AWS-Assume-Role/">more or less messy scripts involving </a><a href="https://bliskavka.com/2019/08/14/AWS-Assume-Role/">jq</a> or <a href="https://gist.github.com/ambakshi/ba0fe456bb6da24da7c2">bash array magic</a> can be found in the wild as the defacto solution. Additional difficulties with this way are changing back to the original IAM role, or even having to deal with several different IAM roles to assume. One usually ends up with setting/unsetting ENV variables and eventually might get confused about the currently assumed IAM role.</p><p>A cleaner and more native way would be great.</p><p><strong>Luckily, there is a native way with AWS CLI, since it’s able to create CLI profiles on the fly dynamically</strong>.</p><p>Let’s have a look at the following (for demo purposes simple) example: Imagine you want to list all S3 buckets in another AWS Account within an AWS CodeBuild buildspec. The sample IAM role to assume in the S3 bucket has the ARN arn:aws:iam::123456789012:role/S3Access</p><p>Two lines of AWS CLI setup code allow us to use dynamically assume and use this role:</p><pre>$ aws configure --profile s3access set role_arn arn:aws:iam::123456789012:role/S3Access<br>$ aws configure --profile s3access set credential_source EcsContainer</pre><p>The first line instructs the AWS CLI to create a new CLI profile s3access on the fly, and to use the desired IAM role arn:aws:iam::123456789012:role/S3Access.<br>(You might already use this for your local/dev machine in combination with <a href="https://docs.aws.amazon.com/credref/latest/refdocs/setting-global-source_profile.html">source_profile</a>.</p><p><strong>The “magic sauce” is the second line</strong>: <a href="https://docs.aws.amazon.com/credref/latest/refdocs/setting-global-credential_source.html">credentials_source tells the AWS CLI where to look for the source credentials</a> for the iam assume-role call which it implicitly does when calling it with the s3access profile. For CodeBuild, it’s EcsContainer since CodeBuild itself seems to use ECS under the hood. (Currently, it’s also possible to use Environment for environment variables, or Ec2InstanceMetadata for EC2 instances.)</p><p>Now, you can seamlessly use the AWS CLI with the profile, and it will handle all the assume-role stuff invisible to the user:</p><pre>$ aws --profile s3access s3api list-buckets</pre><p>That’s it. No environment variables or jq and friends have been harmed. You could also add more temporary/dynamic environments based on your use case.</p><p>For your reference a complete sample CodeBuild buildspec:</p><pre>version: 0.2<br>phases:<br>  build:<br>    commands:<br>      - aws configure --profile s3access set role_arn arn:aws:iam::123456789012:role/S3Access<br>      - aws configure --profile s3access set credential_source EcsContainer<br>      - aws --profile s3access s3api list-buckets</pre><h4>Summary</h4><p>In this post, I showed how to dynamically create AWS CLI profiles within dynamic environments like, for example, AWS CodeBuild.</p><p>These dynamically created AWS CLI profiles allow seamless switching between IAM roles without messing around with e.g. jq and environment variables.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bd28ed22c8bb" width="1" height="1" alt=""><hr><p><a href="https://medium.com/superluminar/painlessly-assume-iam-roles-in-cli-scripts-with-dynamic-aws-cli-profiles-bd28ed22c8bb">Painlessly assume IAM roles in CLI scripts with dynamic AWS CLI profiles</a> was originally published in <a href="https://medium.com/superluminar">superluminar</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inexpensive waiting in AWS CodePipeline with Step Functions]]></title>
            <link>https://medium.com/superluminar/inexpensive-waiting-in-aws-codepipeline-with-step-functions-4cd2839d13bc?source=rss----822c705d0924---4</link>
            <guid isPermaLink="false">https://medium.com/p/4cd2839d13bc</guid>
            <category><![CDATA[step-functions]]></category>
            <category><![CDATA[aws-codepipeline]]></category>
            <category><![CDATA[continuous-delivery]]></category>
            <category><![CDATA[continuous-integration]]></category>
            <dc:creator><![CDATA[Soenke Ruempler]]></dc:creator>
            <pubDate>Fri, 03 Jul 2020 09:04:30 GMT</pubDate>
            <atom:updated>2020-07-03T10:24:31.859Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS CodePipeline is an excellent service to deploy software and infrastructure in an automated, codified, and repeatable way.</p><p>A while ago, I was faced with the situation that I needed a CodePipeline to wait for an external step to finish. First, I thought of invoking a Lambda or CodeBuild step to “sleep,” but that’s rather wasteful to pay for waiting, isn’t it?</p><p>Luckily, quite recently, AWS launched <a href="https://aws.amazon.com/about-aws/whats-new/2020/05/codepipeline-supports-invoking-step-functions-with-a-new-action-type/">Step Functions support for CodePipeline</a>, which means that it’s now possible to execute a Step Function directly as a CodePipeline action. Step Functions has <a href="https://docs.aws.amazon.com/step-functions/latest/dg/amazon-states-language-wait-state.html">native support for a “wait” Task</a>, and the billing is not per time, but per state transition, so idling does not cost money.</p><p>Let’s have a look at how to implement this. We will use CloudFormation to build a sample CodePipeline.</p><p>First, we create a CodePipeline:</p><pre>Pipeline:<br>  Type: AWS::CodePipeline::Pipeline<br>  Properties:<br>    RoleArn: !GetAtt PipelineServiceRole.Arn<br>    Stages:<br>      - Name: Source<br>        Actions:<br>          - Name: SourceAction<br>            ...<br>      - Name: DoSomeThingAndWait<br>        Actions:<br>          - Name: InvokeSomethingExternal<br>            ActionTypeId:<br>              Category: Build<br>              Owner: AWS<br>              Provider: CodeBuild<br>              Version: &quot;1&quot;<br>            Configuration:<br>              ProjectName: !Ref CodeBuildProject<br>            InputArtifacts:<br>              - Name: SourceOutput<br>            RunOrder: 1<br><strong>          - Name: Wait60Minutes<br>            ActionTypeId:<br>              Category: Invoke<br>              Owner: AWS<br>              Provider: StepFunctions<br>              Version: &quot;1&quot;<br>            Configuration:<br>              StateMachineArn: !Ref WaitStateMachine<br>            InputArtifacts:<br>              - Name: SourceOutput<br>            RunOrder: 2</strong><br>          - Name: DoSomethingAfterWaiting60Minutes<br>            ActionTypeId:<br>              ...<br>            RunOrder: 3</pre><p>This sample pipeline consists of two stages, Source and DoSomeThingAndWait. The magic happens in the DoSomeThingAndWait stage: First, we execute a CodeBuild action InvokeSomethingExternal— imagine this triggers an external API, and the following stages/actions have to wait for that to finish. Let&#39;s say this job usually takes 60 minutes to continue. The second step (note the RunOrder of 2) invokes a Step Function, which in turn waits for 60 minutes. After that, the CodePipeline continues with theDoSomethingAfterWaiting60Minutes action (RunOrder: 3).</p><p>Let’s have a look at the definition of the Step Function:</p><pre>WaitStateMachine:<br>  Type: AWS::Serverless::StateMachine<br>  Properties:<br>    Definition:<br><strong>      StartAt: Wait<br>      States:<br>        Wait:<br>          Type: Wait<br>          Seconds: 3600<br>          End: true</strong><br>    Policies:<br>      - CloudWatchPutMetricPolicy: {}</pre><p>The code above defines a minimal Step Function with a single Wait state, which is the start and the end at the same time. We use the <a href="https://aws.amazon.com/about-aws/whats-new/2020/05/aws-sam-adds-support-for-aws-step-functions/">SAM integration for Step Functions</a> here so we can define the function inline in YAML, and we don&#39;t have to use JSON, the native Step Functions language. To make this work, one has to add the following Transform to the CloudFormation template:</p><pre>Transform: AWS::Serverless-2016-10-31</pre><p>Finally, the IAM Role for Codepipeline needs additional permissions to invoke the Step Function:</p><pre>PipelineServiceRole:<br>  Type: AWS::IAM::Role<br>  Properties:<br>    AssumeRolePolicyDocument:<br>      Version: 2012-10-17<br>      Statement:<br>        - Effect: Allow<br>          Principal:<br>            Service: codepipeline.amazonaws.com<br>          Action: sts:AssumeRole<br>    Policies:<br>      - PolicyName: !Sub ${AWS::StackName}-pipeline-role-policy<br>        PolicyDocument:<br>          Version: 2012-10-17<br>          Statement:<br><strong>            - Action:<br>                - states:DescribeStateMachine<br>                - states:StartExecution<br>              Effect: Allow<br>              Resource: !Ref WaitStateMachine<br>            - Action: states:DescribeExecution<br>              Effect: Allow<br>              Resource: !Sub arn:${AWS::Partition}:states:${AWS::Region}:${AWS::AccountId}:execution:${WaitStateMachine.Name}:*</strong></pre><p>That’s it! You now have a cheap solution to wait :) No pay for idle!</p><h3>Summary</h3><p>This article showed how to use the Step Functions integration in CodePipeline to create a “wait” step. It’s possible to extend the Step Function; for example, it could loop and periodically check if the external task has finished.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4cd2839d13bc" width="1" height="1" alt=""><hr><p><a href="https://medium.com/superluminar/inexpensive-waiting-in-aws-codepipeline-with-step-functions-4cd2839d13bc">Inexpensive waiting in AWS CodePipeline with Step Functions</a> was originally published in <a href="https://medium.com/superluminar">superluminar</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A look at the AWS::CloudFormation::StackSet Resource]]></title>
            <link>https://medium.com/superluminar/a-look-at-the-aws-cloudformation-stackset-resource-18ae0d89dfc6?source=rss----822c705d0924---4</link>
            <guid isPermaLink="false">https://medium.com/p/18ae0d89dfc6</guid>
            <dc:creator><![CDATA[Soenke Ruempler]]></dc:creator>
            <pubDate>Fri, 19 Jun 2020 18:19:22 GMT</pubDate>
            <atom:updated>2020-09-18T14:00:00.358Z</atom:updated>
            <content:encoded><![CDATA[<p>At superluminar, we usually use AWS CloudFormation as the deployment tool of our choice because it is a very proven and robust service: Since CloudFormation is a managed service, there are no costs for installation, maintenance, or updates, such as, e.g., with Terraform.</p><h3>The limits of CloudFormation</h3><p>However, CloudFormation often quickly reaches its limits. Until recently, more complex dependencies/orchestrations could not be represented natively, for example:</p><ul><li>Orchestration of StackSets and dependencies across accounts, e.g., “Create X in Account Y, then Z in Account B.”</li><li>Cross-region deployments of individual resources, e.g., “Create ACM certificate for CloudFront in us-east-1, but the S3 bucket in eu-central-1”</li></ul><p><a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html">Workarounds</a> have been possible with <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/template-custom-resources.html">CloudFormation Custom Resources</a>, which <a href="https://blog.codinghorror.com/the-best-code-is-no-code-at-all/">in turn have (follow-up) costs</a>.</p><p>While CloudFormation StackSets provide a native way to roll out CloudFormation stacks across regions, AWS accounts, or entire organizational units, it has not been possible yet to manage StackSets with CloudFormation.</p><h3>Solution: The AWS::Cloudformation::StackSet resource</h3><p>The new <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-cloudformation-stackset.html">AWS::Cloudformation::StackSet</a> resource looks promising because it allows us to define StackSets using CloudFormation templates.</p><p>Let’s have a look at a few examples.</p><h3>Example: Generate ACM certificate in another region</h3><p>Let’s look at how to generate an ACM certificate in a different region than the original stack. This situation can happen, for example, if you have to create an ACM Certificate for CloudFront in us-east-1 , but your CloudFormation Stack “lives” in another region:</p><pre>Resources:<br>  CertificateInUsEast1:<br>    Type: AWS::CloudFormation::StackSet<br>    Properties:<br>      StackSetName: !Ref AWS::StackName<br>      PermissionModel: SELF_MANAGED<br>      StackInstancesGroup:<br>        - Regions:<br>            - us-east-1<br>          DeploymentTargets:<br>            Accounts:<br>              - !Ref AWS::AccountId<br>      TemplateBody: |<br>        Resources:<br>          Certificate:<br>            Type: AWS::CertificateManager::Certificate<br>            Properties:<br>              DomainName: ssl.superluminar.io</pre><p>In this example, CloudFormation creates a StackSet using the CertificateInUsEast1 resource, which rolls out a CloudFormation stack in the same AWS account into the us-east-1 region. This stack then contains the Certificate resource.</p><p>The permission model used is SELF_MANAGED, meaning that you may have to provide roles for CloudFormation in the executing account ( AdministrationRoleARN) as well as for the sub-accounts ( ExecutionRoleName). If you use AWS Landing Zone or AWS Control Tower to create and manage AWS accounts in your AWS organization, your AWS setup is already prepared if you want to create StackSets from your AWS Organizations Master Account:</p><ul><li>With AWS Landing Zone, the defaults for AdministrationRoleARN and ExecutionRoleName are already correct.</li><li>If you use AWS Control Tower, for AdministrationRoleARNuse the role AWSControlTowerStackSetRole, and for ExecutionRoleNameuse AWSControlTowerExecution.</li></ul><h3>Example 2: Rolling out a stack over a specific OU</h3><p>The following example shows how you can roll out resources in the entire AWS Organization or specific organizational units (OU). In this case, the Security Hub is activated in every account of the OU, which is specified with the parameter OU:</p><pre>Parameters:<br>  OU:<br>    Type: String</pre><pre>Resources:<br>  Stackset:<br>    Type: AWS::CloudFormation::StackSet<br>    Properties:<br>      StackSetName: !Sub ${AWS::StackName}<br>      PermissionModel: SERVICE_MANAGED<br>      AutoDeployment:<br>        Enabled: true<br>        RetainStacksOnAccountRemoval: false<br>      StackInstancesGroup:<br>        - Regions:<br>          - !Ref AWS::Region<br>          DeploymentTargets:<br>            OrganizationalUnitIds:<br>              - !Ref OU<br>      TemplateBody: |<br>        Resources:<br>          SecurityHub:<br>            Type: AWS::SecurityHub::Hub</pre><h3>Noteworthy</h3><ul><li>The outputs of the stacks created using StackSets are not easily accessible. If you want to reference something from the sub-template, the only way is to synthesize the resource names / ARNs. This is not always possible, e.g., B. with generated ARNs such as ACM certificates.</li><li>StackSets have <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/cloudformation-limits.html">limits</a>, namely 100 StackSets per account and region, but you can increase these limits via a support ticket.</li><li>The AWS::Cloudformation::StackSet CloudFormation resource is open-source as a <a href="https://github.com/aws-cloudformation/aws-cloudformation-resource-providers-cloudformation/tree/master/aws-cloudformation-stackset/">CloudFormation Resource Provider</a>.</li></ul><h3>Conclusion</h3><p>The native AWS::Cloudformation::StackSet CloudFormation resource can simplify resource management across AWS accounts, organizational units, and regions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18ae0d89dfc6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/superluminar/a-look-at-the-aws-cloudformation-stackset-resource-18ae0d89dfc6">A look at the AWS::CloudFormation::StackSet Resource</a> was originally published in <a href="https://medium.com/superluminar">superluminar</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Automated backups of your AWS resources with AWS Backup]]></title>
            <link>https://medium.com/superluminar/automated-backups-of-your-aws-resources-with-aws-backup-4d076c86079?source=rss----822c705d0924---4</link>
            <guid isPermaLink="false">https://medium.com/p/4d076c86079</guid>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[superluminar]]></dc:creator>
            <pubDate>Fri, 19 Jun 2020 12:31:34 GMT</pubDate>
            <atom:updated>2020-09-16T18:13:11.560Z</atom:updated>
            <content:encoded><![CDATA[<p>What are the best backups? Correct, those done automatically in a consistent way and which can be reliably restored every time.</p><p><strong>AWS Backup</strong> is a relatively new service that tackles the problem of consistent backups and restore. For a general introduction, I highly recommend <a href="https://cloudonaut.io/review-aws-backup/">the cloudonaut review on AWS Backup</a>.</p><p>In this post, I will give you an overview of how to automate backups by combining AWS Backup and AWS CloudFormation.</p><p>First, let&#39;s have a short look at the AWS Backup terminology:</p><ul><li>The “<strong>backup vault”</strong> is a storage container for backups.</li><li>A <strong>“backup plan” </strong>is the scheduler for backups. You can specify when backups should be done in a cron-like syntax. The backup plan is attached to a <strong>backup vault</strong>.</li><li>A “<strong>resource assignment</strong>” or “<strong>backup selection</strong>” defines which resources should be backed up. Currently, selecting resources by tags or by resource ARN is possible. The <strong>backup selection</strong> is attached to a <strong>backup plan</strong>.</li><li>A “<strong>recovery point”</strong> is a snapshot/backup of a resource backed up by AWS Backup. Each recovery point can be restored with AWS Backup.</li></ul><p>And you know what’s really cool? AWS Backup can be fully automated by using AWS CloudFormation. In this example, I show you how to backup all currently supported resource types (EBS, RDS, DynamoDB, EFS) which are tagged with theBackupMe / daily pair:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8be60de253fd524d00911aec33b9139d/href">https://medium.com/media/8be60de253fd524d00911aec33b9139d/href</a></iframe><p>This example consists of four CloudFormation resources:</p><ul><li>An IAM Role: AWS Backup needs a service role to do its work in your AWS account. It uses an AWS managed IAM policy to minimize work to be done here.</li><li>A basic backup vault BackupVault is the container for the backups.</li><li>A backup plan tells AWS Backup to back up resources each day at five o’clock in the morning. The syntax used by AWS Backup is the same as in <a href="https://docs.aws.amazon.com/AmazonCloudWatch/latest/events/ScheduledEvents.html">CloudWatch Events</a>.</li><li>A backup selection which looks for resources being tagged with BackupMe / daily .</li></ul><p>Once deployed via CloudFormation, AWS Backup will start to create daily backups of (supported) resources tagged with BackupMe / daily — in this example, a DynamoDB table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cNU94gRroe58xMmi4bgA6g.png" /><figcaption>Automated backups of a sample DynamoDB table</figcaption></figure><p>That’s it!</p><p>You can easily add more backup selections and plans for your particular workloads and scenarios.</p><p>PS: It’s currently not supported to backup ALL resources of a particular type since AWS Backup does not allow ARNs in backup selections even if the <a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-backup-backupselection-backupselectionresourcetype.html#cfn-backup-backupselection-backupselectionresourcetype-resources">documentation in CloudFormation states it</a>.</p><p>PPS: AWS Backup currently does not support cross AWS account or even off-site backups yet, but the backups remain in the same AWS account as the source. So you should at least protect the backups via preventive guardrails (Service Control Policies). We plan to show you how to do this in a following blog post.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4d076c86079" width="1" height="1" alt=""><hr><p><a href="https://medium.com/superluminar/automated-backups-of-your-aws-resources-with-aws-backup-4d076c86079">Automated backups of your AWS resources with AWS Backup</a> was originally published in <a href="https://medium.com/superluminar">superluminar</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>