<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Carrick Bradley on Medium]]></title>
        <description><![CDATA[Stories by Carrick Bradley on Medium]]></description>
        <link>https://medium.com/@carrickbradley?source=rss-8c55746da4c5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tS14g2HGZLjGG3SIY9EG4g.jpeg</url>
            <title>Stories by Carrick Bradley on Medium</title>
            <link>https://medium.com/@carrickbradley?source=rss-8c55746da4c5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 09:00:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@carrickbradley/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Automating Multilingual Audio Transformations]]></title>
            <link>https://medium.com/@carrickbradley/automating-multilingual-audio-transformations-e32c479030fb?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e32c479030fb</guid>
            <category><![CDATA[cloud-devops-engineer]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws-step-functions]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Sat, 26 Jul 2025 23:27:17 GMT</pubDate>
            <atom:updated>2025-07-26T23:27:17.979Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Generated by Gemini AI" src="https://cdn-images-1.medium.com/max/1024/1*zOz5Dn9_mcZ2wrHwXdXdow.png" /><figcaption>Generated by Gemini AI</figcaption></figure><h3>🚀<strong> Use Case</strong></h3><p>AcmeLabs, a digital education startup, is transforming access to content by automating the conversion of instructor voice messages in English into French, German, and Spanish. This article outlines their sophisticated audio transformation pipeline using AWS services and Infrastructure-as-Code (IaC).</p><h4>🌟<strong> The Challenge</strong></h4><p>AcmeLabs needed to efficiently convert audio content in .mp3 format into multiple languages. Traditional manual processes were unsustainable, prompting the need for an automated solution for transcription, translation, and speech synthesis.</p><h4>💡<strong> The Solution</strong></h4><p>AcmeLabs built a robust pipeline leveraging AWS services: Amazon Transcribe, Amazon Translate, Amazon Polly, and Amazon S3, all orchestrated via AWS Step Functions and monitored with Amazon CloudWatch for logging.</p><h4>🔑<strong> Key Components:</strong></h4><ol><li><strong>Audio Processing Workflow</strong>: The ⁠transcribe.py script converts audio to text, the ⁠translate.py script translates the transcript into French, German, and Spanish, and the ⁠synthesize.py script generates audio files from translations.</li><li><strong>S3 Object Management</strong>: Outputs are organized with timestamps for easy retrieval, including transcripts, translations, and audio files stored under structured paths in S3.</li><li><strong>Retention Policies</strong>: S3 policies automatically expire outputs after 30 days to manage costs.</li><li><strong>Event-Driven Architecture</strong>: S3 event notifications trigger Lambda functions for seamless processing.</li><li><strong>Step Functions Integration</strong>: This orchestrates the entire workflow with error handling and retries.</li><li><strong>CloudWatch Logging</strong>: Real-time monitoring for efficient troubleshooting.</li></ol><h4>🛠️ <strong>Infrastructure Deployment</strong></h4><p>Using CloudFormation, AcmeLabs defined all necessary AWS resources, including S3 buckets, IAM roles, Lambda functions, and Step Functions. This setup allows for reproducible and version-controlled infrastructure across environments (beta and prod).</p><h4>🚀<strong> CI/CD Integration</strong></h4><p>AcmeLabs uses GitHub Actions for CI/CD, automating deployments based on branch pushes. A push to the beta branch triggers testing in the beta environment, while a push to the main branch deploys to production.</p><h4>🌍<strong> The Impact</strong></h4><p>This automated pipeline has significantly improved AcmeLabs’ ability to deliver educational content globally. Key benefits include increased accessibility, scalability, and cost efficiency, with a serverless architecture that reduces overhead.</p><h4>🔄<strong> Workflow of the Application</strong></h4><ol><li><strong>Audio File Upload</strong>: A .mp3 audio file in US English (en-US) is uploaded to the S3 bucket under the ⁠audio_inputs/ prefix.</li><li><strong>S3 Event Notification</strong>: An S3 event notification triggers the ⁠trigger.py Lambda function when a new audio file is uploaded.</li><li><strong>Trigger Lambda Function (⁠trigger.py)</strong>: Extracts the bucket name and key from the event and starts the AWS Step Functions execution for audio processing, passing the bucket, key, and target languages.</li><li><strong>AWS Step Functions Execution</strong>: The Step Functions state machine orchestrates the audio processing workflow, executing the following steps:</li></ol><ul><li>Transcribe Audio: Calls ⁠transcribe.py.</li><li>Check Transcription Status: Calls ⁠status_transcription.py.</li><li>Translate Text: Calls ⁠translate.py.</li><li>Check Translation Status: Calls ⁠status_translation.py.</li><li>Synthesize Speech: Calls ⁠synthesize.py.</li><li>Check Audio File Existence: Calls ⁠status_synthesis.py.</li><li>Completion: Ensures all steps are executed with error handling.</li></ul><p>This workflow automates the multilingual audio transformation process, ensuring efficient and accurate delivery of educational content to a diverse audience.</p><figure><img alt="Generated by Gemini AI" src="https://cdn-images-1.medium.com/max/1024/1*FUd2GVSarYbhRqrtehvmcw.png" /><figcaption>Generated by Gemini AI</figcaption></figure><h3>AWS Resources</h3><p>For this application to work, it’s important to only change the fields below as noted.</p><ul><li>Replace all occurrences of <strong>&lt;AWSAccountID&gt;</strong> with your AWS Account ID</li><li>Replace all occurrences <strong>&lt;Project&gt;</strong>, with a unique name and keep this name short. Only pick one name and use it throughout this article to build the <strong>SpeakEasy</strong> application.</li></ul><h4>Create IAM Policy</h4><p>You’ll create an IAM Policy using least privilege principle.</p><ul><li>Create the File: policy.json</li><li>Copy and paste the contents below into <strong><em>policy.json</em></strong>:</li><li>Change <strong>&lt;AWSAccountID&gt;</strong> and <strong>&lt;Project&gt;</strong></li></ul><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;iam:CreateRole&quot;,<br>                &quot;iam:DeleteRole&quot;,<br>                &quot;iam:DeleteRolePolicy&quot;,<br>                &quot;iam:GetRole&quot;,<br>                &quot;iam:GetRolePolicy&quot;,<br>                &quot;iam:PassRole&quot;,<br>                &quot;iam:PutRolePolicy&quot;,<br>                &quot;iam:TagPolicy&quot;,<br>                &quot;iam:TagRole&quot;,<br>                &quot;iam:UntagPolicy&quot;,<br>                &quot;iam:UntagRole&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:iam::&lt;AWSAccountID&gt;:role/&lt;Project&gt;-speakeasy-lambda-execution-iam-role-beta&quot;,<br>                &quot;arn:aws:iam::&lt;AWSAccountID&gt;:role/&lt;Project&gt;-speakeasy-lambda-execution-iam-role-prod&quot;,<br>                &quot;arn:aws:iam::&lt;AWSAccountID&gt;:role/&lt;Project&gt;-speakeasy-step-functions-iam-role-beta&quot;,<br>                &quot;arn:aws:iam::&lt;AWSAccountID&gt;:role/&lt;Project&gt;-speakeasy-step-functions-iam-role-prod&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:CreateBucket&quot;,<br>                &quot;s3:DeleteBucket&quot;,<br>                &quot;s3:GetBucketNotification&quot;,<br>                &quot;s3:GetBucketTagging&quot;,<br>                &quot;s3:GetLifecycleConfiguration&quot;,<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:PutBucketNotification&quot;,<br>                &quot;s3:PutBucketTagging&quot;,<br>                &quot;s3:PutLifecycleConfiguration&quot;,<br>                &quot;s3:PutObject&quot;,<br>                &quot;s3:GetBucketLocation&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::&lt;Project&gt;-lambdas&quot;,<br>                &quot;arn:aws:s3:::&lt;Project&gt;-lambdas/*&quot;,<br>                &quot;arn:aws:s3:::&lt;Project&gt;-speakeasy-2025-beta&quot;,<br>                &quot;arn:aws:s3:::&lt;Project&gt;-speakeasy-2025-beta/*&quot;,<br>                &quot;arn:aws:s3:::&lt;Project&gt;-speakeasy-2025-prod&quot;,<br>                &quot;arn:aws:s3:::&lt;Project&gt;-speakeasy-2025-prod/*&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:ListAllMyBuckets&quot;,<br>                &quot;s3:ListBucket&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;cloudformation:CreateStack&quot;,<br>                &quot;cloudformation:UpdateStack&quot;,<br>                &quot;cloudformation:DeleteStack&quot;,<br>                &quot;cloudformation:DescribeStacks&quot;,<br>                &quot;cloudformation:DescribeStackResources&quot;,<br>                &quot;cloudformation:ListStackResources&quot;,<br>                &quot;cloudformation:CreateChangeSet&quot;,<br>                &quot;cloudformation:DeleteChangeSet&quot;,<br>                &quot;cloudformation:DescribeChangeSet&quot;,<br>                &quot;cloudformation:ListChangeSets&quot;,<br>                &quot;cloudformation:ExecuteChangeSet&quot;,<br>                &quot;cloudformation:GetTemplate&quot;,<br>                &quot;cloudformation:GetTemplateSummary&quot;,<br>                &quot;cloudformation:TagResource&quot;,<br>                &quot;cloudformation:UntagResource&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:cloudformation:us-east-1:&lt;AWSAccountID&gt;:stack/&lt;Project&gt;-speakeasy*&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;cloudformation:ListStacks&quot;,<br>                &quot;cloudformation:ValidateTemplate&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;transcribe:GetTranscriptionJob&quot;,<br>                &quot;transcribe:StartTranscriptionJob&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;translate:TranslateText&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;polly:SynthesizeSpeech&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;lambda:AddPermission&quot;,<br>                &quot;lambda:CreateFunction&quot;,<br>                &quot;lambda:DeleteFunction&quot;,<br>                &quot;lambda:GetFunction&quot;,<br>                &quot;lambda:InvokeFunction&quot;,<br>                &quot;lambda:RemovePermission&quot;,<br>                &quot;lambda:TagResource&quot;,<br>                &quot;lambda:UntagResource&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-trigger-beta&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-trigger-prod&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-transcribe-beta&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-transcribe-prod&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-translate-beta&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-translate-prod&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-synthesize-beta&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-synthesize-prod&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-transcription-status-beta&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-transcription-status-prod&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-translation-status-beta&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-translation-status-prod&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-synthesis-status-beta&quot;,<br>                &quot;arn:aws:lambda:us-east-1:&lt;AWSAccountID&gt;:function:&lt;Project&gt;-speakeasy-synthesis-status-prod&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: &quot;lambda:ListFunctions&quot;,<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;states:CreateActivity&quot;,<br>                &quot;states:CreateStateMachine&quot;,<br>                &quot;states:DeleteActivity&quot;,<br>                &quot;states:DeleteStateMachine&quot;,<br>                &quot;states:DescribeActivity&quot;,<br>                &quot;states:DescribeExecution&quot;,<br>                &quot;states:DescribeStateMachine&quot;,<br>                &quot;states:GetActivityTask&quot;,<br>                &quot;states:GetExecutionHistory&quot;,<br>                &quot;states:StartExecution&quot;,<br>                &quot;states:StopExecution&quot;,<br>                &quot;states:SendTaskFailure&quot;,<br>                &quot;states:SendTaskSuccess&quot;,<br>                &quot;states:TagResource&quot;,<br>                &quot;states:UntagResource&quot;,<br>                &quot;states:UpdateStateMachine&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:states:us-east-1:&lt;AWSAccountID&gt;:stateMachine:&lt;Project&gt;-speakeasy-audio-processing-state-machine-beta&quot;,<br>                &quot;arn:aws:states:us-east-1:&lt;AWSAccountID&gt;:stateMachine:&lt;Project&gt;-speakeasy-audio-processing-state-machine-prod&quot;<br>            ]<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;states:ListActivities&quot;,<br>                &quot;states:ListExecutions&quot;,<br>                &quot;states:ListStateMachines&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><ul><li>Create the Policy:</li></ul><pre># Example:<br># aws iam create-policy --policy-name &lt;PolicyName&gt; --policy-document file://path/to/policy.json<br>aws iam create-policy --policy-name &lt;Project&gt;_speakeasy_github_actions_policy --policy-document file://policy.json<br><br># Verify Policy Creation:<br>aws iam list-policies --scope Local</pre><h4>Create IAM User</h4><p>You’ll create an IAM user that is responsible for our GitHub Actions Workflows. The user will only have programmatic access to your AWS account.</p><pre># Example:<br># aws iam create-user --user-name &lt;usename&gt;<br>aws iam create-user --user-name &lt;Project&gt;_speakeasy_github_actions_user<br><br># Verify User Creation:<br>aws iam list-users</pre><ul><li>Generate Access Keys (Programmatic Access)</li><li>After you execute the command, the response will have the <em>AccessKeyId</em> &amp; <em>SecretAccessKey</em>, store these keys securely, you’ll use these a bit later.</li></ul><pre># Example:<br>aws iam create-access-key --user-name &lt;YourNewUserName&gt;<br><br>aws iam create-access-key --user-name &lt;Project&gt;_speakeasy_github_actions_user</pre><h4>Attach IAM Policy</h4><p>You’ll attach your newly created policy to your newly created IAM user. Otherwise the user will have no permissions to create the AWS resources necessary for this application.</p><pre>Example:<br>aws iam attach-user-policy --user-name &lt;username&gt; --policy-arn &lt;PolicyARN&gt;<br><br>aws iam attach-user-policy --user-name &lt;Project&gt;_speakeasy_github_actions_user --policy-arn arn:aws:iam::&lt;AWSAccountID&gt;:policy/&lt;Project&gt;_speakeasy_github_actions_policy</pre><h3>Project Resources</h3><h4>Download Project Files</h4><p>You’ll need the source files to deploy the SpeakEasy application.</p><ol><li>Download the zip file: <a href="https://github.com/carrickcancloud/AcmeLabs-SpeakEasy/archive/refs/heads/main.zip">https://github.com/carrickcancloud/AcmeLabs-SpeakEasy/archive/refs/heads/main.zip</a></li><li>⚠️ Keep the folder structure and file names as they are! ⚠️</li></ol><h4>Edit template.yaml</h4><p>Change the date for <strong>CreatedOnTag, and &lt;Project&gt;</strong></p><pre>  LambdaCodeS3BucketName:<br>    Type: String<br>    Default: &lt;Project&gt;-lambdas<br>    Description: The S3 bucket where Lambda function code is stored<br><br>  AudioS3BucketName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-2025<br>    Description: The name of the audio S3 bucket<br><br>  TriggerLambdaName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-trigger<br>    Description: The name of the Upload Trigger Lambda function<br><br>  TranscribeLambdaName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-transcribe<br>    Description: The name of the Transcribe Lambda function<br><br>  TranscriptionStatusLambdaName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-transcription-status<br>    Description: The name of the Transcribe Status Lambda function<br><br>  TranslateLambdaName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-translate<br>    Description: The name of the Translate Lambda function<br><br>  TranslationStatusLambdaName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-translation-status<br>    Description: The name of the Translate Status Lambda function<br><br>  SynthesizeLambdaName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-synthesize<br>    Description: The name of the Synthesize Lambda function<br><br>  SynthesisStatusLambdaName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-synthesis-status<br>    Description: The name of the Synthesize Status Lambda function<br><br>  AudioProcessingStateMachineName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-audio-processing-state-machine<br>    Description: The name of the Audio Processing Step Functions state machine<br><br>  StepFunctionsIAMRoleName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-step-functions-iam-role<br>    Description: The name of the Step Functions IAM role<br><br>  LambdaExecutionIAMRoleName:<br>    Type: String<br>    Default: &lt;Project&gt;-speakeasy-lambda-execution-iam-role<br>    Description: The name of the Lambda Execution IAM role<br><br>  ApplicationNameTag:<br>    Type: String<br>    Default: &quot;&lt;Project&gt; SpeakEasy&quot;<br>    Description: The name of the application.<br><br>  CreatedOnTag:<br>    Type: String<br>    Default: &quot;2025-07-26&quot;<br>    Description: The date when the resource was created, in YYYY-MM-DD format.</pre><h3>GitHub Resources</h3><h4>Create GitHub Repository</h4><h4>Create Classic Branch Protection Rules</h4><ol><li>From GitHub, goto repository “Settings”.</li><li>In the left-sidebar click on “Branches”.</li><li>On the right side click on “Add classic branch protection rule” button.</li><li>Set “Branch name pattern”: main</li><li>Tick the boxes below in the image then click on “Create”.</li><li>Repeat steps 1– 5, though change the “Branch name pattern” to beta.</li></ol><figure><img alt="Add classic branch protection rule" src="https://cdn-images-1.medium.com/max/1024/0*Jv1NJrzAEi4bsC8C.jpeg" /><figcaption>Add classic branch protection rule</figcaption></figure><h4>Create Environment Secrets &amp; Variables</h4><p>You’ll create the environment level secrets &amp; variables required for our application.</p><p><strong>Environments</strong></p><ol><li>Go to your GitHub repository</li><li>Navigate to <strong><em>Settings</em></strong> &gt; <strong><em>Environments</em></strong></li><li>Click on the <strong><em>New environment</em></strong> button and type in the <strong><em>Name</em></strong> field: beta</li><li>Click on the <strong><em>Configure environment</em></strong> button to create the environment</li><li>Repeat steps 1– 4, though this time type in the <strong><em>Name</em></strong> field: prod</li></ol><p><strong>Environment Secrets</strong></p><ol><li>Click on the <strong><em>Environments</em></strong> button on the left sidebar</li><li>Select the <strong><em>beta</em></strong> environment</li><li>Click on the <strong><em>Add environment secret</em></strong> button</li><li>Name: S3_BUCKET_AUDIO</li><li>Value: &lt;Project&gt;-speakeasy-2025-beta</li><li>Click on the <strong><em>Add secret</em></strong> button to create the secret</li><li>Repeat steps 1– 6, though this time use <strong>prod</strong> for the environment and for the value use: &lt;Project&gt;-speakeasy-2025-prod</li></ol><p><strong>Environment Variables</strong></p><ol><li>Click on the <strong><em>Environments</em></strong> button on the left sidebar</li><li>Select the <strong><em>beta</em></strong> environment</li><li>Click on the <strong><em>Add environment variable</em></strong> button</li><li>Name: LAMBDA_TRIGGER</li><li>Value: &lt;Project&gt;-speakeasy-trigger-beta</li><li>Click on the <strong><em>Add variable</em></strong> button to create the variable</li><li>Repeat steps 1–6, though this time use <strong>prod</strong> for the environment and for the value use: &lt;Project&gt;-speakeasy-trigger-prod</li></ol><h4>Create Repository Secrets &amp; Variables</h4><p>You’ll create the repository level secrets &amp; variables required for our application.</p><ol><li>Go to your GitHub repository</li><li>Navigate to <strong><em>Settings</em></strong> &gt; <strong><em>Secrets and variables &gt; Actions</em></strong></li></ol><p><strong>Secrets</strong></p><ol><li>Click on the <strong><em>New repository secret</em></strong> button</li><li>Name: From the list below</li><li>Value: From the list below</li><li>Click on the <strong><em>Add secret</em></strong> button to create the secret</li><li>Repeat steps 1–4 using the list of Names &amp; Values:<br>Name: AWS_ACCESS_KEY_ID, Value: AccessKeyId for our IAM user<br>Name: AWS_REGION, Value: us-east-1<br>Name: AWS_SECRET_ACCESS_KEY, Value: SecretAccessKey for our IAM user<br>Name: S3_BUCKET_LAMBDAS, Value: &lt;Project&gt;-lambdas</li></ol><p><strong>Variables</strong></p><ol><li>Click on the <strong><em>Variables</em></strong> tab</li><li>Click on the <strong><em>New repository variable</em></strong><em> </em>button</li><li>Name: From the list below</li><li>Value: From the list below</li><li>Click on the <strong><em>Add variable</em></strong> button to create the variable</li><li>Repeat Steps 1–5 using the list of Names &amp; Values:<br>Name: APP_NAME, Value: speakeasy<br>Name: STACK_NAME Value: &lt;Project&gt;-speakeasy</li></ol><h4>Clone Repo To Local</h4><p>You’ll need to sync between our local versions of our repo up to the remote versions hosted in GitHub.</p><ol><li>Assuming you are not in your repository for this project, in the top left click on your<strong><em> GitHub username</em></strong></li><li>On the top navigation, click on the <strong><em>Repositories</em></strong> tab</li><li>Click on your <strong><em>repository</em></strong></li><li>This should take us to the <strong><em>Code</em></strong> tab of our repository</li><li>Click on the green <strong><em>&lt;&gt; Code</em></strong> button</li><li>From the dropdown menu, select either HTTPS or SSH</li><li>Copy the address listed below the protocol you selected</li><li>In terminal or your IDE of choice, use that address to clone</li></ol><pre># 1. Change directory to where you want to clone this to:<br>cd /Users/username/repos/<br><br># 2. Git-Clone<br># SSH:<br>git clone git@github.com:GitHubUsername/YourGithubReponame.git<br><br># HTTPS:<br>git clone https://github.com/GitHubUsername/YourGithubReponame.git</pre><h4>Create Branches</h4><p>For brevity sake, create environment branches and then contributor branches like you see below.</p><pre># Create beta branch:<br>git checkout -b beta<br>git push origin beta<br><br># Create contributor branch:<br>git checkout main<br>git checkout -b mynameorhandle<br>git push --set-upstream origin mynameorhandle</pre><ol><li>All work is done in your contributor branch</li><li>Merge your work into beta branch for testing using pull requests</li><li>If all is sound from testing, merge beta into main(prod) using pull requests</li></ol><h4>Load Project Files Into Local</h4><p>Copy over the the source project files into your the local copy of your repository. Below uses terminal/shell to do so. Feel free to use what your prefer.</p><pre># Change Directory:<br>cd /path/to/repo/<br><br># Change Branch:<br>git checkout mynameorhandle<br><br># Validate Current Branch (Look for the *):<br>git branch<br><br># Copy Source Project Files To Local Repository:<br>cp -av /path/to/source/. .<br><br># Tree Repository Root<br>tree -a -I &#39;.git&#39;<br><br># Expected Output:<br># If this is different, SpeakEasy will fail.<br>.<br>├── .github<br>│   ├── pull_request_template.md<br>│   └── workflows<br>│       ├── deploy.yaml<br>│       ├── destroy.yaml<br>│       └── upload_audio.yaml<br>├── .gitignore<br>├── audio_inputs<br>│   └── marvin.mp3<br>├── cloudformation<br>│   └── template.yaml<br>├── lambda<br>│   ├── helpers<br>│   │   ├── datetime_serializer.py<br>│   │   └── logger.py<br>│   ├── status_synthesis.py<br>│   ├── status_transcription.py<br>│   ├── status_translation.py<br>│   ├── synthesize.py<br>│   ├── transcribe.py<br>│   ├── translate.py<br>│   └── trigger.py<br>├── LICENSE<br>└── README.md</pre><h4>Push Project Files To Remote</h4><p>Now that your local copy has our project files, you’ll need to push them to the remote copy in GitHub. Feel free to use what your prefer e.g. your IDE, terminal/shell, GitHub Desktop and etc.</p><pre># Change Directory:<br>cd /path/to/repo/<br><br># Change Branch:<br>git checkout mynameorhandle<br><br># Add Files To Git<br>git add * .gitignore README.md .github/<br><br># Commit with comment<br>git commit -m &quot;Populating project files into repo.&quot;<br><br># Push<br>git push -v</pre><ol><li>Follow the steps above will have pushed the project files to your branch to GitHub</li><li>Create a <strong><em>Pull Request</em></strong> to merge mynameorhandle<strong> </strong>branch into beta</li><li>Create a <strong><em>Pull Request</em></strong> to merge beta into main</li></ol><h3>Deploy Resources</h3><p>Now that your repository has been populated you can deploy SpeakEasy. You’ll use GitHub Actions workflow to deploy.</p><ol><li>Go to your GitHub repository</li><li>Click on the <strong><em>Actions </em></strong>tab<br>Expect to see two failed workflow runs for <strong><em>Upload Audio</em></strong>. This is expected as the S3 buckets for uploading the files to does not exist. The <strong><em>Upload Audio</em></strong> workflow automatically uploads to beta &amp; main(prod) on push. So when you merged into beta and into main from beta, that trigged these workflows as those are pushes to the respective branches. You can delete these if you want, no harm.</li><li>On the left sidebar under <strong><em>Actions</em></strong> click on <strong><em>Deploy Resources</em></strong></li><li>On the right side, click on <strong><em>Run workflow</em></strong> to expand it</li><li>Deploy <strong><em>Beta</em></strong> environment first:<br>- Branch: beta<br>- Action: deploy<br>- Environment: beta</li><li>Deploy <strong><em>Prod</em></strong> environment second:<br>- Branch: main<br>- Action: deploy<br>- Environment: prod</li></ol><h3>Destroy Resources</h3><p>If you’re done with SpeakEasy, you can simply use this GitHub Actions Workflow to teardown all the AWS resources. Though you will need to do this a few parts as for best practice, I choose not to have this workflow purge the S3 bucket used for audio processing, the lambda’s bucket, CloudWatch logs and transcription jobs.</p><ul><li>Purge S3 Buckets:</li></ul><pre># Purge S3 AudioProcessing Buckets<br>aws s3 rm s3://&lt;Project&gt;-speakeasy-2025-beta --recursive<br>aws s3 rm s3://&lt;Project&gt;-speakeasy-2025-prod --recursive<br><br># Purge S3 Lambdas Bucket<br>aws s3 rm s3://&lt;Project&gt;-lambdas --recursive<br><br># Purge Transcription Jobs<br>for job in $(aws transcribe list-transcription-jobs --query &quot;TranscriptionJobSummaries[*].TranscriptionJobName&quot; --output text); do<br>    aws transcribe delete-transcription-job --transcription-job-name &quot;$job&quot;<br>    echo &quot;Deleted transcription job: $job&quot;<br>done</pre><ol><li>Go to your GitHub repository</li><li>Click on the <strong><em>Actions </em></strong>tab</li><li>On the left sidebar under <strong><em>Actions</em></strong> click on <strong><em>Destroy Resources</em></strong></li><li>On the right side, click on <strong><em>Run workflow</em></strong> to expand it</li><li>Destroy <strong><em>Beta</em></strong> environment:<br>- Branch: beta<br>- Environment: beta</li><li>Destroy <strong><em>Prod</em></strong> environment:<br>- Branch: main<br>- Environment: prod</li></ol><h3>Trigger Audio Processing</h3><p>To trigger the workflows, upload mp3’s to the audio_inputs/ directory in your repository.</p><ol><li>Push request to either beta or main branch will trigger the Upload Audio workflow.</li><li>Strategy to maintain the workflow:</li></ol><ul><li>Create a new branch for your changes.</li><li>Add files to the audio_inputs directory in your repository.</li><li>Create a pull request to merge your changes into the beta branch.</li><li>The workflow will automatically upload the audio files to the S3_BUCKET_AUDIO secret under the audio_inputs prefix.</li><li>Newly created audio files in the audio_inputs/ prefix will trigger an S3 event notification.</li><li>The S3 event notification will invoke the trigger.py lambda function which in turn will start the Step Functions state machine to process the audio files.</li><li>The state machine will invoke the Lambda functions to transcribe, translate, and synthesize the audio files.</li><li>The results will be stored in the S3 bucket specified in the S3_BUCKET_AUDIO secret under the transcriptions, translations, and audio_outputs prefixes respectively.</li><li>Once beta testing is complete, merge the beta branch into the main branch to process the audio_inputs/ in production.</li></ul><h3>Expected Outcomes 🌟</h3><h4>Deploy Resources — GitHub Action Workflow</h4><figure><img alt="Deploy Resources Outcome" src="https://cdn-images-1.medium.com/max/1024/1*iuhh-Zb9p5QzErwZNTk6Xw.jpeg" /></figure><h4>Audio Upload — GitHub Action Workflow</h4><figure><img alt="Upload Audio Outcome" src="https://cdn-images-1.medium.com/max/1024/1*bksCTQ1WYhE28WXRl6rkWg.jpeg" /></figure><h4>Destroy Resources — GitHub Action Workflow</h4><figure><img alt="Destroy Resources Outcome" src="https://cdn-images-1.medium.com/max/1024/1*6S4A98LRoSm0qvDIHwGNqw.jpeg" /></figure><h4>State Machine Results — Beta</h4><figure><img alt="State Machine — Step Functions — Job — Beta" src="https://cdn-images-1.medium.com/max/1024/1*rWCUwNNt1yO-WpgeqFX5kA.jpeg" /></figure><h4>State Machine Results — Prod</h4><figure><img alt="State Machine — Step Functions — Job — Prod" src="https://cdn-images-1.medium.com/max/1024/1*p4s2u3i87P8VqAhABQUXaw.jpeg" /></figure><h4>S3 Bucket — Beta</h4><figure><img alt="S3 Bucket — Beta" src="https://cdn-images-1.medium.com/max/687/1*2N6RNdr-aoX-996TOsqDGQ.jpeg" /></figure><h4>S3 Bucket — Prod</h4><figure><img alt="S3 Bucket — Prod" src="https://cdn-images-1.medium.com/max/687/1*6jQM395Bl5Ks2Qu5jExRpw.jpeg" /></figure><p>You can review the output by downloading each object through the AWS Console or using AWS CLI. You can review the orignal file, transcripts, translations for all three languages and hear all three mp3’s too.</p><h3><strong>Conclusion </strong>🎉</h3><p>This project is designed to help you transcribe, translate, and synthesize audio files using AWS services and GitHub Actions. By following the steps outlined above, you can set up your environment and deploy the necessary resources to get started.</p><p><a href="https://medium.com/u/331e9964766c">LaSherr&#39;e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara Hibben</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a> <a href="https://medium.com/u/efc3aac42050">Tait Hoglund</a> <a href="https://medium.com/u/6f71604051be">Zaire Ali</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e32c479030fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supercharge Image Analysis with AWS Rekognition, CloudFormation, and GitHub Actions ]]></title>
            <link>https://medium.com/@carrickbradley/supercharge-image-analysis-with-aws-rekognition-cloudformation-and-github-actions-89312d957db8?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/89312d957db8</guid>
            <category><![CDATA[cloud-devops-engineer]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Mon, 14 Jul 2025 23:21:18 GMT</pubDate>
            <atom:updated>2025-07-14T23:21:18.344Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s fast-paced digital world, image and video analysis are becoming essential for businesses looking to enhance their offerings. AWS Rekognition stands out as a powerful tool that enables developers to analyze images and videos using advanced machine learning techniques. But how can you seamlessly integrate this tool into your applications? That’s where AWS CloudFormation comes in, making it easier to deploy and manage AWS resources.</p><figure><img alt="Generated By DeepAI" src="https://cdn-images-1.medium.com/max/640/1*6cxrmGGTLO2g9dOQ-P5bsA.jpeg" /><figcaption>Generated By DeepAI</figcaption></figure><h3><strong>What is AWS Rekognition? </strong>🖼️</h3><p>AWS Rekognition allows you to effortlessly add image and video analysis capabilities to your applications. Whether you want to detect objects, recognize faces, or analyze scenes, Rekognition provides a range of features that can improve user experiences and deliver valuable insights. Its ability to process large volumes of media quickly and accurately makes it a go-to choice for developers looking to implement image analysis solutions.</p><h3><strong>The Role of CloudFormation </strong>🛠️</h3><p>CloudFormation is an infrastructure-as-code service that lets you define and provision AWS resources through templates. This means you can automate the setup of your infrastructure, ensuring that your applications are both scalable and maintainable. When you combine CloudFormation with AWS Rekognition, you simplify the deployment process, making it easier to launch complex image analysis applications.</p><h4><strong>Why Use CloudFormation with AWS Rekognition? </strong>🤖</h4><p>1. <strong>Automation</strong>: Manually setting up AWS resources can be tedious and error-prone. CloudFormation automates the process, allowing you to deploy your infrastructure with just one command.</p><p>2. <strong>Consistency</strong>: By defining your infrastructure in code, you guarantee that every deployment is consistent. This reduces the chances of configuration drift and makes managing your resources much simpler.</p><p>3. <strong>Version Control</strong>: Just like your application code, you can keep track of changes to your CloudFormation templates. This allows for easy collaboration and the ability to roll back to previous versions if needed.</p><h3><strong>Use Case: AcmeLabs </strong>📚</h3><p>Let’s take a look at AcmeLabs, a digital-first education startup committed to enhancing visual learning tools. The company aims to automate the tagging and classification of educational images used in course materials and marketing efforts.</p><p>Currently, AcmeLabs relies on a manual tagging process that is slow and prone to mistakes, making it difficult for users to find the right content. To address this challenge, they plan to implement an AI-driven labeling system using AWS Rekognition. This technology will significantly reduce the time spent on manual tagging and improve the organization of their image library.</p><p>By integrating this solution directly into their GitHub workflow, AcmeLabs hopes to create a smoother experience for their team. Automating image tagging will not only boost efficiency but also make educational resources more accessible and engaging for both students and educators. This initiative is a crucial step toward making learning materials better organized and user-friendly, reinforcing AcmeLabs’ mission to enhance visual learning.</p><h4><strong>Leveraging GitHub Actions for CI/CD </strong>🔄</h4><p>To streamline their development process, AcmeLabs is also incorporating GitHub Actions into their workflow. GitHub Actions enables developers to automate tasks directly within their GitHub repositories, creating a continuous integration and continuous deployment (CI/CD) pipeline.</p><h4><strong>How GitHub Actions Works </strong>🛠️</h4><p>1. <strong>Workflows</strong>: GitHub Actions allows you to define workflows that automatically trigger on specific events, such as code pushes or pull requests. This means that every time a developer makes a change, the workflow can automatically run tests, build the application, and deploy it to AWS.</p><p>2. <strong>Secrets Management</strong>: Security is paramount, especially when dealing with cloud resources. GitHub Actions provides a secure way to manage sensitive information through GitHub Secrets. Developers can store AWS access keys and other credentials securely, ensuring that they are not exposed in the codebase. During the CI/CD process, these secrets can be accessed by the workflows without compromising security.</p><p>3. <strong>Integration with AWS</strong>: By using GitHub Actions, AcmeLabs can automate the deployment of their AWS resources defined in CloudFormation templates. Once the image tagging system is tested and ready, the workflow can trigger a deployment to AWS, making the process seamless and efficient.</p><h4><strong>Using the AWS Rekognition CloudFormation Repository </strong>📁</h4><p>The <a href="https://github.com/carrickcancloud/AWS-Rekognition-CloudFormation">AWS Rekognition CloudFormation</a> repository provides a specific template designed for image analysis use cases. Here’s a high-level overview of how to use this repository:</p><p>1. <strong>Clone the Repository</strong>: Start by cloning the repository to your local machine using Git. This will give you access to the CloudFormation template and example configurations.</p><pre>git clone https://github.com/carrickcancloud/AWS-Rekognition-CloudFormation.git</pre><p>2. <strong>Review the Template</strong>: The repository contains a single CloudFormation template focused on image analysis. This template defines the necessary AWS resources, such as IAM roles, S3 buckets, and Rekognition services.</p><p>3. <strong>Customize the Template</strong>: It is crucial to change the parameters in the template to fit your specific needs. Modify parameters such as resource names, region configurations, and permissions according to your project requirements. This step is essential to ensure that the template works correctly in your AWS environment.</p><p>4. <strong>Deploy the Stack</strong>: Use the AWS Management Console or AWS CLI to deploy your CloudFormation stack. This will create all the resources defined in your template.</p><pre>aws cloudformation create-stack - stack-name YourStackName - template-body file://path/to/your/template.yaml</pre><p>5. <strong>Integrate with GitHub Actions</strong>: Set up GitHub Actions workflows to automate the deployment of your CloudFormation template. Use GitHub Secrets to securely manage your AWS credentials, enabling seamless CI/CD for your projects.</p><p>For more details, check out the <a href="https://github.com/carrickcancloud/AWS-Rekognition-CloudFormation/blob/main/README.md">README file</a> in the repository.</p><h3><strong>Expected Outcomes </strong>🌟</h3><p>To visualize the expected outcomes of implementing this solution, here are some example images and screenshots:</p><h4><strong>GitHub Actions Workflows</strong></h4><figure><img alt="GitHub Actions Workflow — On Merge — Deploy Resources" src="https://cdn-images-1.medium.com/max/1024/1*QWC4gOReV7l8qBX58a9vsw.jpeg" /><figcaption>GitHub Actions Workflow — On Merge — Deploy Resources</figcaption></figure><figure><img alt="GitHub Actions WorkFlow — On Pull Request — Image Upload — Beta" src="https://cdn-images-1.medium.com/max/1024/1*3MVXYsGg-om6jI7Ry0jonQ.jpeg" /><figcaption>GitHub Actions WorkFlow — On Pull Request — Image Upload — Beta</figcaption></figure><figure><img alt="GitHub Actions WorkFlow — On Merge — Image Upload — Prod" src="https://cdn-images-1.medium.com/max/1024/1*ii0bcFGoOMMqAM1id-04ww.jpeg" /><figcaption>GitHub Actions WorkFlow — On Merge — Image Upload — Prod</figcaption></figure><h4><strong>S3 Bucket</strong></h4><figure><img alt="S3 Bucket — Beta" src="https://cdn-images-1.medium.com/max/1024/1*lhuzLQvdlZVVYaY026OcaA.jpeg" /><figcaption>S3 Bucket — Beta</figcaption></figure><figure><img alt="S3 Bucket — Prod" src="https://cdn-images-1.medium.com/max/1024/1*IjMVwUrA416djQvn6jBdwg.jpeg" /><figcaption>S3 Bucket — Prod</figcaption></figure><h4><strong>DynamoDB Tables</strong></h4><figure><img alt="DynamoDB Table Scan — Beta" src="https://cdn-images-1.medium.com/max/1024/1*yyhXgy2G6HeSU7AITrcp2w.jpeg" /><figcaption>DynamoDB Table Scan — Beta</figcaption></figure><figure><img alt="DynamoDB Table Scan — Prod" src="https://cdn-images-1.medium.com/max/1024/1*YWcPkATXuyI6747HfZuK3Q.jpeg" /><figcaption>DynamoDB Table Scan — Prod</figcaption></figure><figure><img alt="DynamoDB Table Item — Beta" src="https://cdn-images-1.medium.com/max/1024/1*i63A0KjT3FPA5tIT0JYzMA.jpeg" /><figcaption>DynamoDB Table Item — Beta</figcaption></figure><figure><img alt="DynamoDB Table Item — Prod" src="https://cdn-images-1.medium.com/max/1024/1*ZTN9MA4Nnn8RkcAWtayijQ.jpeg" /><figcaption>DynamoDB Table Item — Prod</figcaption></figure><h3><strong>Conclusion </strong>🎉</h3><p>Integrating AWS Rekognition with CloudFormation not only enhances your applications but also simplifies the deployment process for image analysis solutions. By harnessing automation and following best practices for security, developers can focus on creating innovative solutions without getting bogged down by infrastructure management.</p><p>As the demand for intelligent media analysis continues to rise, mastering tools like AWS Rekognition and CloudFormation, along with GitHub Actions for CI/CD, will be crucial for developers looking to stay ahead in the tech landscape. Embrace these technologies, and unlock the potential of your applications today!</p><p><a href="https://medium.com/u/331e9964766c">LaSherr&#39;e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara Hibben</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a> <a href="https://medium.com/u/efc3aac42050">Tait Hoglund</a> <a href="https://medium.com/u/6f71604051be">Zaire Ali</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89312d957db8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS: Polly]]></title>
            <link>https://medium.com/@carrickbradley/aws-polly-3f90e51b71b4?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/3f90e51b71b4</guid>
            <category><![CDATA[aws-polly]]></category>
            <category><![CDATA[aws-s3]]></category>
            <category><![CDATA[github]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Sat, 28 Jun 2025 02:09:51 GMT</pubDate>
            <atom:updated>2025-06-28T02:09:51.152Z</atom:updated>
            <content:encoded><![CDATA[<p>Dive into this innovative project that effortlessly converts text files into MP3 audio files using Python, Boto3, AWS Polly, and AWS S3, all powered by GitHub Actions. Experience the magic of turning written content into engaging speech with automated workflows that synthesize speech using Amazon Polly and upload the finished audio files straight to an S3 bucket. Get ready to transform how you engage with your audience!</p><figure><img alt="Generated by DeepAI" src="https://cdn-images-1.medium.com/max/640/1*_YOFjah1vgRXEbg6eh9Zqw.jpeg" /><figcaption>Generated by DeepAI</figcaption></figure><h3>Use Case</h3><p>AmceLabs is collaborating with a forward-thinking digital education startup dedicated to accessibility and automation, aiming to transform course content into audio format. This initiative is designed to assist users with visual impairments and those who prefer auditory learning. With course materials already stored on GitHub, they plan to leverage AWS AI services to effortlessly convert these resources into audio files. Their goal is to create a streamlined, cost-effective pipeline that eliminates the need for server management or machine learning model training, making education more accessible than ever.</p><h3>Prerequisites</h3><ul><li>AWS Account</li><li>Git Installed</li><li>GitHub Account</li><li>GitHub Repo</li></ul><h3>Lets Get Started</h3><h4><strong>Setup AWS Credentials and S3 Bucket </strong>🛠️</h4><p>To set up AWS credentials and an S3 bucket, follow these steps:</p><ol><li>AWS Account: Ensure you have an AWS account. If not, create one at <a href="https://aws.amazon.com/">AWS</a>. 🌐</li><li>Select Region: Change your region on the top right corner of the AWS console to the region you want your bucket created under, I’m using <strong><em>us-east-1</em></strong> otherwise shown as <strong><em>United States (N. Virginia)</em></strong></li><li>Create an S3 Bucket:</li></ol><ul><li>Go to the S3 service in the AWS Management Console.</li><li>Click on “Create bucket”.</li><li>Choose a unique name for your bucket and select a region.</li><li>Configure any additional settings as needed and create the bucket. 🪣</li></ul><h4><strong>Create an IAM User with Programmatic Access </strong>👤</h4><p>To create an IAM user with programmatic access:</p><ol><li>Sign in to the <a href="https://aws.amazon.com/console/">AWS Management Console</a>.</li><li>Navigate to the IAM service.</li><li>Click on “Users” in the sidebar, then click on “Create user”.</li><li>Enter a username for the new user and click on “Next” to proceed to the <strong>Set permissions</strong> section.</li><li>Click on “Next” to proceed to the “Review and create” section.</li><li>Click “Create user” to proceed. ✅</li></ol><h4><strong>Create &amp; Attach IAM Policies </strong>🔑</h4><p>After creating the IAM user, you need to attach the necessary policies:</p><p><strong>Create the ⁠AcmeLabsAmazonPollyReadOnly Policy</strong>:</p><ul><li>In the IAM console, go to “Policies” and click “Create policy”.</li><li>Switch to the “JSON” tab and paste the following policy:</li></ul><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;AcmeLabsAmazonPollyReadOnly&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;polly:SynthesizeSpeech&quot;,<br>                &quot;polly:DescribeVoices&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        }<br>    ]<br>}</pre><ul><li>Click “Next”, give it a name (⁠AcmeLabsAmazonPollyReadOnly), and click “Create policy”. 📝</li></ul><p><strong>Create the ⁠AcmeLabsAmazonS3ReadWrite Policy</strong>:</p><ul><li>Repeat the steps to create another policy and paste the following JSON:</li></ul><pre>{<br>    &quot;Version&quot;: &quot;2012-10-17&quot;,<br>    &quot;Statement&quot;: [<br>        {<br>            &quot;Sid&quot;: &quot;AcmeLabsAmazonS3ReadWrite&quot;,<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;s3:PutObject&quot;,<br>                &quot;s3:GetObject&quot;,<br>                &quot;s3:ListBucket&quot;<br>            ],<br>            &quot;Resource&quot;: [<br>                &quot;arn:aws:s3:::acmelabs-aws-polly-synthesize&quot;,<br>                &quot;arn:aws:s3:::acmelabs-aws-polly-synthesize/*&quot;<br>            ]<br>        }<br>    ]<br>}</pre><ul><li>Name this policy ⁠AcmeLabsAmazonS3ReadWrite and create it. 🛡️</li></ul><p><strong>Attach Policies to the User</strong>:</p><ul><li>Click on “Users” in the sidebar, then click on your new user’s name.</li><li>Click on the “Permissions” tab.</li><li>Click on “Add permissions”, choose “Attach existing policies directly”, and select both ⁠AcmeLabsAmazonPollyReadOnly and AcmeLabsAmazonS3ReadWrite.</li><li>Click “Next” and then “Add permissions”. ➕</li></ul><h4><strong>Create Access Keys </strong>🔑</h4><ol><li>Navigate to the “Security credentials” tab of your user.</li><li>Click on “Create access key” tab.</li><li>Click on “Other” for the “Use case”.</li><li>Click on “Next” and fill out the “Description tag value” (name the secret).</li><li>Click on “Create access key”.</li><li>Make sure to copy the Access Key ID and Secret Access Key.<br>You will need these for your GitHub Actions workflow, <strong>Store</strong> these credentials <strong>securely</strong>, as you will not be able to <strong>view</strong> the Secret Access Key again. 🔒 You can also download the credentials as a CSV file for safekeeping.</li><li>Click “Done” to finish. 🎉</li></ol><h4>GitHub Repo</h4><ol><li>Download Repo: <a href="https://github.com/carrickcancloud/AWS-Polly/archive/refs/heads/main.zip">https://github.com/carrickcancloud/AWS-Polly/archive/refs/heads/main.zip</a>.</li><li>Create a public repo.</li><li>Extract the contents from the downloaded zip file into your repo.</li><li>Commit and push your changes.<br><strong>Note</strong>: This will trigger the “On Merge” workflow, it should fail as we have not configured the Repository Secrets &amp; Environment Variables.</li></ol><p><strong>Configure branch protection:</strong></p><ol><li>From GitHub, goto repository “Settings”.</li><li>In the left-sidebar click on “Branches”.</li><li>On the right side click on “Add classic branch protection rule” button.</li><li>Set “Branch name pattern”: main</li><li>Tick the boxes below in the image then click on “Create”.</li></ol><figure><img alt="Add classic branch protection rule" src="https://cdn-images-1.medium.com/max/1024/1*xL0yo_OgxdFlRz8gl2OUUg.jpeg" /><figcaption>Add classic branch protection rule</figcaption></figure><h4><strong>Configure GitHub Secrets </strong>🔐</h4><ol><li>Go to your GitHub repository.</li><li>Navigate to ⁠Settings &gt; ⁠Secrets and variables &gt; ⁠Actions.</li><li>Click on the “Secrets” tab.</li><li>Click on “New repository secret”.<br>Name the secrets as follows:<br><strong>⁠- ACMELABS_SYNTHESIZE_AWS_ACCESS_KEY_ID<br>- ACMELABS_SYNTHESIZE_AWS_SECRET_ACCESS_KEY<br>- ACMELABS_SYNTHESIZE_AWS_S3_BUCKET</strong></li><li>Enter the corresponding values for each secret.<br>For example:<br>- <strong>ACMELABS_SYNTHESIZE_AWS_ACCESS_KEY_ID: </strong><em>⁠AKIAIOSFODNN7EXAMPLE</em><strong><br>- ACMELABS_SYNTHESIZE_AWS_SECRET_ACCESS_KEY: </strong><em>⁠wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY</em><strong><br>- ACMELABS_SYNTHESIZE_AWS_S3_BUCKET: ⁠</strong><em>acmelabs-aws-polly-synthesize</em></li><li>Click “Add secret” to save each one. 💾</li></ol><h4>Configure GitHub Environment Variables:</h4><ol><li>Navigate to ⁠Settings &gt; ⁠Secrets and variables &gt; ⁠Actions.</li><li>Click on “New repository variable”.<br>Name the variables as follows:<br>- <strong>ACMELABS_SYNTHESIZE_AWS_REGION</strong><br>- <strong>ACMELABS_SYNTHESIZE_AWS_S3_KEY_PROD</strong><br>- <strong>ACMELABS_SYNTHESIZE_AWS_S3_KEY_BETA</strong><br>- <strong>ACMELABS_SYNTHESIZE_AWS_S3_PREFIX</strong></li><li>Enter the corresponding values for each variable.<br>For example:<br><strong>ACMELABS_SYNTHESIZE_AWS_REGION:</strong> ⁠<em>us-east-1</em><br><strong>ACMELABS_SYNTHESIZE_AWS_S3_KEY_PROD:</strong> ⁠<em>prod.mp3</em><br><strong>ACMELABS_SYNTHESIZE_AWS_S3_KEY_BETA:</strong> ⁠<em>beta.mp3</em><br>⁠<strong>ACMELABS_SYNTHESIZE_AWS_S3_PREFIX:</strong> ⁠<em>polly-audio</em></li><li>Click “Add variable” to save each one. 🌍</li></ol><h3><strong>Trigger the Workflows </strong>🚀</h3><p>The workflows are triggered automatically based on changes to the ⁠speech.txt file:</p><ol><li>Create new branch “trigger”</li><li>Edit “speech.txt”</li><li>Commit and push your changes</li><li>Create a pull request into the ⁠main branch to trigger the workflow “On Pull Request”.</li><li>Merge the pull request into the main branch to trigger the workflow “On Merge”.</li></ol><p><strong>Review GitHub Actions to ensure the workflow runs successfully.</strong></p><ol><li>Click on “Actions” tab in your GitHub repository.</li><li>In the left sidebar, select the workflow named ⁠”On Pull Request” &amp; “On Merge”.</li><li>Click on the latest run to view the details.</li><li>Check the logs to ensure that the speech synthesis and S3 upload steps completed successfully. 📊</li></ol><p><strong>Verify the Uploaded .mp3 Files </strong>🎶</p><p>To verify that the .mp3 files have been uploaded to your S3 bucket:</p><ol><li>Go to the S3 service in the AWS Management Console.</li><li>Navigate to your bucket, click on “Objects” to view the contents.</li><li>Check for the uploaded .mp3 files under the specified prefix (e.g., ⁠polly-audio).</li><li>You can open or download the files to verify their content. 📥</li></ol><h3><strong>Conclusion </strong>🏁</h3><p>This workflow automates the process of synthesizing text to speech and uploading the audio files to S3. Ensure that your AWS credentials are kept secure and not shared publicly. 🔒</p><p><a href="https://medium.com/u/331e9964766c">LaSherr&#39;e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara Hibben</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a> <a href="https://medium.com/u/efc3aac42050">Tait Hoglund</a> <a href="https://medium.com/u/6f71604051be">Zaire Ali</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3f90e51b71b4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS: DynamoDB & Lambda]]></title>
            <link>https://medium.com/@carrickbradley/aws-dynamodb-lambda-5308abd22d7f?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/5308abd22d7f</guid>
            <category><![CDATA[aws-lambda]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-dynamodb]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws-cloudformation]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Fri, 16 May 2025 18:28:20 GMT</pubDate>
            <atom:updated>2025-05-16T18:28:20.984Z</atom:updated>
            <content:encoded><![CDATA[<p>In this project, we’ll explore the integration of DynamoDB with AWS Lambda to retrieve the latest top movies from The Movie Database (TMDB) on a daily basis.</p><figure><img alt="Generated by DeepAI" src="https://cdn-images-1.medium.com/max/1024/1*tY8jXDg0azKZzMEc3yQCHA.png" /><figcaption>Generated by DeepAI</figcaption></figure><h3>Use Case</h3><p>AcmeLabs aims to develop a compact database that maintains the current week’s top movies, updating daily at midnight. To facilitate this, they plan to utilize an EC2 instance for querying the data while continuing to refine the frontend of their web application. Our focus will be on building the following components:</p><ul><li>VPC</li><li>Public Subnet</li><li>Internet Gateway</li><li>Route Table</li><li>Security Group</li><li>DynamoDB</li><li>EC2 Instance</li><li>Lambda Function</li><li>IAM Roles</li></ul><h3>Prerequisites</h3><ul><li>AWS Account</li><li><a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI Installed</a> &amp; <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html">Configured</a></li><li>Terminal Emulator</li><li><a href="http://www.themoviedb.org/">The Movie Database (API)</a></li><li><a href="https://github.com/carrickcancloud/AWS/tree/main/MovieDB">Project Files</a></li></ul><h3>Lets Get Started</h3><ol><li>Download the <a href="https://github.com/carrickcancloud/AWS/tree/main/MovieDB">Project Files</a></li><li>Change directory to the root of the project files</li></ol><h4>Key-Pair</h4><p>We’ll create our key-pair used with our EC2 instance and store the name in SSM parameter store.</p><pre># Create Key-Pair<br>aws ec2 create-key-pair \<br>    --key-name AcmeLabs-MovieDB-KP \<br>    --query &#39;KeyMaterial&#39; \<br>    --output text &gt; AcmeLabs-MovieDB-KP.pem<br><br># Set Permissions on Key-Pair Priavate Key<br>chmod 400 AcmeLabs-MovieDB-KP.pem<br><br># Tag Key-Pair<br>aws ec2 create-tags \<br>    --resources $(aws ec2 describe-key-pairs \<br>        --key-name AcmeLabs-MovieDB-KP \<br>        --query &#39;KeyPairs[0].KeyPairId&#39; \<br>        --output text) \<br>    --tags Key=Name,Value=AcmeLabs-MovieDB-KP<br><br># Add Key-Pair Name to Parameter Store<br>aws ssm put-parameter \<br>--name &quot;/AcmeLabs/MovieDB/KeyPair/Name&quot; \<br>--value &quot;AcmeLabs-MovieDB-KP&quot; \<br>--type &quot;String&quot; \<br>--overwrite</pre><h4>Ubuntu AMI</h4><p>We’ll query the latest Ubuntu 24.x ami id and add to to SSM parameter store.</p><pre># Query Ubuntu 24.04 Latest AMI<br>aws ssm get-parameters --names \<br>   /aws/service/canonical/ubuntu/server/24.04/stable/current/amd64/hvm/ebs-gp3/ami-id<br><br># Add Latest Ubuntu 24.x AMI ID to SSM - Parameter Store<br>aws ssm put-parameter \<br>    --name &quot;/AcmeLabs/MovieDB/Ami/Ubuntu24.x/Latest/ID&quot; \<br>    --value &quot;ami-05c17b22914ce7378&quot; \<br>    --type &quot;String&quot; \<br>    --overwrite</pre><h4>Secrets Manager</h4><p>We’ll securely store our TMDB API key in AWS Secrets Manager for retrieval by the Lambda function.</p><pre># Define TMDB API Key<br>aws secretsmanager create-secret \<br>    --name AcmeLabsMovieDBTMDBKey \<br>    --secret-string &#39;{&quot;apikey&quot;: &quot;TMDB_API_KEY&quot;}&#39;</pre><h4>Infrastructure</h4><p>We’ll create the majority of our infrastructure with a CloudFormation template.</p><pre># Create Infrastructure<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabs-MovieDB-Infra \<br>    --template-body file://acmelabs_moviedb_infra.yml \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h4>Lambda Function</h4><p>We’ll upload our Lambda function to our S3 bucket and initiate the CloudFormation template to create the Lambda function. This function will connect to TMDB to retrieve the latest top movies daily, scheduled to run at midnight.</p><pre># Upload Lambda Function<br>aws s3 cp \<br>    lambda/TmdbApiRetriever.zip \<br>    s3://acmelabs-moviedb-lambda-2025<br><br># Create Lambda TMDB API Function<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabs-MovieDB-Lambda-TMDB-API \<br>    --template-body file://acmelabs_moviedb_lambda_tmdb_api.yml \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h3>Test</h3><p>To verify functionality, we’ll connect to our EC2 instance and execute the following queries.</p><pre># Scan DynamoDB for the last 20 results<br>aws dynamodb scan \<br>    --table-name TopMovies \<br>    --limit 20 \<br>    --output yaml<br><br># Create new entry<br>aws dynamodb put-item \<br>    --table-name TopMovies \<br>    --item &#39;{<br>        &quot;MovieID&quot;: {&quot;S&quot;: &quot;test_movie_001&quot;},<br>        &quot;genres&quot;: {&quot;S&quot;: &quot;Action, Adventure&quot;},<br>        &quot;overview&quot;: {&quot;S&quot;: &quot;This is a test movie overview.&quot;},<br>        &quot;poster_path&quot;: {&quot;S&quot;: &quot;https://example.com/poster.jpg&quot;},<br>        &quot;rating&quot;: {&quot;N&quot;: &quot;8.5&quot;},<br>        &quot;release_year&quot;: {&quot;S&quot;: &quot;2025&quot;}<br>    }&#39;</pre><figure><img alt="DynamoDB Scan Results" src="https://cdn-images-1.medium.com/max/1024/1*Glucvjd-P5S-1l7z5r0ZeQ.jpeg" /><figcaption>DynamoDB Scan Results</figcaption></figure><figure><img alt="DynamoDB Insert Item Failed" src="https://cdn-images-1.medium.com/max/1024/1*R4INRa_UwvOt6I2Y33eWHg.jpeg" /><figcaption>DynamoDB Insert Item Failed</figcaption></figure><h3>Conclusion</h3><p>In this project, we successfully created an efficient system to automatically fetch and store the latest top movies from The Movie Database (TMDB) using AWS services. By integrating DynamoDB, AWS Lambda, and EC2, we built a seamless workflow that updates our movie database every night at midnight.</p><h4><strong>What We Accomplished</strong></h4><ul><li><strong>Infrastructure Setup</strong>: We laid the groundwork with a secure network that includes a Virtual Private Cloud (VPC), public subnet, internet gateway, and security groups to ensure safe access.</li><li><strong>DynamoDB Integration</strong>: We set up DynamoDB to keep our movie data organized and easily retrievable, which is crucial for our application.</li><li><strong>Lambda Function Deployment</strong>: We created a Lambda function that connects to the TMDB API, pulling in the latest movies automatically. This means our database stays fresh without any manual updates.</li><li><strong>Automation</strong>: By scheduling the Lambda function to run nightly, we’ve automated the data retrieval process, saving time and ensuring accuracy.</li><li><strong>Testing and Validation</strong>: We ran tests to confirm that everything works as planned, including checking our DynamoDB table and adding new movie entries.</li></ul><h4><strong>Looking Ahead</strong></h4><p>As we move forward, there are a few exciting steps we can take:</p><ul><li><strong>Frontend Development</strong>: It’s time to start building the user interface for our web application, where users can browse the latest movies.</li><li><strong>Error Handling</strong>: We can enhance our Lambda function with better error handling to manage any issues that might arise when fetching data from the TMDB API.</li><li><strong>Monitoring</strong>: Setting up monitoring tools like AWS CloudWatch will help us keep an eye on the performance of our Lambda function and the health of our database.</li><li><strong>Scaling</strong>: As our user base grows, we’ll want to explore ways to scale our application and optimize our DynamoDB setup for better performance.</li></ul><p>Overall, AcmeLabs now has a solid foundation for managing movie data effectively, setting the stage for a fantastic web application that keeps users up-to-date with the latest films. This project not only showcases the power of AWS but also highlights how we can leverage technology to create a better user experience.</p><p><a href="https://medium.com/u/331e9964766c">LaSherr&#39;e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara Hibben</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a> <a href="https://medium.com/u/efc3aac42050">Tait Hoglund</a> <a href="https://medium.com/u/6f71604051be">Zaire Ali</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5308abd22d7f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS: Two-Tier Architecture]]></title>
            <link>https://medium.com/@carrickbradley/aws-two-tier-architecture-c21856c34d49?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/c21856c34d49</guid>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[rds]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[two-tier-architecture]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Wed, 07 May 2025 15:42:16 GMT</pubDate>
            <atom:updated>2025-05-07T15:42:16.560Z</atom:updated>
            <content:encoded><![CDATA[<p>On this journey we’re going to create a two-tiered architecture for AcmeLabs. They have more needs, we have the skills to devise a solution.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Qz8IJLEy3xKuLanFvtcaOg.png" /></figure><h3>What is a Two-Tier Architecture</h3><p><strong>Two-Tier Architecture</strong> is a straightforward setup for applications that consists of two main parts:</p><p>1. <strong>Client Tier</strong>: This is where users interact with the application, usually through an easy-to-use interface on their devices. It’s like the front desk of a hotel, where guests check in and get information.</p><p>2. <strong>Server Tier</strong>: This part does the heavy lifting behind the scenes. It processes data, manages databases, and handles all the complex tasks needed to keep the application running smoothly.</p><h3>Use Case</h3><p>AcmeLabs is looking to establish a content management system using Joomla with a two-tier architecture. In this setup, the first tier will host a web server that connects to the second tier, which will be their database. They’ve requested the use of Amazon RDS in a multi-availability zone configuration with a standby instance, utilizing only two availability zones. It’s important to follow best practices for security throughout this process. Additionally, the goal is to manage most of the setup using CloudFormation to minimize manual intervention.</p><h3>Prerequisites</h3><ul><li>AWS Account</li><li><a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI Installed</a> &amp; <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html">Configured</a></li><li>Terminal Emulator</li><li>Bash 3.2.57 or newer</li><li><a href="https://github.com/carrickcancloud/AWS/tree/main/TwoTierJoomla">Project Files</a></li></ul><h3>Lets Get Started</h3><ol><li>Download the <a href="https://github.com/carrickcancloud/AWS/tree/main/TwoTierJoomla">Project Files</a></li><li>Change directory to the root of the project files</li></ol><h4>Key-Pair</h4><pre># Create Key-Pair<br>aws ec2 create-key-pair \<br>    --key-name AcmeLabs-Blog-KP \<br>    --query &#39;KeyMaterial&#39; \<br>    --output text &gt; AcmeLabs-Blog-KP.pem<br><br># Set Permissions on Key-Pair Priavate Key<br>chmod 400 AcmeLabs-Blog-KP.pem<br><br># Tag Key-Pair<br>aws ec2 create-tags \<br>    --resources $(aws ec2 describe-key-pairs \<br>        --key-name AcmeLabs-Blog-KP \<br>        --query &#39;KeyPairs[0].KeyPairId&#39; \<br>        --output text) \<br>    --tags Key=Name,Value=AcmeLabs-Blog-KP<br><br># Add Key-Pair Name to Parameter Store<br>aws ssm put-parameter --name &quot;/AcmeLabs/Blog/KeyPair/Name&quot; --value &quot;AcmeLabs-Blog-KP&quot; --type &quot;String&quot; --overwrite</pre><h4>Ubuntu AMI</h4><pre># Query Ubuntu 24.04 Latest AMI<br>aws ssm get-parameters --names \<br>   /aws/service/canonical/ubuntu/server/24.04/stable/current/amd64/hvm/ebs-gp3/ami-id<br><br># Add Latest Ubuntu 24.x AMI ID to SSM - Parameter Store<br>aws ssm put-parameter \<br>    --name &quot;/AcmeLabs/Blog/Ami/Ubuntu24.x/Latest/Id&quot; \<br>    --value &quot;ami-05c17b22914ce7378&quot; \<br>    --type &quot;String&quot; \<br>    --overwrite</pre><h4>Virtual Private Cloud (VPC)</h4><pre># VPC CloudFormation Stack<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabsBlogVPC-1 \<br>    --template-body file://1_acmelabs_blog_vpc.json \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h4>Simple Storage Service (S3)</h4><pre># S3 Bucket CloudFormation Stack<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabsBlogAmiS3Bucket-2 \<br>    --template-body file://2_acmelabs_blog_ami_s3.json \<br>    --capabilities CAPABILITY_NAMED_IAM<br><br># Upload Scripts<br>aws s3 cp \<br>    scripts/ \<br>    s3://acmelabs-blog-ami-2025/scripts/ \<br>    --recursive \<br>    --exclude &quot;*.DS_Store&quot;<br><br># Upload HTML<br>aws s3 cp \<br>    html/ \<br>    s3://acmelabs-blog-ami-2025/html/ \<br>    --recursive \<br>    --exclude &quot;*.DS_Store&quot;</pre><h4>Elastic File System (EFS)</h4><pre>aws cloudformation create-stack \<br>    --stack-name AcmeLabsBlogEFS-3 \<br>    --template-body file://3_acmelabs_blog_efs.json \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h4>Identity and Access Manager (IAM) — Roles</h4><pre># IAM Role CloudFormation Stack<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabsBlogEc2IamRole-4 \<br>    --template-body file://4_acmelabs_blog_ec2_iam_role.json \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h4><strong>Relational Database Service (</strong>RDS)</h4><pre># Define RDS Credentials<br>aws secretsmanager create-secret \<br>    --name AcmeLabsBlogRDSMySQL1 \<br>    --secret-string &#39;{&quot;username&quot;:&quot;USERNAME&quot;,&quot;password&quot;:&quot;PASSWORD&quot;}&#39;<br><br># Define Joomla Admin Credentials<br>aws secretsmanager create-secret \<br>    --name AcmeLabsBlogAdmin \<br>    --secret-string &#39;{&quot;username&quot;:&quot;USERNAME&quot;,&quot;password&quot;:&quot;PASSWORD&quot;}&#39;<br><br># RDS CloudFormation Stack<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabsBlogRDS-5 \<br>    --template-body file://5_acmelabs_blog_rds.json \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h4>Elastic Cloud Compute (EC2)</h4><pre># EC2 Source CloudFormation Stack<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabsBlogEc2Source-6 \<br>    --template-body file://6_acmelabs_blog_ec2_source.json \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h4>Elastic Load Balancer (ELB)</h4><pre># ALB CloudFormation Stack<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabsBlogALB-7 \<br>    --template-body file://7_acmelabs_blog_alb.json \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h4>Auto Scaling Group (ASG)</h4><pre># ASG CloudFormation Stack<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabsBlogASG-8 \<br>    --template-body file://8_acmelabs_blog_asg.json \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h4>Route53</h4><pre># Query Hostedzone ID for acmelabs.cloud<br>aws route53 list-hosted-zones \<br>    --query &quot;HostedZones[?Name==&#39;acmelabs.cloud.&#39;].[Id]&quot; \<br>    --output text<br><br># Put Hostedzone ID for acmelabs.cloud to Parameter Store<br>aws ssm put-parameter --name &quot;/AcmeLabs/Blog/Route53/HostedZone/Id&quot; \<br>    --value &quot;Z087608618II6FJ5B93HU&quot; \<br>    --type &quot;String&quot; \<br>    --overwrite<br><br># Create CloudFormation Stack<br>aws cloudformation create-stack \<br>    --stack-name AcmeLabsBlogRoute53-9 \<br>    --template-body file://9_acmelabs_blog_r53.json \<br>    --capabilities CAPABILITY_NAMED_IAM</pre><h4>TLS</h4><p><strong>Note</strong>: The ALB will generate a certificate with ACM. We will need to query our certificates to get the ARN to query our certicate directly to get the two validation DNS records. This may take sometime for the validation to be “Success” state after the DNS records are created.</p><pre># List Certificates<br>aws acm list-certificates<br><br># Query Certificate<br>aws acm describe-certificate --certificate-arn arn:aws:acm:us-east-1:047719623795:certificate/17326e83-04f2-4e60-bfcb-c0191e227d7f<br><br># Create Route53 Validation Record<br>aws route53 change-resource-record-sets --hosted-zone-id Z087608618II6FJ5B93HU --change-batch &#39;{<br>    &quot;Changes&quot;: [<br>        {<br>            &quot;Action&quot;: &quot;CREATE&quot;,<br>            &quot;ResourceRecordSet&quot;: {<br>                &quot;Name&quot;: &quot;_91641719ec17e70f5253df65a9b5d622.blog.acmelabs.cloud.&quot;,<br>                &quot;Type&quot;: &quot;CNAME&quot;,<br>                &quot;TTL&quot;: 300,<br>                &quot;ResourceRecords&quot;: [<br>                    {<br>                        &quot;Value&quot;: &quot;_4cc2d07613df2833bb0877bd7764fbb4.xlfgrmvvlj.acm-validations.aws.&quot;<br>                    }<br>                ]<br>            }<br>        }<br>    ]<br>}&#39;</pre><h3>Test</h3><ol><li>Goto <a href="https://blog.acmelabs.cloud/">https://blog.acmelabs.cloud</a></li><li>Validate the site comes up</li></ol><figure><img alt="Joomla Homepage" src="https://cdn-images-1.medium.com/max/1024/1*W_IqQZKoUCFlXV_Bqs65WQ.jpeg" /><figcaption>Joomla Homepage</figcaption></figure><p>2. Login to Joomla administrator: <a href="https://blog.acmelabs.cloud/administrator/">https://blog.acmelabs.cloud/administrator/</a><br><strong>Note</strong>: The login is saved in Secrets Manager</p><figure><img alt="Joomla Administrator Login" src="https://cdn-images-1.medium.com/max/1024/1*bEkN97R7wnGatStCatGXfw.jpeg" /><figcaption>Joomla Administrator Login</figcaption></figure><p>3. Administrator Dashboard</p><figure><img alt="Joomla Administrator Dashboard" src="https://cdn-images-1.medium.com/max/1024/1*Jhu7H1jwwP8T16LN5B3btQ.jpeg" /><figcaption>Joomla Administrator Dashboard</figcaption></figure><p>4. Create an Article</p><ul><li>Title: <strong>Thats All Folks</strong></li><li>Article Text: If you want, you can upload an image or right something.</li><li><strong><em>Images and Links</em></strong> Tab: Use this to upload an <strong>Intro</strong> &amp; <strong>Full Article</strong> image</li><li>Status: <strong>Published</strong></li><li>Featured: Select <strong>Yes</strong></li><li>Click on Save &amp; Close</li><li>Gotot <a href="https://blog.acmelabs.cloud/">https://blog.acmelabs.cloud</a></li></ul><figure><img alt="Our First Article" src="https://cdn-images-1.medium.com/max/1024/1*fKJqG9WC-eYSCkFB-QzbSw.jpeg" /><figcaption>Our First Article</figcaption></figure><h4>Stress Test</h4><p>Let’s stress test our EC2 instances to validate our ASG target tracking policy works as we expected. Should grow up to max of six EC2 instances. We’ll test in both directions, scale-out &amp; scale-in.</p><ol><li>Allocate two <strong>Elastic IPs</strong></li><li><strong>Associate</strong> each Elastic IPs with our EC2 instances</li><li>Add in <strong>inbound rule </strong>to<strong> </strong>our security group <strong>AcmeLabs-Blog-EC2-SG</strong> to allow SSH from anywhere</li><li>Shell over to each EC2 Instance using our KeyPair</li><li>Once shelled over run the following:</li></ol><pre># Update Package List<br>sudo apt-get update<br><br># Install stress with -y to say yes<br>sudo apt-get install -y stress<br><br># Stress Me Out<br>sudo stress --cpu 2000 --timeout 3600</pre><p><strong>Note</strong>: The last time I ran this I was still able to break the stress testing while on the terminal, if you are unable to, that’s OK, we can terminate these EC2 instances.</p><h4>ASG Scaling Out</h4><p>Here are screenshots showing the ASG is adding more EC2 instances once the AVG CPU utilization of instance within the ASG is 50% or greater. There is a 300 second warm up time for the EC2 instances to allow the instances to become initialized before being part of the ASG.</p><p>During this time check the site at <a href="https://blog.acmelabs.cloud/">https://blog.acmelabs.cloud</a> to see if it’s accessible. I found it was though overtime, until new EC2 instances were available, the responses were taking longer. Oddly the two instances running stress did not Halt and Catch Fire (HCF), so hits did go to them though responses were very slow.</p><figure><img alt="AVG CPU Utilization Greater Than 50%" src="https://cdn-images-1.medium.com/max/1024/1*07nFFpMAzt3MkgfWFX4guw.jpeg" /><figcaption>AVG CPU Utilization Greater Than 50%</figcaption></figure><figure><img alt="EC2 Instances Spinning Up" src="https://cdn-images-1.medium.com/max/1024/1*-ypAn0_GZjv6UCRsmDl14Q.jpeg" /><figcaption>EC2 Instances Spinning Up</figcaption></figure><figure><img alt="ASG Scaling Out" src="https://cdn-images-1.medium.com/max/1024/1*MahI3KXq28MDySfjbG0IUA.jpeg" /><figcaption>ASG Scaling Out</figcaption></figure><h4>ASG Scaling In</h4><p>Here are screenshots showing the ASG is removing EC2 instances once the AVG CPU utilization of instance within the ASG is lower than 50%. There is a 300 second warm up time for the EC2 instances to allow the instances to become initialized before being part of the ASG.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tNw7evNWj1icayHjLXJ51A.jpeg" /><figcaption>AVG CPU Utilization Below 50%</figcaption></figure><figure><img alt="EC2 Instances Spinning Down" src="https://cdn-images-1.medium.com/max/1024/1*EQWhYOAnery7VdyHnKhe1Q.jpeg" /><figcaption>EC2 Instances Spinning Down</figcaption></figure><figure><img alt="ASG Scaling In" src="https://cdn-images-1.medium.com/max/1024/1*i6pawCaM4r_mg2fnu0RCPQ.jpeg" /><figcaption>ASG Scaling In</figcaption></figure><h3>Conclusion</h3><p>We successfully deployed the Joomla CMS for AcmeLabs for use a blog. We created few pieces using AWS CLI that we then utilzed with our CloudFormation templates. From the templates we created a two-tier architecture that utilizes the following services:</p><ul><li>AWS KeyPair</li><li>AWS Virtual Private Cloud</li><li>AWS S3 Bucket</li><li>AWS Elastic File System (Public Tier, WebRoot)</li><li>AWS Identity Access Manage Role</li><li>AWS RouteTables (Public &amp; Private)</li><li>AWS Internet Gateway (Public Tier)</li><li>AWS NAT Gateway (Private Tier)</li><li>AWS Security Groups</li><li>AWS Relation DataBase Service (Multi-AZ)</li><li>AWS Elastic Cloud Compute</li><li>AWS Amazon Machine Image</li><li>AWS Application Load Balancer</li><li>AWS Target Group</li><li>AWS Launch Template</li><li>AWS Auto-Scaling Group</li><li>AWS Certificate Manager (TLS Connections)</li><li>AWS Route53</li></ul><p><strong>“You are never too old to set another goal or to dream a new dream.”</strong> — C.S. Lewis</p><p>Incase you forgot, You Too Can Cloud!</p><p><a href="https://medium.com/u/331e9964766c">LaSherr&#39;e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara Hibben</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a> <a href="https://medium.com/u/efc3aac42050">Tait Hoglund</a> <a href="https://medium.com/u/6f71604051be">Zaire Ali</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c21856c34d49" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS: CloudFormation]]></title>
            <link>https://medium.com/@carrickbradley/aws-cloudformation-afad76c56d18?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/afad76c56d18</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-cloudformation]]></category>
            <category><![CDATA[aws-ssm]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Mon, 28 Apr 2025 21:20:24 GMT</pubDate>
            <atom:updated>2025-04-28T21:20:24.227Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Image generated with DeepAI" src="https://cdn-images-1.medium.com/max/1024/1*rwFwP5GrwRxG0k6BC6GPhg.png" /><figcaption>Image generated with DeepAI</figcaption></figure><h3>Use Case</h3><p>AcmeLabs would like to from manually creating their infrastructure to a modern approach with infrastructure as code (IaC). Building upon our last article <a href="https://medium.com/@carrickbradley/aws-ec2-aws-cli-expanded-bbfb12aca9ac"><strong><em>AWS EC2: AWS CLI Expanded</em></strong></a>, we’re going to adopt AWS CloudFormation to deploy the same infrastructure to maintain a consistent end state that we expect. We’ll take advantage of Amazon Simple Systems Manager (SSM) — Parameter Store so that we can store parameter key-pair values that the CloudFormation templates generate and use throughout.</p><p>For reference, here’s what our architecture will look like after deploying our CloudFormation templates.</p><figure><img alt="AcmeLabs.Cloud Architecture — Created In Draw.io" src="https://cdn-images-1.medium.com/max/841/0*OaqER0zLHSEVJp6x.jpeg" /><figcaption>AcmeLabs.Cloud Architecture — Created In Draw.io</figcaption></figure><h4>What is AWS CloudFormation?</h4><p>AWS CloudFormation is a powerful tool that allows us to manage our cloud infrastructure as code. By writing our infrastructure in simple text files, we can automate the creation and management of AWS resources, saving time and reducing manual errors. It integrates seamlessly with various AWS services, supports easy change management, and helps us track costs with resource tagging. Plus, we can deploy resources across multiple regions and accounts effortlessly. With CloudFormation, we ensure a consistent, efficient, and secure cloud environment, allowing our team to focus on building rather than managing infrastructure.</p><h3>Prerequisites</h3><ol><li>AWS Account</li><li><a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI Installed</a> &amp; <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html">Configured</a></li><li>Terminal Emulator</li><li>Bash 3.2.57 or newer</li><li><a href="https://drive.google.com/file/d/1JMIeWQ1B_nHyQag0OgzQw4Rn5DvM2Fid/view?usp=sharing">Project Files</a></li></ol><h3>Lets Get Started</h3><ol><li>Download the <a href="https://drive.google.com/file/d/1JMIeWQ1B_nHyQag0OgzQw4Rn5DvM2Fid/view?usp=sharing">Project Files</a></li><li>Change directory to the root of the project files</li></ol><p>For this setup, I already have a hosted zone for “acmelabs.cloud.” If you want to get this working, you’ll need to create your own hosted zone by first registering a domain with Route 53 and then setting up the hosted zone. Make sure to modify the project files wherever “acmelabs.cloud” is referenced, changing it to your own domain.</p><p>When you generate a certificate, I recommend using DNS validation. This will require you to create two CNAME records in your hosted zone for Amazon Certificate Manager to validate your ownership of the domain. It’s important to ensure these records are in place before you create the Application Load Balancer (ALB), as the stack may take a while to complete, especially if the certificate is in a ⁠CREATE_FAILED state.</p><h4>VPC</h4><p>Our foundation starts with the network.</p><ol><li>Use CloudFormation template named: <strong><em>1_acmelabs_web_vpc.yaml</em></strong></li></ol><pre># Create CloudFormation Stack<br>aws cloudformation create-stack --stack-name AcmeLabsWebVpc1of8 --template-body file://1_acmelabs_web_vpc.yaml --capabilities CAPABILITY_NAMED_IAM</pre><h4>Simple Storage Service (S3)</h4><p>We’ll create an S3 bucket used for the storing our files needed to build our own Amazon Machine Image (AMI).</p><ol><li>Add parameter to SSM — Parameter Store</li></ol><pre># Add Bucket Name to Parameter Store<br>aws ssm put-parameter --name &quot;/acmelabs/ami/s3/bucket&quot; --value &quot;acmelabs-web-ami-2025&quot; --type &quot;String&quot; --overwrite</pre><p>2. Use the CloudFormation template named: <strong><em>2_acmelabs_web_ami_s3.yaml</em></strong></p><pre># Create CloudFormation Stack<br>aws cloudformation create-stack --stack-name AcmeLabsWebAmiS3Bucket2of8 --template-body file://2_acmelabs_web_ami_s3.yaml --capabilities CAPABILITY_NAMED_IAM</pre><p>3. Upload Files<br>Make sure you’re in the root of the project files where the following directories are listed: html, images, and scripts, otherwise these commands will fail.</p><pre># Upload Scripts<br>aws s3 cp \<br>    scripts/ \<br>    s3://acmelabs-web-ami-2025/scripts/ \<br>    --recursive \<br>    --exclude &quot;*.DS_Store&quot;<br><br># Upload Images<br>aws s3 cp \<br>    images/ \<br>    s3://acmelabs-web-ami-2025/images/ \<br>    --recursive \<br>    --exclude &quot;*.DS_Store&quot;<br><br># Upload HTML<br>aws s3 cp \<br>    html/ \<br>    s3://acmelabs-web-ami-2025/html/ \<br>    --recursive \<br>    --exclude &quot;*.DS_Store&quot;</pre><h4>Elastic File System (EFS)</h4><p>We’ll use EFS to store our site images in.</p><ol><li>Use the CloudFormation template named: <strong><em>3_acmelabs_web_efs.yaml</em></strong></li></ol><pre># Create CloudFormation Stack<br>aws cloudformation create-stack --stack-name AcmeLabsWebEfs3of8 --template-body file://3_acmelabs_web_efs.yaml --capabilities CAPABILITY_NAMED_IAM</pre><h4>Identity and Access Manager (IAM) — Roles</h4><p>Our EC2 instances out of the box can’t talk to S3. To achieve this, we’ll create a role along with a policy and other components to enable access.</p><ol><li>Use the CloudFormation template named: <strong><em>4_acmelabs_web_ec2_iam_role.yaml</em></strong></li></ol><pre># Create CloudFormation Stack<br>aws cloudformation create-stack --stack-name AcmeLabsEc2IamRole4of8 --template-body file://4_acmelabs_web_ec2_iam_role.yaml --capabilities CAPABILITY_NAMED_IAM</pre><h4>Key-Pair</h4><p>We’ll create a key-pair so we can access our EC2 instances if needed. Otherwise, we’ll have to generate one, then redeploy our existing EC2 instances should we choose not to at this time. In production, that will cause and incident should we need to redeploy and instance with a key-pair.</p><pre># Create Key-Pair<br>aws ec2 create-key-pair \<br>    --key-name AcmeLabs-Web-KP \<br>    --query &#39;KeyMaterial&#39; \<br>    --output text &gt; AcmeLabs-Web-KP.pem<br><br># Set Permissions on Key-Pair Priavate Key<br>chmod 400 AcmeLabs-Web-KP.pem<br><br># Tag Key-Pair<br>aws ec2 create-tags \<br>    --resources $(aws ec2 describe-key-pairs \<br>        --key-name AcmeLabs-Web-KP \<br>        --query &#39;KeyPairs[0].KeyPairId&#39; \<br>        --output text) \<br>    --tags Key=Name,Value=AcmeLabs-Web-KP<br><br># Add Key-Pair Name to Parameter Store<br>aws ssm put-parameter --name &quot;/acmelabs/ec2/keypair-web/name&quot; --value &quot;AcmeLabs-Web-KP&quot; --type &quot;String&quot; --overwrite</pre><h4>Ubuntu AMI</h4><p>Let’s get the AMI ID for the latest Ubuntu 24.x image and store it in SSM — Parameter Store.</p><ol><li><a href="https://documentation.ubuntu.com/aws/aws-how-to/instances/find-ubuntu-images/">Query AMI ID</a></li></ol><pre># Query Ubuntu 24.04 Latest AMI<br>aws ssm get-parameters --names \<br>   /aws/service/canonical/ubuntu/server/24.04/stable/current/amd64/hvm/ebs-gp3/ami-id<br><br># Add Latest Ubuntu 24.x AMI ID to SSM - Parameter Store<br>aws ssm put-parameter --name &quot;/acmelabs/ami/ubuntu24.x/latest/id&quot; --value &quot;ami-0f40b6e9b85d19284&quot; --type &quot;String&quot; --overwrite</pre><h4>EC2 Instance</h4><p>We’ll launch and EC2 instance that we’ll bake our goods to, create an AMI then delete the EC2 instance.</p><ol><li>Use the CloudFormation template named: <strong><em>5_acmelabs_web_ec2_instance.yaml</em></strong></li></ol><pre># Create CloudFormation Stack<br>aws cloudformation create-stack --stack-name AcmeLabsEc2Instance5of8 --template-body file://5_acmelabs_web_ec2_instance.yaml --capabilities CAPABILITY_NAMED_IAM</pre><h4>Elastic Load Balancer (ELB)</h4><p>To evenly distribute traffic and increase are availability to our EC2 instances we’ll create an Application Load Balancer (ALB). If we lose an instance, the ALB will remove it and route traffic to healthy EC2 instances while a replacement is spun up. We’ll create a health check to achieve this.</p><ol><li>Use the CloudFormation template named:<br><strong><em>6_acmelabs_web_alb.yaml</em></strong></li></ol><pre># Create CloudFormation Stack<br>aws cloudformation create-stack --stack-name AcmeLabsEc2Alb6of8 --template-body file://6_acmelabs_web_alb.yaml --capabilities CAPABILITY_NAMED_IAM</pre><h4>Auto Scaling Group (ASG)</h4><p>Wait to run this until the AMI is available and the EC2 instanced named “AcmeLabs-Web-Source” is terminated. Otherwise, the ASG will deploy instances with a partial completed AMI. In short, it’ll be broken.</p><p>We’ll create a launch template, auto-scaling group, certificate and a target tracking policy.</p><ol><li>Use the CloudFormation template named:<br><strong><em>7_acmelabs_web_asg.yaml</em></strong></li></ol><pre># Create CloudFormation Stack<br>aws cloudformation create-stack --stack-name AcmeLabsEc2Asg7of8 --template-body file://7_acmelabs_web_asg.yaml --capabilities CAPABILITY_NAMED_IAM</pre><h4>Route53</h4><p>We’ll define an SSM parameter for our hostedzone id that we’ll use with our template. Then we’ll execute our template which will create a few DNS records we’ll need.</p><ol><li>Use the CloudFormation template named:<br><strong><em>8_acmelabs_web_r53.yaml</em></strong></li></ol><pre># Query Hostedzone ID for acmelabs.cloud<br>aws route53 list-hosted-zones \<br>    --query &quot;HostedZones[?Name==&#39;acmelabs.cloud.&#39;].[Id]&quot; \<br>    --output text<br><br># Put Hostedzone ID for acmelabs.cloud to Parameter Store<br>aws ssm put-parameter --name &quot;/acmelabs/r53/hostedzone/id&quot; --value &quot;Z087608618II6FJ5B93HU&quot; --type &quot;String&quot; --overwrite<br><br># Create CloudFormation Stack<br>aws cloudformation create-stack --stack-name AcmeLabsRoute538of8 --template-body file://8_acmelabs_web_r53.yaml --capabilities CAPABILITY_NAMED_IAM</pre><h3>Test</h3><p>If all works we should see a page like this. Take note of the top right corner of the page. Refresh the page and we’ll bounce around three availability zones (AZ).</p><figure><img alt="US-EAST-1A" src="https://cdn-images-1.medium.com/max/1024/1*JTHl-qjSbl_dF1Uxq7ehqA.jpeg" /><figcaption>US-EAST-1A</figcaption></figure><figure><img alt="US-EAST-1B" src="https://cdn-images-1.medium.com/max/1024/1*NXmABXDm8TAU5PqQr1yK1A.jpeg" /><figcaption>US-EAST-1B</figcaption></figure><figure><img alt="US-EAST-1C" src="https://cdn-images-1.medium.com/max/1024/1*rmrO2uvm8nloBacAQXP35Q.jpeg" /><figcaption>US-EAST-1C</figcaption></figure><h3>Conclusion</h3><p>This was a lot of fun to convert a large amount of the work from <a href="https://medium.com/@carrickbradley/aws-ec2-aws-cli-expanded-bbfb12aca9ac"><strong><em>AWS EC2: AWS CLI Expanded</em></strong></a> to CloudFormation templates. I learned a great deal of what we can do with CloudFormation and what we can’t do.</p><p>Basically, CloudFormation is great for setting up and managing our AWS resources in a clear and straightforward way. But it does have some limits when it comes to tackling complex tasks, processing big chunks of data, or connecting with other systems. That’s where Lambda functions come into play. They give us the ability to run our own code and perform dynamic actions while we’re setting things up.</p><p>By using Lambda alongside CloudFormation, we can automate a lot of the heavy lifting, making our cloud environment more flexible and responsive. This combo lets us build more sophisticated applications that can easily adapt to our needs.</p><p>I realized that I used SSM parameters everywhere, but I could have combined them with outputs. By referencing the outputs, we can get the values we need to build our resources more effectively.</p><p>With that said, I’m looking forward to creating a new article that incorporates Lambda functions and cleans up the use of SSM where outputs could be used.</p><p>When it gets difficult, keep pushing forward. You too can cloud!</p><p><a href="https://medium.com/u/331e9964766c">LaSherr&#39;e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara Hibben</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a> <a href="https://medium.com/u/efc3aac42050">Tait Hoglund</a> <a href="https://medium.com/u/6f71604051be">Zaire Ali</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=afad76c56d18" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS EC2: AWS CLI Expanded]]></title>
            <link>https://medium.com/@carrickbradley/aws-ec2-aws-cli-expanded-bbfb12aca9ac?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bbfb12aca9ac</guid>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[aws-cli]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud-devops-engineer]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Sat, 12 Apr 2025 02:05:25 GMT</pubDate>
            <atom:updated>2025-04-27T00:57:18.280Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="AcmeLabs.Cloud Architecture — Created In Draw.io" src="https://cdn-images-1.medium.com/max/841/1*LSuvJg6Y6Af91NXQXBoL6g.jpeg" /><figcaption>AcmeLabs.Cloud Architecture — Created In Draw.io</figcaption></figure><h3>Use Case</h3><p>AcmeLabs has an EC2 instance they migrated to AWS awhile back. Now, they want take advantage of AWS services to add or improve their: <strong>Scalability</strong>, <strong>Reliability</strong>, <strong>Security, Cost Savings, </strong>and <strong>Flexibility</strong>.</p><p>To achieve this, our statement of work is:</p><ul><li>Create a VPC with the CIDR block: 10.10.0.0/16</li><li>Create an Internet Gateway &amp; attach it to our new VPC</li><li>Create three public subnets with CIDR blocks: 10.10.1.0/24, 10.10.2.0/24, and 10.10.3.0/24</li><li>Create an autoscaling group using t2.micro instances, use the public subnets, set the minimum amount of EC2 instances to 3 and the maximum 6, using the latest Ubuntu 24.x, ensure Apache web server is installed along with a web page</li><li>Create a scaling policy when 50% of the CPU utilization is used to scale out then scale in when CPU utilization dips below 50%</li><li>Create an Application Load Balancer to distribute the traffic to the EC2 instances</li><li>Create two Security groups, one for the Application Load Balancer allowing HTTP, second on for the EC2 instances allowing HTTP</li></ul><h3>Prerequisites</h3><ol><li>AWS Account</li><li><a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI Installed</a> &amp; <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html">Configured</a></li><li>Terminal Emulator</li><li>Bash 3.2.57 or newer</li><li><a href="https://drive.google.com/file/d/1knFuGtfhmBPieTxtsjcqamoKa1UihGJq/view?usp=sharing">Project Files</a></li></ol><h3>Lets Get Started</h3><p>For each AWS CLI command executed, review the output and take note of the resource ID, ARN, and or Name where applicable. We’ll need those to build out the rest of our commands from start to finish. We’ll also tag our resources with a “Name” tag where possible. Below is the list of IDs, ARNs, and Names I kept track of. For each one you create, find and replace mine with yours.</p><pre># List of IDs/ARNs/Names you must replace with yours.<br>vpc_id: vpc-0868038970bd1ab9d<br>igw_id: igw-00fe90aafd807d86b<br>rtb_id: rtb-045a89caa3b86ab5e<br>public_subnet_1_id: subnet-0c112f381394f54d9<br>public_subnet_2_id: subnet-09e8d4b16b4f7dd2b<br>public_subnet_3_id: subnet-0441acfbd58d84c74<br>alb_sg_id: sg-053350f6ad17b7f3f<br>ec2_web_sg_id: sg-0be64343db85129e6<br>bucket_name: acmelabs-web-2025<br>efs_fs_id: fs-0493f75b9bc987268<br>keypair_name: AcmeLabs-WEB-KP<br>iam_role_ec2_s3_name: AcmeLabsWEBEC2S3AccessRole<br>s3_permissions_policy_arn: arn:aws:iam::047719623795:policy/AcmeLabsWEBEC2S3ReadAccessPolicy<br>ec2_s3_instance_profile_name: AcmeLabsWEBEC2S3AccessProfile<br>ubuntu_ami_id: ami-09eb231ad55c3963d<br>ec2_instance_src_id: i-04dffcc34f586ffe6<br>our_ami_id: ami-06c4decc36f7ce21f<br>alb_arn: arn:aws:elasticloadbalancing:us-east-1:047719623795:loadbalancer/app/AcmeLabs-WEB-ALB/14929f913954185d<br>alb_dns: AcmeLabs-WEB-ALB-1156157756.us-east-1.elb.amazonaws.com<br>target_group_arn: arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59<br>launch_template_name: AcmeLabs-WEB-LT<br>asg_tracking_policy_arn: arn:aws:autoscaling:us-east-1:047719623795:scalingPolicy:3cc16975-0ede-44a0-b8b0-a8171e1c912e:autoScalingGroupName/AcmeLabs-ASG:policyName/ScaleUp<br>tls_arn: arn:aws:acm:us-east-1:047719623795:certificate/89f90795-1831-4b68-97a1-7043eec28c13<br>certificate_arn: arn:aws:acm:us-east-1:047719623795:certificate/89f90795-1831-4b68-97a1-7043eec28c13<br>elastic_ip_1: eipalloc-06324a683da7e015a<br>elastic_ip_2: eipalloc-0238459015730e598<br>elastic_ip_3: eipalloc-0f3f2f3f2f3f2f3f</pre><h4><strong>Virtual Private Cloud (VPC)</strong></h4><p>Lets carve out our piece of the network pie to create our VPC and other networking components we’ll need.</p><pre># Create VPC<br>aws ec2 create-vpc \<br>    --cidr-block 10.10.0.0/16 \<br>    --tag-specifications &#39;ResourceType=vpc,Tags=[{Key=Name,Value=AcmeLabs-VPC}]&#39;<br><br># Enable DNS Resolution<br>aws ec2 modify-vpc-attribute \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --enable-dns-support<br><br># Enable DNS Hostnames<br>aws ec2 modify-vpc-attribute \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --enable-dns-hostnames<br><br># Create Internet Gateway<br>aws ec2 create-internet-gateway \<br>    --tag-specifications &#39;ResourceType=internet-gateway,Tags=[{Key=Name,Value=AcmeLabs-IGW}]&#39;<br><br># Attach Internet Gateway<br>aws ec2 attach-internet-gateway \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --internet-gateway-id igw-00fe90aafd807d86b<br><br># Create Route Table<br>aws ec2 create-route-table \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --tag-specifications &#39;ResourceType=route-table,Tags=[{Key=Name,Value=AcmeLabs-RT}]&#39;<br><br># Create Route To Internet Gateway<br>aws ec2 create-route \<br>    --route-table-id rtb-045a89caa3b86ab5e \<br>    --destination-cidr-block 0.0.0.0/0 \<br>    --gateway-id igw-00fe90aafd807d86b<br><br># Create Public Subnet 1 in US-EAST-1A<br>aws ec2 create-subnet \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --cidr-block 10.10.1.0/24 \<br>    --availability-zone us-east-1a \<br>    --tag-specifications &#39;ResourceType=subnet,Tags=[{Key=Name,Value=AcmeLabsPublicSubnet1}]&#39;<br><br># Create Public Subnet 2 in US-EAST-1B<br>aws ec2 create-subnet \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --cidr-block 10.10.2.0/24 \<br>    --availability-zone us-east-1b \<br>    --tag-specifications &#39;ResourceType=subnet,Tags=[{Key=Name,Value=AcmeLabsPublicSubnet2}]&#39;<br><br># Create Public Subnet 3 in US-EAST-1C<br>aws ec2 create-subnet \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --cidr-block 10.10.3.0/24 \<br>    --availability-zone us-east-1c \<br>    --tag-specifications &#39;ResourceType=subnet,Tags=[{Key=Name,Value=AcmeLabsPublicSubnet3}]&#39;<br><br># Associate Public Subnet 1 To Route Table<br>aws ec2 associate-route-table \<br>    --subnet-id subnet-0c112f381394f54d9 \<br>    --route-table-id rtb-045a89caa3b86ab5e<br><br># Associate Public Subnet 2 To Route Table<br>aws ec2 associate-route-table \<br>    --subnet-id subnet-09e8d4b16b4f7dd2b \<br>    --route-table-id rtb-045a89caa3b86ab5e<br><br># Associate Public Subnet 3 To Route Table<br>aws ec2 associate-route-table \<br>    --subnet-id subnet-0441acfbd58d84c74 \<br>    --route-table-id rtb-045a89caa3b86ab5e<br><br># Create Load Balancer Security Group<br>aws ec2 create-security-group \<br>    --group-name WEBALBSG \<br>    --description &quot;Security group for our application load balancer to our web server EC2 instances.&quot; \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --tag-specifications &#39;ResourceType=security-group,Tags=[{Key=Name,Value=AcmeLabs-WEB-ALB-SG}]&#39;<br><br># Allow HTTP traffic from anywhere<br>aws ec2 authorize-security-group-ingress \<br>    --group-id sg-053350f6ad17b7f3f \<br>    --protocol tcp \<br>    --port 80 \<br>    --cidr 0.0.0.0/0<br><br># Create EC2 Security Group<br>aws ec2 create-security-group \<br>    --group-name WEBEC2SG \<br>    --description &quot;Security group for our web server EC2 instances.&quot; \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --tag-specifications &#39;ResourceType=security-group,Tags=[{Key=Name,Value=AcmeLabs-WEB-EC2-SG}]&#39;<br><br># Allow HTTP traffic from ALB SG To EC2 SG<br>aws ec2 authorize-security-group-ingress \<br>    --group-id sg-0be64343db85129e6 \<br>    --protocol tcp \<br>    --port 80 \<br>    --source-group sg-053350f6ad17b7f3f</pre><h4>Simple Storage Service (S3)</h4><p>Taking advantage of S3 to store some files that will downloaded into an EC2 instance that we’ll create our own Amazon Machine Image (AMI) from. I’m on a Mac so I use the “exclude” option when uploading to avoid making a mess out of our S3 bucket. Plus, why pay for storage on files that we’re not going to use.</p><p><strong><em>Due to globally unique bucket names, please set the name to something unique to avoid using the same name.</em></strong></p><pre># Create S3 Bucket<br>aws s3api create-bucket \<br>    --bucket acmelabs-web-2025 \<br>    --region us-east-1<br><br># Tag Bucket<br>aws s3api put-bucket-tagging \<br>    --bucket acmelabs-web-2025 \<br>    --tagging &#39;TagSet=[{Key=Name,Value=AcmeLabs-Web-2025}]&#39;<br><br># Upload Scripts<br>aws s3 cp \<br>    scripts/ \<br>    s3://acmelabs-web-2025/scripts/ \<br>    --recursive \<br>    --exclude &quot;*.DS_Store&quot;<br><br># Upload Images<br>aws s3 cp \<br>    images/ \<br>    s3://acmelabs-web-2025/images/ \<br>    --recursive \<br>    --exclude &quot;*.DS_Store&quot;<br><br># Upload HTML<br>aws s3 cp \<br>    html/ \<br>    s3://acmelabs-web-2025/html/ \<br>    --recursive \<br>    --exclude &quot;*.DS_Store&quot;</pre><h4>Elastic File System (EFS)</h4><p>We’ll use EFS to store our site images in.</p><pre># Create EFS File System<br>aws efs create-file-system \<br>    --creation-token AcmeLabsEFS \<br>    --performance-mode generalPurpose \<br>    --encrypted \<br>    --tags Key=Name,Value=AcmeLabs-EFS<br><br># Create Mount Targets<br>aws efs create-mount-target \<br>    --file-system-id fs-0493f75b9bc987268 \<br>    --subnet-id subnet-0c112f381394f54d9 \<br>    --security-groups sg-0be64343db85129e6<br><br>aws efs create-mount-target \<br>    --file-system-id fs-0493f75b9bc987268 \<br>    --subnet-id subnet-09e8d4b16b4f7dd2b \<br>    --security-groups sg-0be64343db85129e6<br><br>aws efs create-mount-target \<br>    --file-system-id fs-0493f75b9bc987268 \<br>    --subnet-id subnet-0441acfbd58d84c74 \<br>    --security-groups sg-0be64343db85129e6<br><br># Update EC2 Security Group To Allow EFS Traffic<br>aws ec2 authorize-security-group-ingress \<br>    --group-id sg-0be64343db85129 \<br>    --protocol tcp \<br>    --port 2049 \</pre><h4>Key-Pair</h4><p>We’ll create a key-pair so we can access our EC2 instances if needed. Otherwise, we’ll have to generate one, then redeploy our existing EC2 instances should we choose not to at this time.</p><pre># Create Key-Pair<br>aws ec2 create-key-pair \<br>    --key-name AcmeLabs-WEB-KP \<br>    --query &#39;KeyMaterial&#39; \<br>    --output text &gt; AcmeLabs-WEB-KP.pem<br><br># Tag Key-Pair<br>aws ec2 create-tags \<br>    --resources $(aws ec2 describe-key-pairs \<br>        --key-name AcmeLabs-WEB-KP \<br>        --query &#39;KeyPairs[0].KeyPairId&#39; \<br>        --output text) \<br>    --tags Key=Name,Value=AcmeLabs-WEB-KP</pre><h4>Identity and Access Manager (IAM) — Roles</h4><p>Our EC2 instances out of the box can’t talk to S3. To achieve this, we’ll create a role along with a policy and other components to enable access.</p><pre># Create IAM Role For EC2 S3 Access<br>aws iam create-role \<br>    --role-name AcmeLabsWEBEC2S3AccessRole \<br>    --assume-role-policy-document &#39;{<br>        &quot;Version&quot;: &quot;2012-10-17&quot;,<br>        &quot;Statement&quot;: [<br>            {<br>                &quot;Effect&quot;: &quot;Allow&quot;,<br>                &quot;Principal&quot;: {<br>                    &quot;Service&quot;: &quot;ec2.amazonaws.com&quot;<br>                },<br>                &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>            }<br>        ]<br>    }&#39;<br><br># Create S3 Permissions Policy<br>aws iam create-policy \<br>    --policy-name AcmeLabsWEBEC2S3ReadAccessPolicy \<br>    --policy-document &#39;{<br>        &quot;Version&quot;: &quot;2012-10-17&quot;,<br>        &quot;Statement&quot;: [<br>            {<br>                &quot;Effect&quot;: &quot;Allow&quot;,<br>                &quot;Action&quot;: [<br>                    &quot;s3:ListBucket&quot;,<br>                    &quot;s3:GetObject&quot;<br>                ],<br>                &quot;Resource&quot;: [<br>                    &quot;arn:aws:s3:::acmelabs-web-2025&quot;,<br>                    &quot;arn:aws:s3:::acmelabs-web-2025/*&quot;<br>                ]<br>            }<br>        ]<br>    }&#39;<br><br># Attach EC2 S3 IAM Role Policy<br>aws iam attach-role-policy \<br>    --role-name AcmeLabsWEBEC2S3AccessRole \<br>    --policy-arn arn:aws:iam::047719623795:policy/AcmeLabsWEBEC2S3ReadAccessPolicy<br><br># Create EC2 S3 Instance Profile<br>aws iam create-instance-profile \<br>    --instance-profile-name AcmeLabsWEBEC2S3AccessProfile<br><br># Associate EC2 S3 Instance Profile To EC2 S3 IAM Role<br>aws iam add-role-to-instance-profile \<br>    --instance-profile-name AcmeLabsWEBEC2S3AccessProfile \<br>    --role-name AcmeLabsWEBEC2S3AccessRole</pre><h4>Elastice Cloud Compute (EC2)</h4><p>Now we’re cooking with gasoline. Let’s build out our compute components.</p><p><strong>Note:</strong></p><ul><li>I found this nice article from Canonical that explains how to query their latest AMIs in AWS: <a href="https://documentation.ubuntu.com/aws/aws-how-to/instances/find-ubuntu-images/">https://documentation.ubuntu.com/aws/aws-how-to/instances/find-ubuntu-images/</a>.</li><li>Update the BUCKET_NAME=”acmelabs-web-2025&quot; to your bucket name</li><li>Update the EFS_FS=”” to your EFS FS ID</li><li>Allow the EC2 instance to launch and become healthy</li><li>Make sure<strong><em> Query EC2 Instance Status</em></strong> = <strong><em>Running</em></strong> &amp; <strong><em>Query EC2 Instance Health State</em></strong> = <strong><em>ok</em></strong>, before creating the AMI</li><li>After the AMI is <strong><em>available</em></strong>, move forward with deleting our source EC2 instance as it’s no longer needed</li></ul><pre># Query Ubuntu 24.04 Latest AMI<br>aws ssm get-parameters --names \<br>   /aws/service/canonical/ubuntu/server/24.04/stable/current/amd64/hvm/ebs-gp3/ami-id<br><br># Launch EC2 Instance &amp; Bake Our Goods<br>aws ec2 run-instances \<br>  --image-id &quot;ami-09eb231ad55c3963d&quot; \<br>  --count &quot;1&quot; \<br>  --instance-type &quot;t2.micro&quot; \<br>  --key-name &quot;AcmeLabs-WEB-KP&quot; \<br>  --subnet-id &quot;subnet-0c112f381394f54d9&quot; \<br>  --associate-public-ip-address \<br>  --security-group-ids &quot;sg-0be64343db85129e6&quot; \<br>  --user-data &#39;#!/bin/bash<br>              export BUCKET_NAME=&quot;acmelabs-web-2025&quot;<br>              export EFS_FS_ID=&quot;fs-0493f75b9bc987268&quot;<br>              apt-get update<br>              apt-get install -y unzip<br>              curl &quot;https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip&quot; -o &quot;/tmp/awscliv2.zip&quot;<br>              unzip /tmp/awscliv2.zip -d /tmp<br>              /tmp/aws/install<br>              rm -rf /tmp/aws /tmp/awscliv2.zip<br>              if aws s3 cp s3://&quot;$BUCKET_NAME&quot;/scripts/user-data.sh /tmp/user-data.sh; then<br>                  chmod +x /tmp/user-data.sh<br>                  bash /tmp/user-data.sh<br>              else<br>                  echo &quot;Failed to download user-data.sh from S3 bucket: &#39;&quot;$BUCKET_NAME&quot;&#39;. Exiting.&quot;<br>                  exit 1<br>              fi&#39; \<br>  --tag-specifications &quot;ResourceType=instance,Tags=[{Key=Name,Value=AcmeLabs-WEB-SRC}]&quot; \<br>  --iam-instance-profile Name=&quot;AcmeLabsWEBEC2S3AccessProfile&quot; \<br>  --metadata-options &quot;HttpTokens=required,HttpEndpoint=enabled&quot; \<br>  --query &#39;Instances[0].InstanceId&#39; \<br>  --output text<br><br># Query EC2 Instane Status<br>aws ec2 describe-instances \<br>  --instance-ids &quot;i-04dffcc34f586ffe6&quot; \<br>  --query &#39;Reservations[0].Instances[0].State.Name&#39; \<br>  --output text<br><br># Query EC2 Instante Health State<br>aws ec2 describe-instance-status \<br>  --instance-ids &quot;i-04dffcc34f586ffe6&quot; \<br>  --query &#39;InstanceStatuses[0].InstanceStatus.Status&#39; \<br>  --output text<br><br># Create AMI<br>aws ec2 create-image \<br>    --instance-id i-04dffcc34f586ffe6 \<br>    --name &quot;AcmeLabs-WEB-Ubuntu24-AMI&quot; \<br>    --no-reboot<br><br># Tag AMI<br>aws ec2 create-tags \<br>    --resources ami-06c4decc36f7ce21f \<br>    --tags Key=Name,Value=AcmeLabs-Ubuntu24-AMI<br><br># AMI Creation Status (Optional)<br>aws ec2 describe-images \<br>    --image-ids ami-06c4decc36f7ce21f \<br>    --query &#39;Images[0].State&#39; \<br>    --output text<br><br># Delete EC2 Instance Used As Our Source To Create Our AMI<br>aws ec2 terminate-instances \<br>    --instance-ids i-04dffcc34f586ffe6</pre><h4>Elastic Load Balancer (ELB)</h4><p>To evenly distribute traffic and increase are availability to our EC2 instances we’ll create an Application Load Balancer (ALB). If we lose an instance, the ALB will remove it and route traffic to healthy EC2 instances. We’ll create a health check to achieve this.</p><pre># Create ALB<br>aws elbv2 create-load-balancer \<br>    --name AcmeLabs-WEB-ALB \<br>    --subnets subnet-0c112f381394f54d9 \<br>    subnet-09e8d4b16b4f7dd2b \<br>    subnet-0441acfbd58d84c74 \<br>    --security-groups sg-053350f6ad17b7f3f \<br>    --tags Key=Name,Value=AcmeLabs-WEB-ALB<br><br># Create Target Group w/Health Check<br>aws elbv2 create-target-group \<br>    --name AcmeLabs-WEB-TG \<br>    --protocol HTTP \<br>    --port 80 \<br>    --vpc-id vpc-0868038970bd1ab9d \<br>    --health-check-protocol HTTP \<br>    --health-check-path /health \<br>    --health-check-interval-seconds 30 \<br>    --health-check-timeout-seconds 5 \<br>    --healthy-threshold-count 5 \<br>    --unhealthy-threshold-count 2 \<br>    --tags Key=Name,Value=AcmeLabs-WEB-TG<br><br># Create Listeners<br>aws elbv2 create-listener \<br>    --load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:047719623795:loadbalancer/app/AcmeLabs-WEB-ALB/14929f913954185d \<br>    --port 80 \<br>    --protocol HTTP \<br>    --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59</pre><h4>Auto Scaling Group (ASG) — Launch Template</h4><p>For our ASG to fill in the details of what we need for our EC2 instances, we’ll create a launch template.</p><pre># Create Launch Template <br>aws ec2 create-launch-template \<br>  --launch-template-name AcmeLabs-WEB-LT \<br>  --version-description &quot;Initial version&quot; \<br>  --launch-template-data &#39;{<br>    &quot;ImageId&quot;: &quot;ami-06c4decc36f7ce21f&quot;,<br>    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>    &quot;KeyName&quot;: &quot;AcmeLabs-WEB-KP&quot;,<br>    &quot;IamInstanceProfile&quot;: {<br>        &quot;Name&quot;: &quot;AcmeLabsWEBEC2S3AccessProfile&quot;<br>    },<br>    &quot;SecurityGroupIds&quot;: [&quot;sg-0be64343db85129e6&quot;],<br>    &quot;TagSpecifications&quot;: [<br>      {<br>        &quot;ResourceType&quot;: &quot;instance&quot;,<br>        &quot;Tags&quot;: [<br>          {<br>            &quot;Key&quot;: &quot;Name&quot;,<br>            &quot;Value&quot;: &quot;AcmeLabs-WEB&quot;<br>          }<br>        ]<br>      }<br>    ]<br>  }&#39;</pre><h4>Auto Scaling Group (ASG)</h4><p>Here’s our ASG thats referencing our launch template. Here we can tell our ASG what we need for resources and which subnets they should be launched in.</p><pre># Create ASG<br>aws autoscaling create-auto-scaling-group \<br>  --auto-scaling-group-name AcmeLabs-WEB-ASG \<br>  --launch-template &quot;LaunchTemplateName=AcmeLabs-WEB-LT,Version=1&quot; \<br>  --min-size 3 \<br>  --max-size 6 \<br>  --vpc-zone-identifier &quot;subnet-0c112f381394f54d9,subnet-09e8d4b16b4f7dd2b,subnet-0441acfbd58d84c74&quot; \<br>  --target-group-arns &quot;arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59&quot;</pre><h4>Auto Scaling Group (ASG) — Target Tracking Policy</h4><p>To track if we need to scale out or scale in, we’ll create a <strong>Target Tracking Policy.</strong> If the ASG goes above AVG CPU of 50%, scale out to our maximum size if needed and when we drop below 50% then we’ll scale in to our minimum size.</p><pre># Create Target Tracking Policy<br>aws autoscaling put-scaling-policy --auto-scaling-group-name AcmeLabs-WEB-ASG --policy-name ScaleUp --policy-type TargetTrackingScaling --target-tracking-configuration &#39;{<br>    &quot;PredefinedMetricSpecification&quot;: {<br>        &quot;PredefinedMetricType&quot;: &quot;ASGAverageCPUUtilization&quot;<br>    },<br>    &quot;TargetValue&quot;: 50.0,<br>    &quot;DisableScaleIn&quot;: false<br>}&#39;</pre><h4>Route53 (Optional)</h4><p>I like clean URLs, it’s a me thing. You don’t have register a domain and setup a zone. Feel free to use the ALB DNS name to test. If you want to have fun with this, please take the time to review registering a domain, creating a zone and creating DNS records. <a href="https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/GettingStarted.html">Amazon Route 53 Getting Started</a></p><p>My zone was already created so I’m going to skip to the <strong><em>Retrieve ZoneId</em></strong> step.</p><p>If you choose to do this, it comes at cost for the domain based on the TLD you pick and having a hosted zone. The hosted zone per month is around $.50 cents a month at the time of this article.</p><pre># Register a Domain with Route53<br>aws route53domains register-domain \<br>    --domain-name acmelabs.cloud \<br>    --duration-in-years 1 \<br>    --admin-contact &quot;FirstName=Acme,LastName=Admin,ContactType=PERSON,Email=acmeadmin@acmelabs.cloud,PhoneNumber=+12065551234,AddressLine1=123 Cloud Way,City=Cloudy,State=AZ,CountryCode=US,ZipCode=85224&quot; \<br>    --registrant-contact &quot;FirstName=Acme,LastName=Admin,ContactType=PERSON,Email=acmeadmin@acmelabs.cloud,PhoneNumber=+12065551234,AddressLine1=123 Cloud Way,City=Cloudy,State=AZ,CountryCode=US,ZipCode=85224&quot; \<br>    --tech-contact &quot;FirstName=Acme,LastName=Admin,ContactType=PERSON,Email=acmeadmin@acmelabs.cloud,PhoneNumber=+12065551234,AddressLine1=123 Cloud Way,City=Cloudy,State=AZ,CountryCode=US,ZipCode=85224&quot; \<br>    --privacy-protect-admin-contact \<br>    --privacy-protect-registrant-contact \<br>    --privacy-protect-tech-contact<br><br># Create Zone<br>aws route53 create-hosted-zone \<br>    --name acmelabs.cloud \<br>    --caller-reference &quot;$(date +%s)&quot; \<br>    --hosted-zone-config Comment=&quot;Hosted zone for acmelabs.cloud&quot;,PrivateZone=false \<br>    --tags Key=Name,Value=AcmeCloud<br><br># Retrieve ZoneId<br>aws route53 list-hosted-zones \<br>    --query &quot;HostedZones[?Name==&#39;acmelabs.cloud.&#39;].[Id]&quot; \<br>    --output text<br><br># Create DNS Records<br>aws route53 change-resource-record-sets \<br>  --hosted-zone-id Z087608618II6FJ5B93HU \<br>  --change-batch &#39;{<br>    &quot;Changes&quot;: [<br>      {<br>        &quot;Action&quot;: &quot;CREATE&quot;,<br>        &quot;ResourceRecordSet&quot;: {<br>          &quot;Name&quot;: &quot;acmelabs.cloud&quot;,<br>          &quot;Type&quot;: &quot;A&quot;,<br>          &quot;AliasTarget&quot;: {<br>            &quot;HostedZoneId&quot;: &quot;Z35SXDOTRQ7X7K&quot;,<br>            &quot;DNSName&quot;: &quot;AcmeLabs-WEB-ALB-525810016.us-east-1.elb.amazonaws.com&quot;,<br>            &quot;EvaluateTargetHealth&quot;: false<br>          }<br>        }<br>      },<br>      {<br>        &quot;Action&quot;: &quot;CREATE&quot;,<br>        &quot;ResourceRecordSet&quot;: {<br>          &quot;Name&quot;: &quot;www.acmelabs.cloud&quot;,<br>          &quot;Type&quot;: &quot;CNAME&quot;,<br>          &quot;TTL&quot;: 300,<br>          &quot;ResourceRecords&quot;: [<br>            {<br>              &quot;Value&quot;: &quot;AcmeLabs-WEB-ALB-525810016.us-east-1.elb.amazonaws.com&quot;<br>            }<br>          ]<br>        }<br>      }<br>    ]<br>  }&#39;</pre><h4>Transport Layer Security (TLS) (Optional)</h4><p>To add a bit more security we can adjust our work to use a certificate issued by AWS to secure our inflight connections to our EC2 instances.<br><strong>Note:</strong> These changes can take minutes to hours. If you zone is setup wrong and you delete it then recreate it, there is the possiblity it may take 48 hours to work. If that happens, test with the ALB DNS URL.</p><pre># Create Certificate<br>aws acm request-certificate \<br>    --domain-name acmelabs.cloud \<br>    --validation-method DNS \<br>    --subject-alternative-names www.acmelabs.cloud<br><br># Get Status<br># ValidationStatus = Success before moving on<br>aws acm describe-certificate \<br>    --certificate-arn arn:aws:acm:us-east-1:047719623795:certificate/89f90795-1831-4b68-97a1-7043eec28c13<br><br># Create HTTPS Listeners on our ALB<br>aws elbv2 create-listener \<br>    --load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:047719623795:loadbalancer/app/AcmeLabs-WEB-ALB/14929f913954185d \<br>    --port 443 \<br>    --protocol HTTPS \<br>    --default-actions Type=forward,TargetGroupArn=arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59 \<br>    --certificates CertificateArn=arn:aws:acm:us-east-1:047719623795:certificate/89f90795-1831-4b68-97a1-7043eec28c13<br><br># Allow HTTPS traffic<br>aws ec2 authorize-security-group-ingress \<br>    --group-id sg-053350f6ad17b7f3f \<br>    --protocol tcp \<br>    --port 443 \<br>    --cidr 0.0.0.0/0<br><br># Get AcmeLabs-WEB-ALB HTTP Listener ARN<br># Look for the HTTP ARN<br>aws elbv2 describe-listeners \<br>    --load-balancer-arn arn:aws:elasticloadbalancing:us-east-1:047719623795:loadbalancer/app/AcmeLabs-WEB-ALB/14929f913954185d<br><br># Remove HTTP From AcmeLabs-WEB-ALB <br>aws elbv2 delete-listener \<br>    --listener-arn arn:aws:elasticloadbalancing:us-east-1:047719623795:listener/app/AcmeLabs-WEB-ALB/14929f913954185d/f599459d9d0a930a<br><br># Remove HTTP From AcmeLabs-WEB-ALB-SG<br>aws ec2 revoke-security-group-ingress \<br>    --group-id sg-0be64343db85129e6 \<br>    --protocol tcp \<br>    --port 80 \<br>    --source-group sg-053350f6ad17b7f3f</pre><pre># Create CNAME for acmecloud.com Validation<br>aws route53 change-resource-record-sets \<br>  --hosted-zone-id Z087608618II6FJ5B93HU \<br>  --change-batch &#39;{<br>    &quot;Changes&quot;: [<br>      {<br>        &quot;Action&quot;: &quot;CREATE&quot;,<br>        &quot;ResourceRecordSet&quot;: {<br>          &quot;Name&quot;: &quot;_edb26fc083581701d2095e9baad2dc80.acmelabs.cloud.&quot;,<br>          &quot;Type&quot;: &quot;CNAME&quot;,<br>          &quot;TTL&quot;: 300,<br>          &quot;ResourceRecords&quot;: [<br>            {<br>              &quot;Value&quot;: &quot;_e4533c7ad46b60ff55b80ecbfdf51746.xlfgrmvvlj.acm-validations.aws.&quot;<br>            }<br>          ]<br>        }<br>      }<br>    ]<br>  }&#39;<br><br># Create CNAME for www.acmecloud.com Validation<br>aws route53 change-resource-record-sets \<br>  --hosted-zone-id Z087608618II6FJ5B93HU \<br>  --change-batch &#39;{<br>    &quot;Changes&quot;: [<br>      {<br>        &quot;Action&quot;: &quot;CREATE&quot;,<br>        &quot;ResourceRecordSet&quot;: {<br>          &quot;Name&quot;: &quot;_8fd320bdffc18b7578c3739785ca0680.www.acmelabs.cloud.&quot;,<br>          &quot;Type&quot;: &quot;CNAME&quot;,<br>          &quot;TTL&quot;: 300,<br>          &quot;ResourceRecords&quot;: [<br>            {<br>              &quot;Value&quot;: &quot;_36b686ce647ce6c6a8cf38051c3f62fb.xlfgrmvvlj.acm-validations.aws.&quot;<br>            }<br>          ]<br>        }<br>      }<br>    ]<br>  }&#39;<br><br># This may take minutes to hours</pre><h4>Test</h4><p>If you registered a domain, please use that to test otherwise please use the ALB DNS . If all works we should see a page like this. Take note of the top right corner of the page. Refresh the page and you’ll bounce around three availability zones (AZ).</p><figure><img alt="US-EAST-1A" src="https://cdn-images-1.medium.com/max/1024/1*c_vUyJULPxZOFDEIq_umKA.jpeg" /><figcaption>US-EAST-1A</figcaption></figure><figure><img alt="US-EAST-1B" src="https://cdn-images-1.medium.com/max/1024/1*KvjnoNNIyjA-QsbiDK3ctQ.jpeg" /><figcaption>US-EAST-1B</figcaption></figure><figure><img alt="US-EAST-1C" src="https://cdn-images-1.medium.com/max/1024/1*tGbxDjd3YvUkxHili3HDZg.jpeg" /><figcaption>US-EAST-1C</figcaption></figure><h4>Stress Test</h4><p>Lets watch our ASG in action. We’ll do the following:</p><ul><li>Adjust our AcmeLabs-EC2-SG to accept inbound SSH from anywhere</li></ul><pre># Allow SSH traffic to Our EC2 Instances<br>aws ec2 authorize-security-group-ingress \<br>    --group-id sg-0be64343db85129e6 \<br>    --protocol tcp \<br>    --port 22 \<br>    --cidr 0.0.0.0/0</pre><ul><li>Create an elastic IP to assign to one of our EC2 instances</li></ul><pre># Get Elastic IP 1<br>aws ec2 allocate-address \<br>    --domain vpc<br><br># Get Elastic IP 2<br>aws ec2 allocate-address \<br>    --domain vpc<br><br># Get Elastic IP 3<br>aws ec2 allocate-address \<br>    --domain vpc<br><br># Associate Elastic IP to EC2 Instance 1<br>aws ec2 associate-address \<br>    --instance-id i-0a700cec15e1f3f56 \<br>    --allocation-id eipalloc-06324a683da7e015a<br><br># Associate Elastic IP to EC2 Instance 2<br>aws ec2 associate-address \<br>    --instance-id i-0e6e7c5da63b2cf2a \<br>    --allocation-id eipalloc-0238459015730e598<br><br># Associate Elastic IP to EC2 Instance 3<br>aws ec2 associate-address \<br>    --instance-id i-0d9441ff20c4e61fe \<br>    --allocation-id eipalloc-0d2f60238bf4aa60f</pre><ul><li>Shell Over to Our EC2 Instance(s)<br><strong>Note:</strong> Make sure your chmod + 400 our private key.</li></ul><pre># Shell Over To EC2 Instance 1<br>ssh -i ~/path/to/AcmeLabs-WEB-KP.pem ubuntu@&lt;IP&gt;<br><br># Shell Over To EC2 Instance 2<br>ssh -i ~/path/to/AcmeLabs-WEB-KP.pem ubuntu@&lt;IP&gt;<br><br># Shell Over To EC2 Instance 3<br>ssh -i ~/path/to/AcmeLabs-WEB-KP.pem ubuntu@&lt;IP&gt;</pre><ul><li>Install Stress Utility</li></ul><pre># Update Package List<br>sudo apt-get update<br><br># Install Stress Utility<br>sudo apt-get install -y stress</pre><ul><li>Stress Our EC2 Instance(s)</li></ul><pre># Stress Out (TTL is 5 minutes)<br>sudo stress --cpu 2000 --timeout 3600</pre><ul><li>Results ASG Scale Out</li></ul><figure><img alt="EC2 Instances Health (Stress Running)" src="https://cdn-images-1.medium.com/max/1024/1*T-D0kgsWFZPz1DDGlnZ4Ug.jpeg" /><figcaption>EC2 Instances Health (Stress Running)</figcaption></figure><figure><img alt="ASG Scaling Out" src="https://cdn-images-1.medium.com/max/1024/1*tY7y-q77W7zdmDhpb7cQ9A.jpeg" /><figcaption>ASG Scaling Out</figcaption></figure><pre># Check ASG Status<br>aws autoscaling describe-auto-scaling-groups \<br>    --auto-scaling-group-names AcmeLabs-WEB-ASG<br><br># ASG Output<br>{<br>    &quot;AutoScalingGroups&quot;: [<br>        {<br>            &quot;AutoScalingGroupName&quot;: &quot;AcmeLabs-WEB-ASG&quot;,<br>            &quot;AutoScalingGroupARN&quot;: &quot;arn:aws:autoscaling:us-east-1:047719623795:autoScalingGroup:cc9cc878-8f03-4602-a179-18f74a3b420a:autoScalingGroupName/AcmeLabs-WEB-ASG&quot;,<br>            &quot;LaunchTemplate&quot;: {<br>                &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                &quot;Version&quot;: &quot;1&quot;<br>            },<br>            &quot;MinSize&quot;: 3,<br>            &quot;MaxSize&quot;: 6,<br>            &quot;DesiredCapacity&quot;: 6,<br>            &quot;DefaultCooldown&quot;: 300,<br>            &quot;AvailabilityZones&quot;: [<br>                &quot;us-east-1a&quot;,<br>                &quot;us-east-1b&quot;,<br>                &quot;us-east-1c&quot;<br>            ],<br>            &quot;LoadBalancerNames&quot;: [],<br>            &quot;TargetGroupARNs&quot;: [<br>                &quot;arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59&quot;<br>            ],<br>            &quot;HealthCheckType&quot;: &quot;EC2&quot;,<br>            &quot;HealthCheckGracePeriod&quot;: 0,<br>            &quot;Instances&quot;: [<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-03aa83c9c1f22e645&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1b&quot;,<br>                    &quot;LifecycleState&quot;: &quot;InService&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                },<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-087a1a3cd1b59d1ee&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1c&quot;,<br>                    &quot;LifecycleState&quot;: &quot;InService&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                },<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-08b2c8e4ae6e8440c&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1a&quot;,<br>                    &quot;LifecycleState&quot;: &quot;InService&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                },<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-0a700cec15e1f3f56&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1a&quot;,<br>                    &quot;LifecycleState&quot;: &quot;InService&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                },<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-0d9441ff20c4e61fe&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1c&quot;,<br>                    &quot;LifecycleState&quot;: &quot;InService&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                },<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-0e6e7c5da63b2cf2a&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1b&quot;,<br>                    &quot;LifecycleState&quot;: &quot;InService&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                }<br>            ],<br>            &quot;CreatedTime&quot;: &quot;2025-04-12T00:11:56.612000+00:00&quot;,<br>            &quot;SuspendedProcesses&quot;: [],<br>            &quot;VPCZoneIdentifier&quot;: &quot;subnet-09e8d4b16b4f7dd2b,subnet-0441acfbd58d84c74,subnet-0c112f381394f54d9&quot;,<br>            &quot;EnabledMetrics&quot;: [],<br>            &quot;Tags&quot;: [],<br>            &quot;TerminationPolicies&quot;: [<br>                &quot;Default&quot;<br>            ],<br>            &quot;NewInstancesProtectedFromScaleIn&quot;: false,<br>            &quot;ServiceLinkedRoleARN&quot;: &quot;arn:aws:iam::047719623795:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling&quot;,<br>            &quot;TrafficSources&quot;: [<br>                {<br>                    &quot;Identifier&quot;: &quot;arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59&quot;,<br>                    &quot;Type&quot;: &quot;elbv2&quot;<br>                }<br>            ],<br>            &quot;AvailabilityZoneDistribution&quot;: {<br>                &quot;CapacityDistributionStrategy&quot;: &quot;balanced-best-effort&quot;<br>            },<br>            &quot;CapacityReservationSpecification&quot;: {<br>                &quot;CapacityReservationPreference&quot;: &quot;default&quot;<br>            }<br>        }<br>    ]<br>}</pre><figure><img alt="Target Group Now Has 6 EC2 Instances" src="https://cdn-images-1.medium.com/max/1024/1*NhdtImIIP3QZWqXcqyxqvA.jpeg" /><figcaption>Target Group Showing Maximum ASG EC2 Instances 6</figcaption></figure><pre># Check Target Group Status<br>aws elbv2 describe-target-health \<br>    --target-group-arn arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59<br><br># Targrt Group Output<br>{<br>    &quot;TargetHealthDescriptions&quot;: [<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-08b2c8e4ae6e8440c&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;healthy&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        },<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-087a1a3cd1b59d1ee&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;healthy&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        },<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-0d9441ff20c4e61fe&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;healthy&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        },<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-0a700cec15e1f3f56&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;healthy&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        },<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-0e6e7c5da63b2cf2a&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;healthy&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        },<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-03aa83c9c1f22e645&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;healthy&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        }<br>    ]<br>}</pre><ul><li>Results ASG Scale In</li></ul><pre># Check ASG Status<br>aws autoscaling describe-auto-scaling-groups \<br>    --auto-scaling-group-names AcmeLabs-WEB-ASG<br><br># ASG Output<br>{<br>    &quot;AutoScalingGroups&quot;: [<br>        {<br>            &quot;AutoScalingGroupName&quot;: &quot;AcmeLabs-WEB-ASG&quot;,<br>            &quot;AutoScalingGroupARN&quot;: &quot;arn:aws:autoscaling:us-east-1:047719623795:autoScalingGroup:cc9cc878-8f03-4602-a179-18f74a3b420a:autoScalingGroupName/AcmeLabs-WEB-ASG&quot;,<br>            &quot;LaunchTemplate&quot;: {<br>                &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                &quot;Version&quot;: &quot;1&quot;<br>            },<br>            &quot;MinSize&quot;: 3,<br>            &quot;MaxSize&quot;: 6,<br>            &quot;DesiredCapacity&quot;: 3,<br>            &quot;DefaultCooldown&quot;: 300,<br>            &quot;AvailabilityZones&quot;: [<br>                &quot;us-east-1a&quot;,<br>                &quot;us-east-1b&quot;,<br>                &quot;us-east-1c&quot;<br>            ],<br>            &quot;LoadBalancerNames&quot;: [],<br>            &quot;TargetGroupARNs&quot;: [<br>                &quot;arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59&quot;<br>            ],<br>            &quot;HealthCheckType&quot;: &quot;EC2&quot;,<br>            &quot;HealthCheckGracePeriod&quot;: 0,<br>            &quot;Instances&quot;: [<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-03aa83c9c1f22e645&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1b&quot;,<br>                    &quot;LifecycleState&quot;: &quot;InService&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                },<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-087a1a3cd1b59d1ee&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1c&quot;,<br>                    &quot;LifecycleState&quot;: &quot;InService&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                },<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-08b2c8e4ae6e8440c&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1a&quot;,<br>                    &quot;LifecycleState&quot;: &quot;InService&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                },<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-0d9441ff20c4e61fe&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1c&quot;,<br>                    &quot;LifecycleState&quot;: &quot;Terminating&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                },<br>                {<br>                    &quot;InstanceId&quot;: &quot;i-0e6e7c5da63b2cf2a&quot;,<br>                    &quot;InstanceType&quot;: &quot;t2.micro&quot;,<br>                    &quot;AvailabilityZone&quot;: &quot;us-east-1b&quot;,<br>                    &quot;LifecycleState&quot;: &quot;Terminating&quot;,<br>                    &quot;HealthStatus&quot;: &quot;Healthy&quot;,<br>                    &quot;LaunchTemplate&quot;: {<br>                        &quot;LaunchTemplateId&quot;: &quot;lt-0c3b4835a80925fe0&quot;,<br>                        &quot;LaunchTemplateName&quot;: &quot;AcmeLabs-WEB-LT&quot;,<br>                        &quot;Version&quot;: &quot;1&quot;<br>                    },<br>                    &quot;ProtectedFromScaleIn&quot;: false<br>                }<br>            ],<br>            &quot;CreatedTime&quot;: &quot;2025-04-12T00:11:56.612000+00:00&quot;,<br>            &quot;SuspendedProcesses&quot;: [],<br>            &quot;VPCZoneIdentifier&quot;: &quot;subnet-09e8d4b16b4f7dd2b,subnet-0441acfbd58d84c74,subnet-0c112f381394f54d9&quot;,<br>            &quot;EnabledMetrics&quot;: [],<br>            &quot;Tags&quot;: [],<br>            &quot;TerminationPolicies&quot;: [<br>                &quot;Default&quot;<br>            ],<br>            &quot;NewInstancesProtectedFromScaleIn&quot;: false,<br>            &quot;ServiceLinkedRoleARN&quot;: &quot;arn:aws:iam::047719623795:role/aws-service-role/autoscaling.amazonaws.com/AWSServiceRoleForAutoScaling&quot;,<br>            &quot;TrafficSources&quot;: [<br>                {<br>                    &quot;Identifier&quot;: &quot;arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59&quot;,<br>                    &quot;Type&quot;: &quot;elbv2&quot;<br>                }<br>            ],<br>            &quot;AvailabilityZoneDistribution&quot;: {<br>                &quot;CapacityDistributionStrategy&quot;: &quot;balanced-best-effort&quot;<br>            },<br>            &quot;CapacityReservationSpecification&quot;: {<br>                &quot;CapacityReservationPreference&quot;: &quot;default&quot;<br>            }<br>        }<br>    ]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bJ5SviO2tCky5H90i8_MXQ.jpeg" /><figcaption>EC2 Instances Health (Stress No Longer Running)</figcaption></figure><figure><img alt="ASG Scaling In" src="https://cdn-images-1.medium.com/max/1024/1*mEl63UabR9_kD0UT7bd37w.jpeg" /><figcaption>ASG Scaling In</figcaption></figure><pre># Check Target Group Status<br>aws elbv2 describe-target-health \<br>    --target-group-arn arn:aws:elasticloadbalancing:us-east-1:047719623795:targetgroup/AcmeLabs-WEB-TG/086f1097ab15af59<br><br># Targrt Group Output<br>{<br>    &quot;TargetHealthDescriptions&quot;: [<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-08b2c8e4ae6e8440c&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;healthy&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        },<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-087a1a3cd1b59d1ee&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;healthy&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        },<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-0e6e7c5da63b2cf2a&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;draining&quot;,<br>                &quot;Reason&quot;: &quot;Target.DeregistrationInProgress&quot;,<br>                &quot;Description&quot;: &quot;Target deregistration is in progress&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        },<br>        {<br>            &quot;Target&quot;: {<br>                &quot;Id&quot;: &quot;i-03aa83c9c1f22e645&quot;,<br>                &quot;Port&quot;: 80<br>            },<br>            &quot;HealthCheckPort&quot;: &quot;80&quot;,<br>            &quot;TargetHealth&quot;: {<br>                &quot;State&quot;: &quot;healthy&quot;<br>            },<br>            &quot;AdministrativeOverride&quot;: {<br>                &quot;State&quot;: &quot;no_override&quot;,<br>                &quot;Reason&quot;: &quot;AdministrativeOverride.NoOverride&quot;,<br>                &quot;Description&quot;: &quot;No override is currently active on target&quot;<br>            }<br>        }<br>    ]<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BxRTW2zXAB6eAlJZO6TlkA.jpeg" /><figcaption>Target Group Deregisting EC2 Instances</figcaption></figure><h4>Elastic File System (EFS) — Test</h4><p>While we still have SSH and Elastic IPs associated to our three EC2 instances.</p><ul><li>Shell Over to Our EC2 Instance(s)</li></ul><pre># Shell Over To EC2 Instance 1<br>ssh -i ~/path/to/AcmeLabs-WEB-KP.pem ubuntu@&lt;IP&gt;<br><br># Shell Over To EC2 Instance 2<br>ssh -i ~/path/to/AcmeLabs-WEB-KP.pem ubuntu@&lt;IP&gt;<br><br># Shell Over To EC2 Instance 3<br>ssh -i ~/path/to/AcmeLabs-WEB-KP.pem ubuntu@&lt;IP&gt;</pre><ul><li>Validate the EFS FS share is present /var/www/html/images</li></ul><figure><img alt="EFS FS Mounted To /var/www/html/images" src="https://cdn-images-1.medium.com/max/1024/1*rSXKW8jqpGeiNqcuy-P8Mw.jpeg" /><figcaption>EFS FS Mounted To /var/www/html/images</figcaption></figure><ul><li>List the /var/www/html/images</li></ul><figure><img alt="Listing Shows Files" src="https://cdn-images-1.medium.com/max/1024/1*6bC0NXJsuoK222cepsn5XA.jpeg" /><figcaption>Listing Shows Files</figcaption></figure><ul><li>Create a file on one instance then list in the other two to validate it shows up</li></ul><figure><img alt="File Created on 1 EC2 Instance — Appears when listing on the other instances." src="https://cdn-images-1.medium.com/max/1024/1*eg2cNSromE2lV7QXVLMVCw.jpeg" /><figcaption>File Created on 1 EC2 Instance — Appears when listing on the other instances.</figcaption></figure><h4>Conclusion</h4><p>We used AWS CLI to successfully create AcmeLabs infrastructure in AWS. AcmeLabs have moved from a single EC2 instance to a modern dynamic infrastructure that scales out or in depending on our ASG AVG CPU along with securing access through the ALB with TLS. We took advantage of S3 to help store some files that we could pull down into an EC2 instance that baked our goods. We create an AMI from the EC2 to be used with our ASG launch template. We used EFS to store our images for our website and to share with all EC2 instances. We saw the website successfully from more than one AZ. We stressed tested our first three EC2 instances to force the ASG to scale out when ASG AVG CPU went over 50%. Once CPU dipped below 50% we saw our ASG remove EC2 instances. Also note, our health check was still passing so none of the EC2 instances ever wen’t unhealthy, odd huh. I was able to break the commands to allow the EC2 instances to cool down and let the ASG remove the additional EC2 instances.</p><p>The joys I learned, there’s a lot more puzzle pieces to build out using the AWS CLI vs using the AWS Console which turned out to be frustrating at times though rewarding when moving through obstacles.</p><p>Stay hungry, stay curious, keep learning. You too can cloud.</p><p><a href="https://medium.com/u/331e9964766c">LaSherr&#39;e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara Hibben</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a> <a href="https://medium.com/u/efc3aac42050">Tait Hoglund</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bbfb12aca9ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS EC2: Deploy an Apache Web Server via AWS CLI]]></title>
            <link>https://medium.com/@carrickbradley/aws-ec2-deploy-an-apache-web-server-via-aws-cli-6e2cde2bdd35?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/6e2cde2bdd35</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-devops-engineer]]></category>
            <category><![CDATA[bash]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[aws-cli]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Sun, 30 Mar 2025 21:51:54 GMT</pubDate>
            <atom:updated>2025-03-31T16:51:46.473Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*FtdKAphIy4LWz8-hof_6Tg.jpeg" /><figcaption>Image generated with DeepAI</figcaption></figure><p>We’re going dive right into the deep end with the AWS CLI. We already have experience with launching an <a href="https://medium.com/@carrickbradley/amazon-ec2-deploy-an-apache-web-server-on-ubuntu-24-04-lts-e5242632a491">EC2 instance with some user-data to launch a web server via the AWS Consol</a>e. Today, we’ll do the same however, we’ll do this programmatically using the AWS CLI and for a bonus, we’ll create our own AMI from our deployed EC2 instance along with deploying that instance via AWS CLI.</p><p>This article will demonstrate how to use the AWS CLI to deploy an EC2 instance that includes the user-data, key-pair creation and security group. The user-data will update the operating system by installing the latest patches, install the Apache2 web server, and create an HTML webpage.</p><p>For an extra challenge, we’ll create two Bash scripts: the first being the main script and the other being the user-data script that we’ll reference.</p><h3>AWS CLI</h3><p>From Amazon directly, “The AWS Command Line Interface (AWS CLI) is a unified tool to manage your AWS services. With just one tool to download and configure, you can control multiple AWS services from the command line and automate them through scripts.”. In short, we get use a terminal emulator and write out commands or put them into scripts that we can then execute to orchestrate &amp; maintain our cloud infrastructure in AWS.</p><h3>Prerequisites</h3><ol><li>AWS Account</li><li><a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-install.html">AWS CLI Installed</a> &amp; <a href="https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html">Configured</a></li><li>Terminal Emulator</li><li>Bash 3.2.57 or newer</li></ol><h3>Code</h3><p>Below is the code used in each bash script, <strong><em>AWS CLI DEMO</em></strong> &amp; <strong><em>User-Data</em></strong> scripts.</p><p><strong>AWS CLI Demo </strong>script does the following (aws_cli_demo.sh):</p><ul><li>Queries Public AMI images to retrieve the latest AMI ID for Ubuntu Server AMD64 X86_64 Architecture</li><li>Creates a Key-Pair</li><li>Creates a Security-Group with inbound SSH &amp; HTTP rules</li><li>Creates an EC2 instance calling the user-data script</li></ul><pre>#!/bin/bash<br># ---------------------------------------------------------------------------------------<br># Title: AWS CLI Demo Script<br># Date: 2025-03-28<br># Version: 1.0<br># Written By: Carrick Bradley<br># Tested on: MacOS 15.3.2<br># ---------------------------------------------------------------------------------------<br># Description: This script performs the following tasks:<br># - Queries AMI images to retrieve the AMI ID for the latest Ubuntu Server AMD64 X86_64<br># - Creates a Key-Pair<br># - Creates a Security Group with inbound SSH and HTTP rules<br># - Creates an EC2 Instance with a user data script that installs and configures Apache2<br>#<br># Usage: ./aws_cli_demo.sh [local_log_file_path] [key_pair_name] [security_group_name] [user_data_script_path] <br>#<br># Requirements: You do not need to pass the four arguments as listed in the usage,<br>#               however, if you would like the name to differ from the defauilts listed<br>#               in the &quot;Define parameters for EC2 creation&quot;.<br>#               <br>#               This script requires root privileges to run and will run on MacOS 15.3.2,<br>#               user data script will run on: Ubuntu 22.04 LTS (Jammmy Jellyfish) &amp;<br>#               24.04 (Noble Numbat) and other Debian-based systems.<br>#               It may not work as expected on other systems.<br># ---------------------------------------------------------------------------------------<br><br># Exit on error, uninitialized variable, or failed command in a pipeline<br>set -euo pipefail<br><br># Define exit codes<br>SUCCESS=0<br>ERROR=1<br><br># Define the log file variable with a timestamp or use provided path<br>LOGFILE=&quot;${1:-$(dirname &quot;$0&quot;)/aws-cli-$(date &#39;+%Y%m%d_%H%M%S&#39;).log}&quot;<br><br># Define parameters for EC2 creation<br>INSTANCE_COUNT=1<br>INSTANCE_TYPE=&quot;t2.micro&quot;<br>INSTANCE_TAG_NAME=&quot;AWSCLIDEMO&quot;<br>KEY_PAIR_NAME=&quot;${2:-AWSCLIDEMO-KP}&quot;<br>SECURITY_GROUP_NAME=&quot;${3:-AWSCLIDEMO-SSH-HTTP-SG}&quot;<br>USER_DATA_SCRIPT=&quot;${4:-user-data.sh}&quot;<br><br># Function to log messages with a default log level of INFO<br>log_capture() {<br>    local message=&quot;$1&quot;<br>    local level=&quot;${2:-INFO}&quot;<br>    local timestamp<br>    timestamp=$(date &#39;+%Y-%m-%d %H:%M:%S&#39;)<br>    <br>    echo &quot;$timestamp - [$level] - $message&quot; | tee -a &quot;$LOGFILE&quot;<br>    logger -t aws-cli &quot;$message&quot;<br>}<br><br># Function to initialize logging<br>initialize_logging() {<br>    log_capture &quot;Initializing logging to &#39;$LOGFILE&#39;...&quot;<br>    <br>    if [ ! -f &quot;$LOGFILE&quot; ]; then<br>        touch &quot;$LOGFILE&quot;<br>        log_capture &quot;Log file &#39;$LOGFILE&#39; created.&quot;<br>    else<br>        log_capture &quot;Log file &#39;$LOGFILE&#39; already exists...appending to it.&quot;<br>    fi<br><br>    exec &gt; &gt;(tee -a &quot;$LOGFILE&quot;) 2&gt;&amp;1<br>    log_capture &quot;Logging initialized.&quot;<br>    log_capture &quot;Starting EC2 user data script...&quot;<br>}<br><br># Function to check if AWS CLI is installed<br>aws_cli_installed() {<br>    log_capture &quot;Checking if AWS CLI is installed...&quot;<br>    if ! command -v aws &amp;&gt; /dev/null; then<br>        log_capture &quot;Error: AWS CLI is not installed. Please install it and configure it.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;AWS CLI is installed.&quot;<br>}<br><br># Function to query AMI images to retrieve the AMI ID for the latest Ubuntu Server AMD64 X86_64 architecture<br>query_ami(){<br>    log_capture &quot;Querying AMI images for the latest Ubuntu Server AMD64 X86_64 architecture...&quot;<br>    <br>    # Query for the latest public Ubuntu AMI<br>    AMI_ID=$(aws ec2 describe-images \<br>        --owners &quot;099720109477&quot; \<br>        --filters &quot;Name=architecture,Values=x86_64&quot; &quot;Name=name,Values=ubuntu/images/hvm-ssd/ubuntu-*-server-*&quot; \<br>        --query &quot;Images | sort_by(@, &amp;CreationDate) | [-1].[ImageId]&quot; \<br>        --output text)<br>    <br>    if [ -z &quot;$AMI_ID&quot; ]; then<br>        log_capture &quot;Error: Failed to retrieve AMI ID.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;AMI ID queried successfully: $AMI_ID&quot;<br>}<br><br># Function to create a keypair<br>create_key_pair(){<br>    log_capture &quot;Creating KeyPair...&quot;<br>    if aws ec2 describe-key-pairs --key-names &quot;$KEY_PAIR_NAME&quot; &amp;&gt; /dev/null; then<br>        log_capture &quot;KeyPair &#39;$KEY_PAIR_NAME&#39; already exists. Skipping creation.&quot;<br>    else<br>        if [ -f &quot;$KEY_PAIR_NAME.pem&quot; ]; then<br>            log_capture &quot;Warning: KeyPair file &#39;$KEY_PAIR_NAME.pem&#39; already exists. It will be overwritten.&quot;<br>            rm &quot;$KEY_PAIR_NAME.pem&quot;<br>        fi<br>        if ! aws ec2 create-key-pair --key-name &quot;$KEY_PAIR_NAME&quot; --query &#39;KeyMaterial&#39; --output text &gt; &quot;$KEY_PAIR_NAME.pem&quot;; then<br>            log_capture &quot;Error: Failed to create KeyPair.&quot; &quot;ERROR&quot;<br>            exit $ERROR<br>        fi<br>        log_capture &quot;KeyPair created successfully.&quot;<br>    fi<br><br>    log_capture &quot;Setting permissions for KeyPair file...&quot;<br>    if ! chmod 400 &quot;$KEY_PAIR_NAME.pem&quot;; then<br>        log_capture &quot;Error: Failed to set permissions for KeyPair file.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Permissions set successfully.&quot;<br>}<br><br># Function to create a security group<br>create_security_group(){<br>    log_capture &quot;Creating Security Group...&quot;<br>    GROUP_ID=$(<br>        if aws ec2 describe-security-groups --group-names &quot;$SECURITY_GROUP_NAME&quot; &amp;&gt; /dev/null; then<br>            log_capture &quot;Security Group &#39;$SECURITY_GROUP_NAME&#39; already exists. Skipping creation.&quot;<br>            aws ec2 describe-security-groups --group-names &quot;$SECURITY_GROUP_NAME&quot; --query &#39;SecurityGroups[0].GroupId&#39; --output text<br>        else<br>            aws ec2 create-security-group --group-name &quot;$SECURITY_GROUP_NAME&quot; --description &quot;Security group allowing inbound SSH &amp; HTTP traffic.&quot; --query &#39;GroupId&#39; --output text<br>        fi<br>    )<br>    <br>    if [ -z &quot;$GROUP_ID&quot; ]; then<br>        log_capture &quot;Error: Failed to create Security Group.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Security Group created successfully with ID: $GROUP_ID.&quot;<br><br>    log_capture &quot;Creating Name tag for Security Group $GROUP_ID...&quot;<br>    if ! aws ec2 create-tags --resources &quot;$GROUP_ID&quot; --tags Key=Name,Value=&quot;$SECURITY_GROUP_NAME&quot;; then<br>        log_capture &quot;Error: Failed to create tags for Security Group $GROUP_ID.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Tags created successfully.&quot;<br><br>    log_capture &quot;Creating inbound SSH rule...&quot;<br>    if ! aws ec2 authorize-security-group-ingress --group-id &quot;$GROUP_ID&quot; --protocol tcp --port 22 --cidr 0.0.0.0/0; then<br>        log_capture &quot;Error: Failed to create inbound SSH rule.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Inbound SSH rule created successfully.&quot;<br><br>    log_capture &quot;Creating inbound HTTP rule...&quot;<br>    if ! aws ec2 authorize-security-group-ingress --group-id &quot;$GROUP_ID&quot; --protocol tcp --port 80 --cidr 0.0.0.0/0; then<br>        log_capture &quot;Error: Failed to create inbound HTTP rule.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Inbound HTTP rule created successfully.&quot;<br>}<br><br># Create the EC2 Instance<br>create_ec2_instance(){<br>    log_capture &quot;Creating EC2 Instance...&quot;<br><br>    # Check if the user data script exists<br>    log_capture &quot;Checking if user data script exists...&quot;<br>    if [ ! -f &quot;$USER_DATA_SCRIPT&quot; ]; then<br>        log_capture &quot;Error: User data script &#39;$USER_DATA_SCRIPT&#39; not found.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;User data script found.&quot;<br><br>    if ! aws ec2 run-instances \<br>        --image-id &quot;$AMI_ID&quot; \<br>        --count &quot;$INSTANCE_COUNT&quot; \<br>        --instance-type &quot;$INSTANCE_TYPE&quot; \<br>        --key-name &quot;$KEY_PAIR_NAME&quot; \<br>        --security-group-ids &quot;$GROUP_ID&quot; \<br>        --user-data file://&quot;$USER_DATA_SCRIPT&quot; \<br>        --tag-specifications &quot;ResourceType=instance,Tags=[{Key=Name,Value=$INSTANCE_TAG_NAME}]&quot;; then<br>        log_capture &quot;Error: Failed to create EC2 Instance.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;EC2 Instance created successfully.&quot;<br>}<br><br># Main execution<br>initialize_logging<br>aws_cli_installed<br>query_ami<br>create_key_pair<br>create_security_group<br>create_ec2_instance<br><br># Log the completion of our script<br>log_capture &quot;AWS CLI Demo script completed successfully.&quot;<br>exit $SUCCESS</pre><p><strong>User-Data </strong>script does the following (user-data.sh)</p><ul><li>Update Operating System</li><li>Install Apache2 Web Server</li><li>Creates an HTML web page</li></ul><pre>#!/bin/bash<br># ---------------------------------------------------------------------------------------<br># Title: EC2 User Data Script<br># Date: 2025-03-28<br># Version: 1.0<br># Written By: Carrick Bradley<br># Tested on: Ubuntu 22.04 LTS (Jammy Jellyfish) &amp; Ubuntu 24.04 (Noble Numbat)<br># ---------------------------------------------------------------------------------------<br># Description: This script performs the following tasks:<br># - Updates and upgrades the operating system<br># - Installs Apache web server<br># - Configures Apache2 with a custom index.html file<br>#<br># Usage: ./user-data.sh [log_file_path]<br># Requirements: This script requires root privileges to run and will run on<br>#               Ubuntu 22.04 LTS (Jammy Jellyfish) &amp; Ubuntu 24.04 (Noble Numbat)<br>#               and other Debian-based systems.<br># ---------------------------------------------------------------------------------------<br><br># Exit on error, uninitialized variable, or failed command in a pipeline<br>set -euo pipefail<br><br># Define exit codes<br>SUCCESS=0<br>ERROR=1<br><br># Define the log file variable with a timestamp or use provided path<br>LOGFILE=&quot;${1:-/var/log/startup-script-$(date &#39;+%Y%m%d_%H%M%S&#39;).log}&quot;<br><br># Define a lock file variable<br>LOCKFILE=&quot;/var/run/user-data-script.lock&quot;<br><br># Function to log messages with a default log level of INFO<br>log_capture() {<br>    local message=&quot;$1&quot;<br>    local level=&quot;${2:-INFO}&quot;<br>    local timestamp<br>    timestamp=$(date &#39;+%Y-%m-%d %H:%M:%S&#39;)<br><br>    # Check if the message has already been logged<br>    if grep -qF &quot;$message&quot; &quot;$LOGFILE&quot;; then<br>        return  # Skip logging if the message is already in the log file<br>    fi<br><br>    echo &quot;$timestamp - [$level] - $message&quot; | tee -a &quot;$LOGFILE&quot;<br>    logger -t startup-script &quot;$message&quot;<br>}<br><br># Function to initialize logging<br>initialize_logging() {<br>    log_capture &quot;Initializing logging to &#39;$LOGFILE&#39;...&quot;<br>    <br>    # Create log file if it does not exist<br>    if [ ! -f &quot;$LOGFILE&quot; ]; then<br>        touch &quot;$LOGFILE&quot;<br>        log_capture &quot;Log file &#39;$LOGFILE&#39; created.&quot;<br>    else<br>        log_capture &quot;Log file &#39;$LOGFILE&#39; already exists...appending to it.&quot;<br>    fi<br><br>    exec &gt; &gt;(tee -a &quot;$LOGFILE&quot;) 2&gt;&amp;1<br>    log_capture &quot;Logging initialized.&quot;<br>    log_capture &quot;Starting EC2 user data script...&quot;<br>}<br><br># Function to check if the script is already running<br>check_running() {<br>    if [ -f &quot;$LOCKFILE&quot; ]; then<br>        log_capture &quot;User data script is already running. Exiting.&quot;<br>        exit $SUCCESS<br>    fi<br>    touch &quot;$LOCKFILE&quot;<br>}<br><br># Function to update &amp; upgrade the operating system<br>update_and_upgrade_os() {<br>    log_capture &quot;Updating package list...&quot;<br>    if ! apt-get update -y; then<br>        log_capture &quot;Error: Failed to update package list.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Package list updated successfully.&quot;<br><br>    log_capture &quot;Upgrading installed packages...&quot;<br>    if ! apt-get upgrade -y; then<br>        log_capture &quot;Error: Failed to upgrade packages.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Packages upgraded successfully.&quot;<br><br>    log_capture &quot;Removing unnecessary packages...&quot;<br>    if ! apt-get autoremove -y; then<br>        log_capture &quot;Error: Failed to remove unnecessary packages.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Unnecessary packages removed successfully.&quot;<br><br>    log_capture &quot;Cleaning up package files...&quot;<br>    if ! apt-get autoclean -y; then<br>        log_capture &quot;Error: Failed to clean up package files.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Package files cleaned up successfully.&quot;<br>}<br><br># Function to install Apache web server<br>install_apache() {<br>    log_capture &quot;Installing Apache web server...&quot;<br>    if ! apt-get install -y apache2; then<br>        log_capture &quot;Error: Failed to install Apache web server.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Apache web server installed successfully.&quot;<br>}<br><br># Function to configure Apache2<br>configure_apache() {<br>    log_capture &quot;Configuring Apache web server...&quot;<br><br>    # Change to the default Apache2 directory and create index.html<br>    log_capture &quot;Creating index.html file...&quot;<br>    if ! cd /var/www/html; then<br>        log_capture &quot;Error: Failed to change directory to /var/www/html.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Changed directory to /var/www/html.&quot;<br><br>    log_capture &quot;Removing existing index.html file...&quot;<br>    # Remove existing index.html file if it exists<br>    # 2&gt;/dev/null suppresses error if the file does not exist<br>    if ! rm -f index.html; then<br>        log_capture &quot;Error: Failed to remove existing index.html file.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Existing index.html file removed successfully.&quot;<br><br>    log_capture &quot;Creating new index.html file...&quot;<br>    # Create a new index.html file with a welcome message<br>    cat &lt;&lt;EOF &gt; index.html<br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Welcome to LUIT&lt;/title&gt;<br>    &lt;style&gt;<br>        body {<br>            font-family: &#39;Arial&#39;, sans-serif;<br>            margin: 0;<br>            padding: 0;<br>            background: linear-gradient(135deg, #1a0f4b, #000000);<br>            color: #ffffff;<br>            display: flex;<br>            flex-direction: column;<br>            justify-content: center;<br>            align-items: center;<br>            height: 100vh;<br>            text-align: center;<br>            overflow: hidden;<br>        }<br>        h1 {<br>            font-size: 4em;<br>            color: #ff4081;<br>            animation: futuristicEffect 1.5s infinite alternate;<br>        }<br>        h2 {<br>            font-size: 3em;<br>            color: #39ff14;<br>            animation: futuristicEffect 1.5s infinite alternate;<br>        }<br>        @keyframes futuristicEffect {<br>            0% { transform: scale(1); }<br>            100% { transform: scale(1.05); }<br>        }<br>        .button {<br>            margin-top: 30px;<br>            padding: 15px 30px;<br>            font-size: 1.5em;<br>            color: #ffffff;<br>            background-color: #ff4081;<br>            border: none;<br>            border-radius: 5px;<br>            cursor: pointer;<br>            transition: background-color 0.3s;<br>        }<br>        .button:hover {<br>            background-color: #d5006d;<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;div&gt;<br>        &lt;h1&gt;Welcome to LUIT&lt;/h1&gt;<br>        &lt;h2&gt;Green Team - DevOps - February 2025&lt;/h2&gt;<br>        &lt;button class=&quot;button&quot; onclick=&quot;window.location.href=&#39;https://levelupintech.com&#39;&quot;&gt;Get Started&lt;/button&gt;<br>    &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>EOF<br><br>    log_capture &quot;index.html file created successfully.&quot;<br><br>    # Set permissions for the index.html file<br>    log_capture &quot;Setting permissions for index.html file...&quot;<br>    if ! chmod 644 index.html; then<br>        log_capture &quot;Error: Failed to set permissions for index.html.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Permissions set successfully.&quot;<br><br>    # Enable Apache2 service<br>    log_capture &quot;Enabling Apache2 service...&quot;<br>    if ! systemctl enable apache2; then<br>        log_capture &quot;Error: Failed to enable Apache2 service.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Apache2 service enabled successfully.&quot;<br><br>    # Start Apache2 service<br>    log_capture &quot;Starting Apache2 service...&quot;<br>    if ! systemctl start apache2; then<br>        log_capture &quot;Error: Failed to start Apache2 service.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Apache2 service started successfully.&quot;<br>    log_capture &quot;Apache web server configured successfully.&quot;<br>}<br><br># Main execution<br>initialize_logging<br>check_running<br>update_and_upgrade_os<br>install_apache<br>configure_apache<br><br># Log the completion of our script<br>log_capture &quot;Amazon EC2 user data script completed successfully!&quot;<br>exit $SUCCESS</pre><h3>Usage</h3><p>To use these scripts you must have Bash installed. I’m running on MacOS 15.3.2 using Bash 3.2.57(1)-release (arm64-apple-darwin24). If this doesn’t work on your system, first insure you’re running the latest version of bash as it should be equal to or be newer than 3.2.57.</p><h4>Make scripts executable</h4><pre>sudo chmod +x /path/to/aws_cli_demo.sh</pre><h4>Execute Script</h4><p>We can execute our script in one of two ways, with the defaults values or define them by passing what we want as arguments 1–4.</p><ul><li><strong>Default Values<br></strong>This is the simple option first you must insure the following:<br>- Place the user_data.sh script in the same directory as the aws_cli_demo.sh script<br>- Log output will be placed where the aws_cli_demo.sh script lives<br>- When the key-pair is genetated, the private key will be downloaded into the same directory where the aws_cli_demo.sh script lives<br>- If you ever ran this before successfully then deleted all the resources in AWS though didn’t delete the key-pair private key, expect to be prompted to override it to continue</li></ul><pre>bash /path/to/aws_cli_demo.sh</pre><ul><li><strong>Defining Arguments<br></strong>This option provides flexibility as you get to define the arguments that fit best for your needs.<br>- Argument 1 = local_log_file_path<br>- Argument 2 = KeyPair Name<br>- Argument 3 = Security GroupName<br>- Argument 4 = User Data Script Path</li></ul><pre>bash aws_cli_demo.sh [log_file_path] [key_pair_name] [security_group_name] [user_data_script_path]<br><br>Example:<br><br>bash aws_cli_demo.sh ~/aws_cli_demo.log AWSCLIDEMO-KP AWSCLIDEMO-SSH-HTTP-SG /path/to/user_data.sh</pre><h3>Test</h3><p>Now that we have successfully ran our script we need to test to ensure our EC2 instance is up &amp; running.</p><ul><li>Validate the EC2 instance is running</li><li>Take note of the the <strong><em>PublicIP</em></strong></li></ul><pre>aws ec2 describe-instances --filters &quot;Name=tag:Name,Values=AWSCLIDEMO&quot; &quot;Name=instance-state-name,Values=running&quot; --query &quot;Reservations[*].Instances[*].{InstanceID: InstanceId, InstanceState: State.Name, InstanceType: InstanceType, AZ: Placement.AvailabilityZone, PublicIP: PublicIpAddress, KeyName: KeyName, SecurityGroups: SecurityGroups[*].GroupName}&quot; --output json</pre><figure><img alt="EC2 Instance Info" src="https://cdn-images-1.medium.com/max/343/1*4Jt7hYwc-ktPgdOxsPSaLg.jpeg" /><figcaption>EC2 Instance Info</figcaption></figure><ul><li>Validate the EC2 instance status is ok/ok like in the AWS console</li></ul><pre>aws ec2 describe-instances --filters &quot;Name=tag:Name,Values=AWSCLIDEMO&quot; &quot;Name=instance-state-name,Values=running&quot; --query &quot;Reservations[*].Instances[*].InstanceId&quot; --output json | jq -r &#39;flatten | join(&quot;,&quot;)&#39; &amp;&amp; aws ec2 describe-instance-status --instance-ids $(aws ec2 describe-instances --filters &quot;Name=tag:Name,Values=AWSCLIDEMO&quot; &quot;Name=instance-state-name,Values=running&quot; --query &quot;Reservations[*].Instances[*].InstanceId&quot; --output json | jq -r &#39;flatten | join(&quot;,&quot;)&#39;) --query &quot;InstanceStatuses[*].{InstanceID: InstanceId, InstanceStatus: InstanceStatus.Status, SystemStatus: SystemStatus.Status}&quot; --output json</pre><figure><img alt="EC2 Instance Status" src="https://cdn-images-1.medium.com/max/316/1*2rdqvFP3YzfQN-fFP3DFrQ.jpeg" /><figcaption>EC2 Instance Status</figcaption></figure><ul><li>Validate the website is online by using the PublicIP retrieved earlier</li></ul><pre><a href="http://34.229.88.155/">http://34.229.88.155</a><br><br>This will differ for you, just make sure the URL looks like this in order to<br>open the site in your preferred browser.</pre><figure><img alt="Website Validation" src="https://cdn-images-1.medium.com/max/1024/1*GCl3IjE2fsEyqvB-cs5G0g.jpeg" /><figcaption>Website Validation</figcaption></figure><h4><strong>Secure Shell (SSH)</strong></h4><p>Use the command below, though adjust the path to where the key-pair file is located and attempt to login.</p><pre>ssh -i /path/to/AWSCLIDEMO-KP ubuntu@34.229.88.155</pre><figure><img alt="Successfully Shelled In" src="https://cdn-images-1.medium.com/max/735/1*jxhWlSTZZwiCywvfQv9SrA.jpeg" /><figcaption>Successfully Shelled In</figcaption></figure><h3>Amazon Machine Image (AMI)</h3><p>Now that we have an EC2 instance, let’s create an AMI.</p><ul><li><strong>Get InstanceID<br></strong>We need to get the <strong>InstanceID</strong> from our EC2 instance named <strong>AWSCLIDEMO</strong>.</li></ul><pre>aws ec2 describe-instances --filters &quot;Name=tag:Name,Values=AWSCLIDEMO&quot; &quot;Name=instance-state-name,Values=running&quot; --query &quot;Reservations[*].Instances[*].{InstanceID: InstanceId, InstanceState: State.Name, InstanceType: InstanceType, AZ: Placement.AvailabilityZone, PublicIP: PublicIpAddress, KeyName: KeyName, SecurityGroups: SecurityGroups[*].GroupName}&quot; --output json</pre><figure><img alt="EC2 Instance Info" src="https://cdn-images-1.medium.com/max/343/1*4Jt7hYwc-ktPgdOxsPSaLg.jpeg" /><figcaption>EC2 Instance Info</figcaption></figure><ul><li><strong>Create AMI<br></strong>Let’s create our AMI by replacing <strong><em>&lt;instance-id&gt;</em></strong> with the <strong>InstanceID</strong> retrieved in the prior step<strong> </strong>and <strong><em>“&lt;image-name&gt;”</em></strong> with the name you want for the image. This command will output the <strong>ImageId</strong>, take note as we’ll use this in the next step.</li></ul><pre>aws ec2 create-image --instance-id &lt;instance-id&gt; --name &quot;&lt;image-name&gt;&quot; --no-reboot<br><br>Example:<br><br>aws ec2 create-image --instance-id i-0bfc4da15a3662c45 --name &quot;AWSCLIDEMO-AMI&quot; --no-reboot</pre><figure><img alt="ImageID Output" src="https://cdn-images-1.medium.com/max/277/1*R5t6t75fR_pUoHnZxPdY6w.jpeg" /><figcaption>ImageID Output</figcaption></figure><ul><li><strong>AMI Status<br></strong>Using the <strong>ImageID</strong> from the prior command, we can see the status of the AMI being created. We’re looking for the Name &amp; State. Since the EC2 instance is running, depending on your EBS volume(s) size, this may take awhile to create the AMI.<br>- <strong>Pending</strong> — The AMI is being created. This state indicates that the image is in the process of being generated and is not yet available for use.<br>- <strong>Available</strong> — The AMI has been successfully created and is available for launching new instances. You can use this AMI to start new EC2 instances.<br>- <strong>Failed</strong> — The AMI creation process has failed. This state indicates that there was an error during the image creation process. You can check the error message for details.<br>- <strong>Deregistered</strong> — The AMI has been deregistered and is no longer available for launching new instances. However, the underlying snapshot may still exist unless explicitly deleted.</li></ul><pre>aws ec2 describe-images --image-ids &lt;image-id&gt;<br><br>Example:<br><br>aws ec2 describe-images --image-ids ami-05a90563f54f1e0b4</pre><figure><img alt="AMI Status" src="https://cdn-images-1.medium.com/max/453/1*heWQqRtTpZXr-f7xufxMAA.jpeg" /><figcaption>AMI Status</figcaption></figure><h3><strong>Create EC2 Instance From our AMI</strong></h3><p>Once the AMI state is <strong><em>available</em></strong>, we need to get the following: <strong>KeyPair</strong> &amp; <strong>SecurityGroup</strong> names from our <strong>AWSCLIDEMO</strong> EC2 instance.</p><pre>aws ec2 describe-instances --filters &quot;Name=tag:Name,Values=AWSCLIDEMO&quot; &quot;Name=instance-state-name,Values=running&quot; --query &quot;Reservations[*].Instances[*].{InstanceID: InstanceId, InstanceState: State.Name, InstanceType: InstanceType, AZ: Placement.AvailabilityZone, PublicIP: PublicIpAddress, KeyName: KeyName, SecurityGroups: SecurityGroups[*].GroupName}&quot; --output json</pre><figure><img alt="EC2 Instance Info" src="https://cdn-images-1.medium.com/max/343/1*4Jt7hYwc-ktPgdOxsPSaLg.jpeg" /><figcaption>EC2 Instance Info</figcaption></figure><p>We use the <strong>KeyName</strong> and <strong>SecurityGroups</strong> names in our command below to launch a new EC2 instance. This command will output a lot of data, take note of the <strong>InstanceID</strong>.</p><pre>aws ec2 run-instances --image-id ami-05a90563f54f1e0b4 --count 1 --instance-type t2.micro --key-name AWSCLIDEMO-KP --security-groups AWSCLIDEMO-SSH-HTTP-SG</pre><figure><img alt="EC2 Instance Info &amp; State" src="https://cdn-images-1.medium.com/max/378/1*l3bwcL-rsyoW2DP97OS8bg.jpeg" /><figcaption>EC2 Instance Info &amp; State</figcaption></figure><p>We can use the <strong>InstanceID</strong> to check on the status of our EC2 instance. We want to see our new instance in a running state. Take note of the <strong>PublicIP</strong> for use in testing.</p><pre>aws ec2 describe-instances --instance-ids i-0130528823f9a56a4 --query &quot;Reservations[*].Instances[*].{InstanceID: InstanceId, InstanceState: State.Name, InstanceType: InstanceType, AZ: Placement.AvailabilityZone, PublicIP: PublicIpAddress, KeyName: KeyName, SecurityGroups: SecurityGroups[*].GroupName}&quot; --output json</pre><figure><img alt="EC2 Instance Info &amp; State" src="https://cdn-images-1.medium.com/max/344/1*oai1-sE6XsoLlkK2RaVVJw.jpeg" /><figcaption>EC2 Instance Info &amp; State</figcaption></figure><p>We want to want to make sure our EC2 instance status is ok/ok as we would in the AWS Console. Use the <strong>InstanceId</strong> from the prior command.</p><pre>aws ec2 describe-instances --instance-ids i-0130528823f9a56a4 --query &quot;Reservations[*].Instances[*].InstanceId&quot; --output json | jq -r &#39;flatten | join(&quot;,&quot;)&#39; &amp;&amp; aws ec2 describe-instance-status --instance-ids i-0130528823f9a56a4 --query &quot;InstanceStatuses[*].{InstanceID: InstanceId, InstanceStatus: InstanceStatus.Status, SystemStatus: SystemStatus.Status}&quot; --output json</pre><figure><img alt="EC2 Instance Status ok/ok" src="https://cdn-images-1.medium.com/max/313/1*ZaOFtzLIDVFsG_8QNdT9tg.jpeg" /><figcaption>EC2 Instance Status ok/ok</figcaption></figure><h3>Test</h3><p>Now that we have successfully created an EC2 instance from the AWS CLI, we need to test to ensure our EC2 instance is up &amp; running.</p><ol><li>Validate the website is online by going to http://<a href="http://54.226.206.220/">http://54.226.206.220/</a></li></ol><figure><img alt="Website Validation" src="https://cdn-images-1.medium.com/max/1024/1*dylB94SuhkM-qmLe_b2Wug.jpeg" /><figcaption>Website Validation</figcaption></figure><h4><strong>Secure Shell (SSH)</strong></h4><p>Use the command below though adjust the path to our key-pair file and attempt to login.</p><pre>ssh -i /path/to/AWSCLIDEMO-KP ubuntu@54.226.206.220</pre><figure><img alt="Successfully Shelled In" src="https://cdn-images-1.medium.com/max/738/1*tqn9R_ODdwSns_ahXhIpfQ.jpeg" /><figcaption>Successfully Shelled In</figcaption></figure><h3>Conclusion</h3><p>We have successfully launched an Ubuntu EC2 instance using the AWS CLI by using two Bash shell scripts the first one aws_cli_demo.sh reference&#39;s user-data.sh script to create our EC2 instance. Lastly, we created an AMI and launched an EC2 instance based on the new AMI all from the AWS CLI.</p><p><a href="https://medium.com/u/331e9964766c">LaSherr&#39;e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a> <a href="https://medium.com/u/efc3aac42050">Tait Hoglund</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6e2cde2bdd35" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Linux Basics: Users, Groups & Permissions (Updated Script)]]></title>
            <link>https://medium.com/@carrickbradley/linux-basics-users-groups-permissions-bb192f123e00?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/bb192f123e00</guid>
            <category><![CDATA[aws]]></category>
            <category><![CDATA[cloud-devops]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[cloud-devops-engineer]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Fri, 07 Mar 2025 00:30:12 GMT</pubDate>
            <atom:updated>2025-03-28T23:20:41.590Z</atom:updated>
            <content:encoded><![CDATA[<p>We’ve launched a few Linux Amazon EC2 instances. Let’s have a little look at a few Linux basics for administering users &amp; groups and setting permissions. We’ll add this all to a script to automate this process on an EC2 instance running Ubuntu 24.04 LTS.</p><figure><img alt="Image background generated with DeepAI" src="https://cdn-images-1.medium.com/max/640/1*Dhdnoxe7bFedejfulWya0A.png" /><figcaption>Image background generated with DeepAI</figcaption></figure><h3>What To Expect</h3><ol><li>Review of Linux Basics</li><li>Launch &amp; login into the AWS Console</li><li>Navigate to the Amazon EC2 service</li><li>Launch an instance using Ubuntu 24.04 LTS</li><li>Configure the EC2 instance with user data:<br>- Create Users<br>- Create Groups<br>- Set Permissions</li><li>Shell over to the instance using Secure Shell (SSH)</li><li>Lastly, we’ll test, I can’t stress this enough</li></ol><h3>Prerequisites</h3><ol><li>AWS Account</li><li>Terminal to Secure Shell (SSH)</li><li>Basic Linux experience (Don’t worry if your new, just follow as best you can.)</li></ol><h3>Lets Get Started</h3><h4>Linux Basics</h4><p>We’re going to need to recall a bunch of commands to create our script. Remember that scripting is just taking our commands we type on the command line interface (CLI) and putting them into a server-side scripting language, in our case, BASH. Don’t worry about trying to memorize all of these commands at once. The goal is to build upon, progress not perfection.</p><ul><li><strong><em>cd</em></strong> = change directory, we’ll use this to move around the file system</li><li><strong><em>ls</em></strong> = list, we’ll use this along with options to list directory contents</li><li><strong><em>sudo</em></strong> = superuser do (Elevates your privileges to run commands.)</li><li><strong><em>mkdir</em></strong> = makes a new directory e.g. <strong><em>mkdir /path_to/directory</em></strong><br>Command Options:<br><strong><em>-p</em></strong> = makes a new directory with the path provided if it doesn’t exist e.g. <strong><em>mkdir -p /path/to/directory</em></strong></li><li><strong><em>touch</em></strong> = create an empty file e.g. <strong><em>touch /path/to/my/empty.file</em></strong></li><li><strong><em>groupadd</em></strong> = create a group e.g. <strong><em>groupadd AwesomeSauce</em></strong></li><li><strong><em>useradd</em></strong> = create a new user e.g. <strong><em>useradd username_here</em></strong><br>Though we need to pass more options:<br><strong><em>-m</em></strong> = make home directory (Needed to test.)<br><strong><em>-s</em></strong> = define which shell to use (We’ll use bash, not a fan of shell or sh.)<br><strong><em>-c</em></strong> = comment, we’ll define the FullName along with an email address<br>-<strong><em>G</em></strong> = add user to an existing group<br>Example(s):<br><strong><em>useradd -m -s /bin/bash -c “FirstName LastName &lt;emailaddress@domain.tld&gt;” -G GroupName username</em></strong><br><strong><em>useradd -m -s /bin/bash -c “Crash Override &lt;crash@overide.net&gt;” -G Hackers crash</em></strong></li><li><strong><em>chown</em></strong> = change ownership e.g.<strong><em> chown userowner_name:groupowner_name /path/to/file_or_directory</em></strong><br>The cool part about this, if you just need to change the user owner then use this: <strong><em>chown userowner_name /path/to/object, </em></strong>just the same for group like so<strong><em> chown :groupowner_name /path/to/object</em></strong></li><li><strong><em>chmod</em></strong> = change permissions e.g. <strong><em>chmod 700 /groupfiles/myfile</em></strong><br>This will set the permissions so that only the user owner can view the file “<strong><em>myfile</em></strong>”</li></ul><figure><img alt="Linux Permissions" src="https://cdn-images-1.medium.com/max/522/1*ClFffDIKoaPN6F8CyEu-DA.png" /><figcaption>Linux Permissions</figcaption></figure><ul><li><strong><em>apt</em></strong> vs <strong><em>apt-get</em></strong>: On the command line we can use apt, however, experience has taught me to not do this when scripting, use <strong><em>apt-get</em></strong> which is still backward compatible and you’ll avoid headaches while debugging</li></ul><h3>AWS Console Login:</h3><ol><li>Goto to <a href="https://console.aws.amazon.com/">https://console.aws.amazon.com/</a></li><li>Login with our credentials</li></ol><figure><img alt="AWS Login Screen" src="https://cdn-images-1.medium.com/max/700/0*lDTDNCuRBF-5EF4t.png" /><figcaption>AWS Login Screen</figcaption></figure><h3>Select Region</h3><ol><li>Change our region on the top right corner of the AWS console to the region we want to deploy our EC2 instances in, I’m using <strong><em>us-east-1</em></strong> otherwise shown as <strong><em>United States (N. Virginia)</em></strong></li></ol><figure><img alt="Select Region" src="https://cdn-images-1.medium.com/max/700/0*vRTtIL7ZXy6rCFI4.png" /><figcaption>Select Region</figcaption></figure><h3>Navigate To EC2</h3><ol><li>Open up the EC2 service by going to <a href="https://console.aws.amazon.com/ec2">https://console.aws.amazon.com/ec2</a></li><li>Alternative: Use the search box on the top and type <strong><em>EC2</em></strong></li></ol><figure><img alt="Navigate to EC2" src="https://cdn-images-1.medium.com/max/700/0*srFi8s6mc5PD-bdX.png" /><figcaption>Navigate to EC2</figcaption></figure><h3>Ubuntu Instance</h3><p>We’ll leave most of the settings default, below are the ones we’re defining.</p><h3>Launch Instance</h3><ol><li>Click on the<strong><em> Launch Instance</em></strong> button</li><li>Name: <strong><em>Ubuntu</em></strong></li><li>Application and OS Images (Amazon Machine Image): <strong><em>Ubuntu</em></strong></li><li>Amazon Machine Image (AMI): <strong><em>Ubuntu Server 24.04 LTS (HVM), SSD Volume Type </em></strong>(Expect newer versions.)</li></ol><h3>Instance Type</h3><ol><li>Instance Type: <strong><em>t2.micro<br>- </em></strong>Whichever is free tier eligible</li></ol><h3>Key pair (Login)</h3><ol><li>Click on the <strong><em>Create new key pair </em></strong>link</li><li>Key pair name: <strong><em>Ubuntu</em></strong></li><li>Key pair type: <strong><em>RSA</em></strong></li><li>Private key file format: .<strong><em>pem</em></strong> (Depending on your OS, this may be different, I’m running MacOS so this is my option.)</li><li>Click on the <strong><em>Create key pair</em></strong> button<br>- The private key of the key-pair will download to our system while the public key will stay in AWS and will be attached to EC2 instances<br>- The key name should populate in the<strong><em> Key pair name — required</em></strong> field, if not, select <strong><em>Ubuntu</em></strong> from the dropdown</li></ol><h3>Network Settings</h3><ol><li><strong><em>Create security group</em></strong> should already be ticked, if not, tick the box</li><li><strong><em>Allow SSH traffic from </em></strong>should already be ticked along with the <strong><em>Anywhere </em></strong>set to <em>0.0.0.0/0</em>, if not, tick the box and set the <strong><em>Anywhere</em></strong> to<strong><em> 0.0.0.0/0</em></strong></li><li>Read the warning, no need to worry, we’re only creating a demo that we’ll tear-down when we’re done</li></ol><h3>Advanced Details</h3><ol><li>Scroll-down to the bottom of the page and click on the <strong><em>triangle</em></strong> to the left of <strong><em>Advanced details</em></strong></li><li>Scroll-down to the bottom of the page and look for<strong><em> User data — optional</em></strong></li><li>Copy and paste the code block below into the <strong><em>User data field</em></strong></li><li>Click on the <strong><em>Launch Instance</em></strong> button</li><li>Lastly click on the <strong><em>View all instances</em></strong> button</li></ol><figure><img alt="Launch Instance" src="https://cdn-images-1.medium.com/max/700/0*_8hQR48wWfN82Cmg.png" /><figcaption>Launch Instance</figcaption></figure><figure><img alt="Ubuntu Instance Details Part 1" src="https://cdn-images-1.medium.com/max/1024/1*xTG69NbdZxF2Xg9JeTngKw.png" /><figcaption>Ubuntu Instance Details Part 1</figcaption></figure><figure><img alt="Generate Key Pair Details" src="https://cdn-images-1.medium.com/max/582/1*wMudZk9iZP93QmpnwvZFAA.png" /><figcaption>Generate Key Pair Details</figcaption></figure><figure><img alt="Ubuntu Instance Details Part 2" src="https://cdn-images-1.medium.com/max/1024/1*0qKtjgvJvJtqJnznHJxNxg.png" /><figcaption>Ubuntu Instance Details Part 2</figcaption></figure><figure><img alt="Advanced Details" src="https://cdn-images-1.medium.com/max/824/0*YG7JqU0rMwzFN-VE.png" /><figcaption>Advanced Details</figcaption></figure><figure><img alt="User Data Field" src="https://cdn-images-1.medium.com/max/1024/1*vp97v1jGD6AJV2N1uXG-fg.png" /><figcaption>User Data Field</figcaption></figure><h4>EC2 User Data Script 2.0 (Updated)</h4><pre>#!/bin/bash<br># ---------------------------------------------------------------------------------------<br># Title: EC2 User Data Script<br># Date: 2025-03-11<br># Version: 2.0<br># Written By: Carrick Bradley<br># Tested on: Ubuntu 24.04 LTS (Noble Numbat) on Amazon EC2<br># ---------------------------------------------------------------------------------------<br># Description: This script performs the following tasks:<br># - Updates and upgrades the operating system packages<br># - Creates directories for Development, Operations, and Analytics<br># - Creates 10 dummy files in each directory<br># - Creates user groups for Developers, Operations, and Data Analysts<br># - Sets group ownership for the directories<br># - Sets permissions for the directories<br># - Sets default group ownership for the directories<br># - Creates users and adds them to their department groups<br># - Logs all actions to both the console and a log file<br>#<br># Usage: ./startup-script.sh [num_dummy_files] [log_file_path] [directory_base_path]<br># Requirements: This script requires root privileges to run and will run on<br>#               Ubuntu 24.x LTS (Noble Numbat) and other Debian-based systems.<br>#               It may not work as expected on other systems.<br># ---------------------------------------------------------------------------------------<br><br># Exit on error, uninitialized variable, or failed command in a pipeline<br>set -euo pipefail<br><br># Define exit codes<br>SUCCESS=0<br>ERROR=1<br>INVALID_INPUT=2<br>GROUP_EXISTS=3<br>DIRECTORY_NOT_FOUND=4<br>USER_EXISTS=5<br>CONTACT_DETAILS_EMPTY=6<br>GROUP_DETAILS_EMPTY=7<br>USERNAME_EMPTY=8<br>CONTACT_DETAILS_FORMATTING_ERROR=9<br>USERNAME_FORMATTING_ERROR=10<br>INVALID_DIRECTORY_PATH=11<br>INVALID_GROUP_NAME=12<br><br># Default number of dummy files<br># If no argument is provided, the default value is 10<br>NUM_DUMMY_FILES=${1:-10}<br><br># Define the log file variable with a timestamp or use provided path<br># If no argument is provided, the default path is /var/log/ and the<br># log name will be startup-script-YYYYMMDD_HHMMSS.log<br>LOGFILE=&quot;${2:-/var/log/startup-script-$(date &#39;+%Y%m%d_%H%M%S&#39;).log}&quot;<br><br># Define the base path for directories using a named array<br># If no argument is provided, the default path is /fileshares<br># This path will be used to create the directories<br>DIRECTORY_BASE_PATH=&quot;${3:-/fileshares}&quot;<br>declare -A DIRECTORIES=(<br>    [&quot;Development&quot;]=&quot;$DIRECTORY_BASE_PATH/Development&quot;<br>    [&quot;Operations&quot;]=&quot;$DIRECTORY_BASE_PATH/Operations&quot;<br>    [&quot;Analytics&quot;]=&quot;$DIRECTORY_BASE_PATH/Analytics&quot;<br>)<br><br># Define the mapping between directories and their corresponding groups<br># using a named array<br># This mapping is used to set the group ownership of the directories<br>declare -A DIRECTORY_GROUP_MAP=(<br>    [&quot;Development&quot;]=&quot;Developers&quot;<br>    [&quot;Operations&quot;]=&quot;Operations&quot;<br>    [&quot;Analytics&quot;]=&quot;DataAnalysts&quot;<br>)<br><br># Define the mapping used to create users, contact details and their<br># respective groups using a named array<br>declare -A USERS=(<br>    [&quot;Jess Waller jwaller@levelupbank.com&quot;]=&quot;Developers&quot;<br>    [&quot;Blake Dorsey bdorsey@levelupbank.com&quot;]=&quot;Operations&quot;<br>    [&quot;Joey Ewart jewart@levelupbank.com&quot;]=&quot;DataAnalysts&quot;<br>)<br><br># Function to log messages<br># Default log level is INFO<br>log_capture() {<br>    local message=&quot;$1&quot;<br>    local level=&quot;${2:-INFO}&quot;<br>    local timestamp<br>    timestamp=$(date &#39;+%Y-%m-%d %H:%M:%S&#39;)<br><br>    echo &quot;$timestamp - [$level] - $message&quot;<br>    logger -t startup-script &quot;$message&quot;<br>}<br><br># Function sets up logging to both the console and log file<br># If the log file does not exist, it creates it or appends to it<br>initialize_logging() {<br>    log_capture &quot;Initializing logging to &#39;$LOGFILE&#39;...&quot; # This may not appear if the log file does not exist.<br>    if [ ! -f &quot;$LOGFILE&quot; ]; then<br>        touch &quot;$LOGFILE&quot;<br>        log_capture &quot;Log file &#39;$LOGFILE&#39; created.&quot;<br>    else<br>        log_capture &quot;Log file &#39;$LOGFILE&#39; already exists...appending to it.&quot;<br>    fi<br><br>    exec &gt; &gt;(tee -a &quot;$LOGFILE&quot;) 2&gt;&amp;1<br>    log_capture &quot;Logging initialized.&quot;<br>    log_capture &quot;Starting EC2 user data script...&quot;<br>}<br><br># Function checks if the number of dummy files is a positive integer and not zero<br>validate_input() {<br>    log_capture &quot;Validating input parameters...&quot;<br>    if ! [[ &quot;$NUM_DUMMY_FILES&quot; =~ ^[0-9]+$ &amp;&amp; &quot;$NUM_DUMMY_FILES&quot; -gt 0 ]]; then<br>        log_capture &quot;Error: The number of dummy files must be a positive integer.&quot; &quot;ERROR&quot;<br>        exit $INVALID_INPUT<br>    fi<br>    log_capture &quot;Input parameters validated successfully.&quot;<br>}<br><br># Function to update &amp; upgrade the operating system<br>update_and_upgrade_os() {<br>    log_capture &quot;Updating package list...&quot;<br>    if ! apt-get update -y; then<br>        log_capture &quot;Error: Failed to update package list.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Package list updated successfully.&quot;<br><br>    log_capture &quot;Upgrading installed packages...&quot;<br>    if ! apt-get upgrade -y; then<br>        log_capture &quot;Error: Failed to upgrade packages.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Packages upgraded successfully.&quot;<br><br>    log_capture &quot;Removing unnecessary packages...&quot;<br>    if ! apt-get autoremove -y; then<br>        log_capture &quot;Error: Failed to remove unnecessary packages.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Unnecessary packages removed successfully.&quot;<br><br>    log_capture &quot;Cleaning up package files...&quot;<br>    if ! apt-get autoclean -y; then<br>        log_capture &quot;Error: Failed to clean up package files.&quot; &quot;ERROR&quot;<br>        exit $ERROR<br>    fi<br>    log_capture &quot;Package files cleaned up successfully.&quot;<br>}<br><br># Function checks if the group name is alphanumeric and can include underscores<br>validate_group_name() {<br>    local group=&quot;$1&quot;<br><br>    log_capture &quot;Validating group name &#39;$group&#39;...&quot;<br>    if [[ ! &quot;$group&quot; =~ ^[a-zA-Z0-9_]+$ ]]; then<br>        log_capture &quot;Error: Group name &#39;$group&#39; must be alphanumeric and can include underscores.&quot; &quot;ERROR&quot;<br>        exit $INVALID_GROUP_NAME<br>    fi<br>    log_capture &quot;Group name &#39;$group&#39; validated successfully.&quot;<br>}<br><br># Function creates a directory and a specified number of dummy files within it<br>create_directory_and_dummy_files() {<br>    local directory_path=&quot;$1&quot;<br>    local num_files=&quot;$2&quot;<br>    <br>    log_capture &quot;Creating directory &#39;$directory_path&#39; and $num_files dummy files...&quot;<br>    # Checks if the directory path starts with &#39;/&#39;<br>    if [[ ! &quot;$directory_path&quot; =~ ^/ ]]; then<br>        log_capture &quot;Error: Invalid directory path &#39;$directory_path&#39;. Must start with &#39;/&#39;.&quot; &quot;ERROR&quot;<br>        exit $INVALID_DIRECTORY_PATH<br>    fi<br>    <br>    # Check if the directory already exists<br>    if [ ! -d &quot;$directory_path&quot; ]; then<br>        mkdir -p &quot;$directory_path&quot; &amp;&amp; log_capture &quot;Directory &#39;$directory_path&#39; created successfully.&quot;<br>    else<br>        log_capture &quot;Directory &#39;$directory_path&#39; already exists. Skipping creation.&quot;<br>    fi<br><br>    # Create dummy files if they do not exist<br>    log_capture &quot;Creating dummy files in &#39;$directory_path&#39;...&quot;<br>    for i in $(seq 1 &quot;$num_files&quot;); do<br>        local dummy_file=&quot;$directory_path/dummy_file_$i.txt&quot;<br>        if [ ! -f &quot;$dummy_file&quot; ]; then<br>            touch &quot;$dummy_file&quot; || { log_capture &quot;Failed to create dummy file &#39;$dummy_file&#39;.&quot; &quot;ERROR&quot;; exit $ERROR; }<br>        else<br>            log_capture &quot;Dummy file &#39;$dummy_file&#39; already exists. Skipping creation.&quot;<br>        fi<br>    done<br>    log_capture &quot;Created $num_files dummy files in &#39;$directory_path&#39;.&quot;<br>}<br><br># Function to create a user group if it does not exist<br>create_group() {<br>    local group=&quot;$1&quot;<br><br>    log_capture &quot;Creating group &#39;$group&#39;...&quot;<br>    validate_group_name &quot;$group&quot;<br>    # Check if the group already exists<br>    if ! getent group &quot;$group&quot; &gt; /dev/null; then<br>        groupadd &quot;$group&quot; &amp;&amp; log_capture &quot;Group &#39;$group&#39; created successfully.&quot;<br>    else<br>        log_capture &quot;Group &#39;$group&#39; already exists. Skipping group creation.&quot; &quot;INFO&quot;<br>    fi<br>}<br><br># Function to set group ownership for a specified directory<br>set_group_ownership() {<br>    local directory_path=&quot;$1&quot;<br>    local group=&quot;$2&quot;<br><br>    log_capture &quot;Setting group ownership for &#39;$directory_path&#39; to group &#39;$group&#39;...&quot;<br>    if [ -d &quot;$directory_path&quot; ]; then<br>        chown -R :&quot;$group&quot; &quot;$directory_path&quot; &amp;&amp; log_capture &quot;Ownership set for &#39;$directory_path&#39; to group &#39;$group&#39;.&quot;<br>    else<br>        log_capture &quot;Directory &#39;$directory_path&#39; does not exist. Skipping ownership change.&quot; &quot;WARNING&quot;<br>    fi<br>}<br><br># Function to set permissions for a specified directory to 770<br>set_directory_permissions_770() {<br>    local directory_path=&quot;$1&quot;<br><br>    log_capture &quot;Setting permissions for &#39;$directory_path&#39; to 770...&quot;<br>    if [ -d &quot;$directory_path&quot; ]; then<br>        chmod -R 770 &quot;$directory_path&quot; &amp;&amp; log_capture &quot;Permissions set to 770 for &#39;$directory_path&#39;.&quot;<br>    else<br>        log_capture &quot;Directory &#39;$directory_path&#39; does not exist. Skipping permission change.&quot; &quot;WARNING&quot;<br>    fi<br>}<br><br># Function to set default group ownership for a specified directory<br>set_default_ownership() {<br>    local directory_path=&quot;$1&quot;<br><br>    log_capture &quot;Setting default group ownership for &#39;$directory_path&#39;...&quot;<br>    if [ -d &quot;$directory_path&quot; ]; then<br>        chmod g+s &quot;$directory_path&quot; &amp;&amp; log_capture &quot;Set default group ownership for &#39;$directory_path&#39;.&quot;<br>    else<br>        log_capture &quot;Directory &#39;$directory_path&#39; does not exist. Skipping default ownership change.&quot; &quot;WARNING&quot;<br>    fi<br>}<br><br># Function to create a user and add them to a specified group<br>create_user() {<br>    local contact_details=&quot;$1&quot;<br>    local group=&quot;$2&quot;<br>    local username=&quot;$3&quot;<br><br>    log_capture &quot;Creating user with contact details &#39;$contact_details&#39;, group &#39;$group&#39;, and username &#39;$username&#39;...&quot;<br><br>    # Validate input is not empty error out if it is while logging the error<br>    log_capture &quot;Validating ${contact_details}, ${group} and ${username} are not empty...&quot;<br>    [[ -z &quot;$contact_details&quot; ]] &amp;&amp; { log_capture &quot;Error: Contact details are empty.&quot; &quot;ERROR&quot;; exit $CONTACT_DETAILS_EMPTY; }<br>    [[ -z &quot;$group&quot; ]] &amp;&amp; { log_capture &quot;Error: Group name is empty.&quot; &quot;ERROR&quot;; exit $GROUP_DETAILS_EMPTY; }<br>    [[ -z &quot;$username&quot; ]] &amp;&amp; { log_capture &quot;Error: Username is empty.&quot; &quot;ERROR&quot;; exit $USERNAME_EMPTY; }<br><br>    # Validate username is alphanumeric<br>    log_capture &quot;Validating username &#39;$username&#39; is alphanumeric...&quot;<br>    [[ ! &quot;$username&quot; =~ ^[a-zA-Z0-9]+$ ]] &amp;&amp; { log_capture &quot;Error: Username &#39;$username&#39; must be alphanumeric.&quot; &quot;ERROR&quot;; exit $USERNAME_FORMATTING_ERROR; }<br>    log_capture &quot;Username &#39;$username&#39; validated successfully.&quot;<br><br>    # Contact details parsing using space as the delimiter<br>    log_capture &quot;Parsing contact details...&quot;<br>    IFS=&#39; &#39; read -r first_name last_name email &lt;&lt;&lt; &quot;$contact_details&quot;<br>    log_capture &quot;Parsed contact details: First Name: &#39;$first_name&#39;, Last Name: &#39;$last_name&#39;, Email: &#39;$email&#39;&quot;<br>    <br>    # Validate if name and email are not empty<br>    log_capture &quot;Validating contact details...&quot;<br>    if [[ -z &quot;$first_name&quot; || -z &quot;$last_name&quot; || -z &quot;$email&quot; ]]; then<br>        log_capture &quot;Error: Contact details must include both first and last names and a valid email.&quot; &quot;ERROR&quot;<br>        exit $CONTACT_DETAILS_FORMATTING_ERROR<br>    fi<br>    log_capture &quot;Contact details validated successfully.&quot;<br><br>    # eMail validation regex<br>    log_capture &quot;Validating email format...&quot;<br>    [[ ! &quot;$email&quot; =~ ^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$ ]] &amp;&amp; { log_capture &quot;Error: Email format is invalid in contact details &#39;$contact_details&#39;.&quot; &quot;ERROR&quot;; exit $CONTACT_DETAILS_FORMATTING_ERROR; }<br>    log_capture &quot;Email format validated successfully.&quot;<br><br>    # Check if the user already exists<br>    log_capture &quot;Checking if user &#39;$username&#39; already exists...&quot;<br>    if id &quot;$username&quot; &amp;&gt;/dev/null; then<br>        log_capture &quot;User &#39;$username&#39; already exists. Skipping user creation.&quot; &quot;INFO&quot;<br>        return  # Skip creating this user<br>    fi<br>    log_capture &quot;User &#39;$username&#39; does not exist. Proceeding with user creation.&quot;<br><br>    # Create the user with a home directory and shell<br>    log_capture &quot;Creating user &#39;$username&#39;...&quot;<br>    useradd -m -s /bin/bash -c &quot;$contact_details&quot; -G &quot;$group&quot; &quot;$username&quot; &amp;&amp; log_capture &quot;User &#39;$username&#39; created successfully and added to group &#39;$group&#39;.&quot; || { log_capture &quot;Failed to create user &#39;$username&#39;.&quot; &quot;ERROR&quot;; exit $ERROR; }<br><br>    # Restrict home directory access (700)<br>    log_capture &quot;Setting permissions for home directory &#39;/home/$username&#39; to 700...&quot;<br>    chmod 700 &quot;/home/$username&quot; &amp;&amp; log_capture &quot;Permissions set to 700 for home directory &#39;/home/$username&#39;.&quot; || { log_capture &quot;Failed to set permissions for home directory &#39;/home/$username&#39;.&quot; &quot;ERROR&quot;; exit $ERROR; }<br><br>    log_capture &quot;User creation and setup completed successfully.&quot;<br>}<br><br># Main execution<br>initialize_logging<br>validate_input<br>update_and_upgrade_os<br><br># Create groups<br>for user in &quot;${!USERS[@]}&quot;; do<br>    group_name=&quot;${USERS[$user]}&quot;<br>    create_group &quot;$group_name&quot;<br>done<br><br># Create directories and dummy files<br>for dir_name in &quot;${!DIRECTORIES[@]}&quot;; do<br>    create_directory_and_dummy_files &quot;${DIRECTORIES[$dir_name]}&quot; &quot;$NUM_DUMMY_FILES&quot;<br>done<br><br># Set ownership and permissions for directories<br>for dir_name in &quot;${!DIRECTORIES[@]}&quot;; do<br>    log_capture &quot;Setting ownership and permissions for directory &#39;${DIRECTORIES[$dir_name]}&#39;...&quot;<br>    <br>    # Get the corresponding group name from the mapping array<br>    group_name=&quot;${DIRECTORY_GROUP_MAP[$dir_name]}&quot;<br>    <br>    if [[ -z &quot;$group_name&quot; ]]; then<br>        log_capture &quot;Error: No group mapping found for directory &#39;$dir_name&#39;. Skipping ownership setting.&quot; &quot;ERROR&quot;<br>        continue<br>    fi<br>    <br>    set_group_ownership &quot;${DIRECTORIES[$dir_name]}&quot; &quot;$group_name&quot;<br>    set_directory_permissions_770 &quot;${DIRECTORIES[$dir_name]}&quot;<br>    set_default_ownership &quot;${DIRECTORIES[$dir_name]}&quot;<br>done<br><br># Create users with formatted usernames<br>for user in &quot;${!USERS[@]}&quot;; do<br>    log_capture &quot;Creating user &#39;$user&#39;...&quot;<br>    <br>    # Extract contact details<br>    log_capture &quot;Extracting contact details for user &#39;$user&#39;...&quot;<br>    IFS=&#39; &#39; read -r first_name last_name email &lt;&lt;&lt; &quot;$user&quot;<br>    log_capture &quot;Extracted contact details: First Name: &#39;$first_name&#39;, Last Name: &#39;$last_name&#39;, Email: &#39;$email&#39;&quot;<br>    <br>    # Format the first name and last name to have the first letter capitalized<br>    log_capture &quot;Formatting display names...&quot;<br>    formatted_first_name=&quot;${first_name^}&quot;<br>    formatted_last_name=&quot;${last_name^}&quot;<br>    log_capture &quot;Formatted display names: &#39;$formatted_first_name&#39; &#39;$formatted_last_name&#39;&quot;<br><br>    # Format username to be all lowercase<br>    log_capture &quot;Formatting username...&quot;<br>    username=&quot;$(echo &quot;${first_name:0:1}${last_name}&quot; | tr &#39;[:upper:]&#39; &#39;[:lower:]&#39;)&quot;<br>    log_capture &quot;Formatted username: &#39;$username&#39;&quot;<br><br>    # Combine formatted names for contact details<br>    log_capture &quot;Combining formatted names for contact details...&quot;<br>    contact_details=&quot;$formatted_first_name $formatted_last_name $email&quot;<br>    log_capture &quot;Combined contact details: &#39;$contact_details&#39;&quot;<br><br>    create_user &quot;$contact_details&quot; &quot;${USERS[$user]}&quot; &quot;$username&quot;<br>done<br><br># Log the completion of our script<br>log_capture &quot;Amazon EC2 user data script completed successfully!&quot;<br>exit $SUCCESS</pre><h4>EC2 User Data Script 1.0 (Original)</h4><pre>#!/bin/bash<br>#<br># Global Variables<br>#<br># Disable interactive prompts since this is running programmaticly at first launch.<br># If we do not disable this, then at some point even with -y (for yes) will not work.<br># I&#39;ve been burned a few times forgetting this while in a hurry.<br>export DEBIAN_FRONTEND=noninteractive<br>#<br># Start Functions<br># Get latest updates &amp; install silently<br># We&#39;re using apt-get as this works better within scripts, I got burned during my tests using just apt<br># update = update the package list<br># upgrade = upgrade all packages<br># autoremove = remove packages that are no longer needed<br># autoclean = remove .deb files for packages that are no longer installed<br># -y = yes to all prompts<br>os_updates_and_upgrade () {<br>    apt-get update -y<br>    apt-get upgrade -y<br>    apt-get autoremove -y<br>    apt-get autoclean -y<br>}<br># Create Fileshare Directories<br># Using mkdir command along with -p to create the path if it doesn&#39;t exist<br>shares_create_directories () {<br>    mkdir -p /fileshares/Development /fileshares/Operations /fileshares/Analytics<br>}<br># Create 10 dummy files within each fileshare directory<br># Using a for loop with a range from 1 to 10 along with touch to create dummy files<br>shares_dummy_file_generator () {<br>    for i in {1..10}; do touch /fileshares/Development/file-$i.txt; done<br>    for i in {1..10}; do touch /fileshares/Operations/file-$i.txt; done<br>    for i in {1..10}; do touch /fileshares/Analytics/file-$i.txt; done<br>}<br># Create fileshare user groups<br># groupadd creates a the group followed by the groupname<br>shares_user_groups_generator () {<br>    groupadd Developers<br>    groupadd Operations<br>    groupadd DataAnalysts<br>}<br># Set fileshare directory ownership<br># chown = change ownership<br># -R = recursive<br># user and group are represented by using : between them e.g.<br># acmeuser:acemegroup<br># If we see just a : followed by the groupname, then we&#39;re changing the group owner<br>shares_set_ownership () {<br>    chown -R :Developers /fileshares/Development<br>    chown -R :Operations /fileshares/Operations<br>    chown -R :DataAnalysts /fileshares/Analytics<br>}<br># Set fileshare directory permissions<br># chmod = change mode to set permissions<br># -R = recursive<br># Using octal format, 770 <br># 7 = full access<br># 0 = no access<br># 770 = 1 7 is user owner and has RWX, the middle 7 is for group owner and has RWX, the last 0 is other or simply everyone else and they have no access<br># R = read<br># W = write<br># X = execute<br>shares_set_permissions () {<br>    chmod -R 770 /fileshares/Development<br>    chmod -R 770 /fileshares/Operations<br>    chmod -R 770 /fileshares/Analytics<br><br>}<br># Set fileshare directory default ownership<br># This allows new files and directores created within to inherit the group ownership of the directory and not that of the parent directory.<br># g = group<br># s = setgid (Using the group ownership of the directory.)<br># + means add<br>shares_set_default_ownership () {<br>    chmod g+s /fileshares/Development<br>    chmod g+s /fileshares/Operations<br>    chmod g+s /fileshares/Analytics<br>}<br># Create user then add to groups<br>shares_create_users () {<br>    # Create users and add them to their groups<br>    # -m creates a home directory, otherwise if you switch user it will fail as there is no home directory<br>    # -c adds a comment with the users fullname and email address<br>    # -s sets the shell, in this case bash, I&#39;m use to this than sh which is the default<br>    # -G adds the user to their groups<br>    useradd -ms /bin/bash -c &quot;Jess Waller &lt;jwaller@‌levelupbank.com&gt;&quot; -G Developers jwaller<br>    useradd -ms /bin/bash -c &quot;Black Dorsey, &lt;bdorsey@‌levelupbank.com&gt;&quot; -G Operations bdorsey<br>    useradd -ms /bin/bash -c &quot;Joey Ewart &lt;jewart@levelupbank.com&gt;&quot; -G DataAnalysts jewart<br>}<br># End Functions<br>#<br># Call the function name we defined<br># Order of Operations Matter Here!!! The first function to run should be the first one needed to get this train rolling down the line.<br>os_updates_and_upgrade<br>shares_create_directories<br>shares_dummy_file_generator<br>shares_user_groups_generator<br>shares_set_ownership<br>shares_set_permissions<br>shares_set_default_ownership<br>shares_create_users<br>#<br># End of script</pre><h3>Test Our Work</h3><p>Currently, we launched an EC2 instance running Ubuntu 24.04 LTS. While the server is spinning up, the user data bash script will patch the operating system, create directories, create dummy files into the created diretories, create groups, set ownership to the new directories using the new groups, set the permissions on each new directory to restrict access to only members of the group, set the default group on the directories so that newly created files/directories will inherit the respective group ownership, create users and lastly restrict new users home directories.</p><p>We need to validate the folder permissions for each group under /fileshares/<br>- Validate group ownership<br>- Validate permissions should be 770<br>- Validate dummy files exist and they’re owned by the intended group<br>- Switch user to each user and determine they can only access their group folders and only not the other new users home directories</p><h4>Ubuntu Instance</h4><ol><li>Click on the Ubuntu’s <strong><em>instance ID</em></strong> to go into it</li><li>Take note of the <strong><em>Public IPv4 address</em></strong></li><li>Open a <strong><em>terminal</em></strong> on our system</li><li>Let’s set the private key to only be accessible by our user and no one else by using the utility <strong><em>chmod</em></strong> on Mac or Linux systems on Windows, be sure to adjust the permissions on the file</li><li>Connection string: <strong><em>ssh -i ~/path_to_yourkey/Ubuntu.pem ubuntu@your-public-ipv4-address</em></strong></li><li>Type <strong><em>Yes</em></strong> to accept the <strong><em>host key fingerprint</em></strong> into our allowed SSH hosts file</li><li>We should now be on the <strong><em>command line interface (CLI)</em></strong> of our Ubuntu instance</li><li>Validate groups created: <strong><em>compgen -g</em></strong></li><li>Validate users created: <strong><em>compgen -u</em></strong></li><li>Validate user comments:<br>- <strong><em>getent passwd jwaller</em></strong><br>- <strong><em>getent passwd bdorsey</em></strong><br>- <strong><em>getent passwd jewart</em></strong></li><li>Let’s navigate to: <strong><em>cd /fileshares</em></strong></li><li>Run this: <strong><em>ls -l</em></strong></li><li>We should see our three directories: <strong><em>Analytics</em></strong>, <strong><em>Development</em></strong> and <strong><em>Operations</em></strong><br>- Each folder should show the group owner as follows: <strong><em>Analytics</em></strong> directory owned by <strong><em>DataAnalysts</em></strong> group, <strong><em>Development</em></strong> directory owned by the <strong><em>Developers</em></strong> group and the <strong><em>Operations</em></strong> directory owned by the <strong><em>Operations</em></strong> group<br>- The permissions for each directory is <strong><em>770</em></strong> which translates to: <strong><em>RWX</em></strong> permissions for user owner, <strong><em>RWX</em></strong> permissions for group owner, and <strong><em>— — — no </em></strong>permissions for others or everyone</li><li>Validate their are dummy files in each directory along with the proper permissions:<br>- <strong><em>sudo ls -l Analytics/</em></strong><br>- <strong><em>sudo ls -l Development/</em></strong><br>- <strong><em>sudo ls -l Operations/</em></strong></li><li>Validate users only have access to their respective group directory and they can’t access the other users home directory:<br><strong><em>- sudo su - jwaller<br>- cd /home/bdorsey<br>- cd /home/jewart<br>- cd /fileshares/<br>- cd Analytics/<br>- cd Development/<br>- cd Operations/<br>- sudo su - bdorsey<br>- cd /home/bdorsey<br>- cd /home/jewart<br>- cd /fileshares/<br>- cd Analytics/<br>- cd Development/<br>- cd Operations/<br>- sudo su - jewart<br>- cd /home/jwaller<br>- cd /home/bdorsey<br>- cd /fileshares/<br>- cd Analytics/<br>- cd Development/<br>- cd Operations/</em></strong><br>Tip: Expect, Permission denied errors, they’re expected.</li></ol><figure><img alt="compgen -g" src="https://cdn-images-1.medium.com/max/211/1*flwGuU4FpUNOVM73KRvE6w.png" /><figcaption>compgen -g</figcaption></figure><figure><img alt="compgen -u" src="https://cdn-images-1.medium.com/max/200/1*MwUbfjhfL5__IK0eJr87qw.png" /><figcaption>compgen -u</figcaption></figure><figure><img alt="getent passwd &lt;username&gt;" src="https://cdn-images-1.medium.com/max/601/1*gaspkX1lhQQ2RX6QoFM9Lw.png" /><figcaption>getent passwd &lt;username&gt;</figcaption></figure><figure><img alt="Directory Ownership &amp; Permissions" src="https://cdn-images-1.medium.com/max/461/1*pxDfYRjv3aChtwdnJn5EBg.png" /><figcaption>Directory Ownership &amp; Permissions</figcaption></figure><figure><img alt="Users Permissions For Home &amp; File Share Access" src="https://cdn-images-1.medium.com/max/413/1*ROCl88pNrnqSzr3NqNKdTw.png" /><figcaption>Users Permissions For Home &amp; File Share Access</figcaption></figure><h3>Conclusion</h3><p>We have successfully launched an Ubuntu EC2 instance using user data which patched the Operating System and create a very basic file share with restricted access to their respective groups.</p><ol><li>Logged into the AWS Console</li><li>Navigated to EC2</li><li>Launched an Ubuntu instance with:<br>- Generated an SSH KeyPair<br>- Created a Security group that allows SSH<br>- Defined user data that installed updates, created file share directories, created groups, changed group ownership to file share directories with our newly created groups, set file share directory inheritance to use the new group name as the owner of newly created files/directories, generated 10 dummy files in each file share directory, created users with options &amp; comment</li><li>Shelled over to our ubuntu server and validated:<br>- Groups created<br>- Users created<br>- Users comment was created<br>- File shares were created<br>- Each department directory has the correct group ownership and permissions<br>- Dummy files exist and their ownership and permissions are correct<br>- Switched user to each user and confirmed they only have access to their home directory and their share directory</li></ol><p>Thank you for sticking in there with me. If you have any feedback please feel free to reach out to me.</p><p>The cloud is a canvas; your creativity is the brush. Paint your masterpiece.</p><p><a href="https://medium.com/u/331e9964766c">LaSherr’e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bb192f123e00" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Amazon EC2: Deploy an Apache Web Server on Ubuntu 24.04 LTS]]></title>
            <link>https://medium.com/@carrickbradley/amazon-ec2-deploy-an-apache-web-server-on-ubuntu-24-04-lts-e5242632a491?source=rss-8c55746da4c5------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5242632a491</guid>
            <category><![CDATA[ec2]]></category>
            <category><![CDATA[ubuntu]]></category>
            <category><![CDATA[cloud-devops-engineer]]></category>
            <category><![CDATA[apache]]></category>
            <category><![CDATA[cloud-devops]]></category>
            <dc:creator><![CDATA[Carrick Bradley]]></dc:creator>
            <pubDate>Thu, 27 Feb 2025 14:55:12 GMT</pubDate>
            <atom:updated>2025-03-06T22:41:20.102Z</atom:updated>
            <content:encoded><![CDATA[<p>I’m excited to share with you my joy of using open-source software. As the title states, I’ll take us on a journey to deploy a single Ubuntu EC2 instance using the user data to automate the installation of Apache and configure a static HTML web-page.</p><figure><img alt="Image background generated with DeepAI. AWS Logo’s, provided by Amazon Web Services, Inc. Ubuntu Logo provided by Canonical Ltd. Powered By Apache Logo provided by The Apache Software Foundation" src="https://cdn-images-1.medium.com/max/640/1*dUZ0U2kTqNO8xZQktiy8Hg.png" /><figcaption>Image background generated with DeepAI. AWS Logo’s, provided by Amazon Web Services, Inc. Ubuntu Logo provided by Canonical Ltd. Powered By Apache Logo provided by The Apache Software Foundation</figcaption></figure><h3>What is Open-source Software?</h3><p>Open-source Software is free to use for everyone. We have access to the source code that we can fork to make enhancements to, though there’s a process for this that goes beyond the scope of this topic. Lastly, we can participate in the open-source community and collaborate with others which helps promote innovation along with delivery to the public much faster e.g. updates, patches, and security updates to name a few.</p><h3>What is a web server?</h3><p>Let’s not let the word “server” confuse us, a server is a computer just like the ones we use day end and out, these just have fancier hardware &amp; software. In short, think of the word server for a moment, it serves requests from clients such our web browsers. Wether we know it our not, this article we’re reading was served up to you from a web-server.</p><p>Thin of web-servers like requesting a book from library. The library stores books, just like a web-servers store the website content. If we’re looking for a book, we can ask the librarian, just like a web-server processing our request when we visit the site. Just like the Liberian handing you the book, the web-server delivers the content to our browser. The entire process requires us to communicate with the librarian, for web-servers, nothings different, we use a set of protocols that define how we’ll communicate over the internet with the web-server. Here’s a list of protocols used to communicate:</p><ul><li>Transport Control Protocol over Internet Protocol (TCP/IP)</li><li>Hypertext Transfer Protocol (HTTP)</li><li>HTTP Secure (HTTPS) hopefully using Transport Layer Security (TLS) to secure communication with the web-server and our browser</li></ul><h3>What Is “User Data”</h3><p>One time startup-script that runs only at the launch of an EC2 instance with elevated privileges so that we can automate the process of baking artifacts into our web-server. In our case, thats the OS pathches along with installing &amp; configuring the Apache2 web-server service.</p><h3>What To Expect</h3><ol><li>Launch &amp; login into the AWS Console</li><li>Navigate to the Amazon EC2 service</li><li>Launch an instance using Ubuntu 24.04 LTS</li><li>Configure the EC2 instance with user data:<br>- Patch the operating system<br>- Install Apache2<br>- Define an HTML page</li><li>Launch the EC2 Instace</li><li>Lastly, we’ll test, I can’t stress this enough</li></ol><h3>Prerequisites</h3><ol><li>AWS Account</li><li>A static HTML page (Feel free to use mine and adjust to your liking.)</li></ol><h3>Lets Get Started</h3><h3>AWS Console Login:</h3><ol><li>Goto to <a href="https://console.aws.amazon.com/">https://console.aws.amazon.com/</a></li><li>Login with our credentials</li></ol><figure><img alt="AWS Login Screen" src="https://cdn-images-1.medium.com/max/700/0*o6kNkZFGy4jcZuix.png" /><figcaption>AWS Login Screen</figcaption></figure><h3>Select Region</h3><ol><li>Change our region on the top right corner of the AWS console to the region we want to deploy our EC2 instances in, I’m using <strong><em>us-east-1</em></strong> otherwise shown as <strong><em>United States (N. Virginia)</em></strong></li></ol><figure><img alt="Select Region" src="https://cdn-images-1.medium.com/max/700/0*86kGFupGi_CXYP4P.png" /><figcaption>Select Region</figcaption></figure><h3>Navigate To EC2</h3><ol><li>Open up the EC2 service by going to <a href="https://console.aws.amazon.com/ec2">https://console.aws.amazon.com/ec2</a></li><li>Alternative: Use the search box on the top and type <strong><em>EC2</em></strong></li></ol><figure><img alt="Navigate to EC2" src="https://cdn-images-1.medium.com/max/700/0*vXfExpnF7wYtd8-D.png" /><figcaption>Navigate to EC2</figcaption></figure><h3>Ubuntu Instance</h3><p>We’ll leave most of the settings default, below are the ones we’re defining.</p><h4>Launch Instance</h4><ol><li>Click on the<strong><em> Launch Instance</em></strong> button</li><li>Name: <strong><em>UbuntuWebServer</em></strong></li><li>Application and OS Images (Amazon Machine Image): <strong><em>Ubuntu</em></strong></li><li>Amazon Machine Image (AMI): <strong><em>Ubuntu Server 24.04 LTS (HVM), SSD Volume Type </em></strong>(Expect newer versions.)</li></ol><h4>Instance Type</h4><ol><li>Instance Type: <strong><em>t2.micro<br>- </em></strong>Whichever is free tier eligible</li></ol><h4>Key pair (Login)</h4><ol><li>Click on the <strong><em>Create new key pair </em></strong>link</li><li>Key pair name: <strong><em>UbuntuWebServer</em></strong></li><li>Key pair type: <strong><em>RSA</em></strong></li><li>Private key file format: .<strong><em>pem</em></strong> (Depending on your OS, this may be different, I’m running MacOS so this is my option.)</li><li>Click on the <strong><em>Create key pair</em></strong> button<br>- The private key of the key-pair will download to our system while the public key will stay in AWS and will be attached to EC2 instances<br>- The key name should populate in the<strong><em> Key pair name — required</em></strong> field, if not, select <strong><em>UbuntuWebServer</em></strong> from the dropdown</li></ol><h4>Network Settings</h4><ol><li><strong><em>Create security group</em></strong> should already be ticked, if not, tick the box</li><li><strong><em>Allow SSH traffic from </em></strong>should already be ticked along with the <strong><em>Anywhere </em></strong>set to <em>0.0.0.0/0</em>, if not, tick the box and set the <strong><em>Anywhere</em></strong> to<strong><em> 0.0.0.0/0</em></strong></li><li>Tick the box to <strong><em>Allow HTTP traffic from the internet</em></strong></li><li>Read the warning, no need to worry, we’re only creating a demo that we’ll tear-down when we’re done</li></ol><h4>Advanced Details</h4><ol><li>Scroll-down to the bottom of the page and click on the <strong><em>triangle</em></strong> to the left of <strong><em>Advanced details</em></strong></li><li>Scroll-down to the bottom of the page and look for<strong><em> User data — optional</em></strong></li><li>Copy and paste the code block below into the <strong><em>User data field</em></strong></li><li>Click on the <strong><em>Launch Instance</em></strong> button</li><li>Lastly click on the <strong><em>View all instances</em></strong> button</li></ol><pre>#!/bin/bash<br>#<br># Global Variables<br>#<br># Disable interactive prompts since this is running programmaticly at first launch.<br># If we do not disable this, then at some point even with -y (for yes) will not work.<br># Trust me on this, I&#39;ve been burned a few times forgetting this while in a hurry.<br>export DEBIAN_FRONTEND=noninteractive<br>#<br># Functions<br>    # Get latest updates &amp; install silently<br>    os_updates_and_upgrade () {<br>        apt update -y<br>        apt upgrade -y<br>        apt autoremove -y<br>        apt autoclean -y<br>    }<br>    # Apache2 Install<br>    apache_install () {<br>        apt install apache2 -y<br>    }<br>    # Apache2 Configure<br>    apache_configure () {<br>        # Change to the default Apache2 wegbro directory<br>        cd /var/www/html<br>        # Remove the default index.html file<br>        rm -f index.html<br>        # Create a new index.html file with a welcome message<br>        # Normally for sake of reading this cleaner, I must keep this non-indented for End of File EOF to work<br>        # Using tee to create the file, then EOF to fill it with the HTML code<br>        # This is a common way to create files in bash scripts<br>tee index.html &lt;&lt;EOF<br>&lt;!DOCTYPE html&gt;<br>&lt;html lang=&quot;en&quot;&gt;<br>&lt;head&gt;<br>    &lt;meta charset=&quot;UTF-8&quot;&gt;<br>    &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1.0&quot;&gt;<br>    &lt;title&gt;Welcome to LUIT&lt;/title&gt;<br>    &lt;style&gt;<br>        body {<br>            font-family: &#39;Arial&#39;, sans-serif;<br>            margin: 0;<br>            padding: 0;<br>            background: linear-gradient(135deg, #1a0f4b, #000000); /* Dark purple to black gradient */<br>            color: #ffffff;<br>            display: flex;<br>            flex-direction: column;<br>            justify-content: center;<br>            align-items: center;<br>            height: 100vh;<br>            text-align: center;<br>            overflow: hidden;<br>        }<br><br>        h1 {<br>            font-size: 4em; /* Large size */<br>            color: #ff4081; /* Hot Pink */<br>            animation: futuristicEffect 1.5s infinite alternate;<br>        }<br><br>        h2 {<br>            font-size: 3em; /* Large size */<br>            color: #39ff14; /* Neon Green */<br>            animation: futuristicEffect 1.5s infinite alternate;<br>        }<br><br>        @keyframes futuristicEffect {<br>            0% {<br>                transform: scale(1);<br>            }<br>            100% {<br>                transform: scale(1.05);<br>            }<br>        }<br><br>        .button {<br>            margin-top: 30px;<br>            padding: 15px 30px;<br>            font-size: 1.5em; /* Larger button text */<br>            color: #ffffff;<br>            background-color: #ff4081; /* Hot Pink */<br>            border: none;<br>            border-radius: 5px;<br>            cursor: pointer;<br>            transition: background-color 0.3s;<br>        }<br><br>        .button:hover {<br>            background-color: #d5006d; /* Darker Pink */<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;div&gt;<br>        &lt;h1&gt;Welcome to LUIT&lt;/h1&gt;<br>        &lt;h2&gt;Green Team - DevOps - February 2025&lt;/h2&gt;<br>        &lt;button class=&quot;button&quot; onclick=&quot;window.location.href=&#39;https://levelupintech.com&#39;&quot;&gt;Get Started&lt;/button&gt;<br>    &lt;/div&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>EOF<br>        # Set permissions for the index.html file<br>        chmod 644 index.html<br>        # Enable &amp; start the Apache2 service<br>        systemctl enable apache2<br>        systemctl start apache2<br>}<br>#<br># Call Functions, Order of Operations Matter Here!!!<br>os_updates_and_upgrade<br>apache_install<br>apache_configure<br>#<br># End of script</pre><figure><img alt="Launch Instance" src="https://cdn-images-1.medium.com/max/700/0*KnNpOmHqLrsTPaxg.png" /><figcaption>Launch Instance</figcaption></figure><figure><img alt="Ubuntu Instance Details Part 1" src="https://cdn-images-1.medium.com/max/1024/1*Yj3zgsRdQXoGIji5qCG_2w.png" /><figcaption>Ubuntu Instance Details Part 1</figcaption></figure><figure><img alt="Generate Key Pair Details" src="https://cdn-images-1.medium.com/max/588/1*VpZuwUawxW2_dU0LymPP1g.png" /><figcaption>Generate Key Pair Details</figcaption></figure><figure><img alt="Ubuntu Instance Details Part 2" src="https://cdn-images-1.medium.com/max/1024/1*PyGntgGj0PwMwMeFfjkNlw.png" /><figcaption>Ubuntu Instance Details Part 2</figcaption></figure><figure><img alt="Advanced Details" src="https://cdn-images-1.medium.com/max/824/1*Phcs0jMbXZQAsf289HOlRw.png" /><figcaption>Advanced Details</figcaption></figure><figure><img alt="User Data Field" src="https://cdn-images-1.medium.com/max/1024/1*tL9x1xgKN089oAQgvTyApQ.png" /><figcaption>User Data Field</figcaption></figure><figure><img alt="View All Instances" src="https://cdn-images-1.medium.com/max/700/0*REXnFVmPxWqz5ihg.png" /><figcaption>View All Instances</figcaption></figure><h3>Test Our Work</h3><p>Currently, we have launch and EC2 instance running Ubuntu 24.04 LTS. While the server is spinning up, the user data bash script will patch the operating system along with installing Apache2 and lastely configure a index.html static web page that we’ll then check.</p><h4>Instance State</h4><p>We’ll wait for our instances to be in a <strong><em>running</em></strong> state along with the <strong><em>Status Check</em></strong> to be <strong><em>2/2 checks passed</em></strong> before we continue.</p><h4>Ubuntu Instance</h4><ol><li>Click on the UbuntuWebServer’s <strong><em>instance ID</em></strong> to go into it</li><li>Take note of the <strong><em>Public IPv4 address</em></strong></li><li>Open a <strong><em>terminal</em></strong> on our system</li><li>Let’s set the private key to only be accessible by our user and no one else by using the utility <strong><em>chmod</em></strong> on Mac or Linux systems on Windows, be sure to adjust the permissions on the file</li><li>Connection string: <strong><em>ssh -i ~/path_to_yourkey/UbuntuWebServer.pem ubuntu@your-public-ipv4-address</em></strong></li><li>Type <strong><em>Yes</em></strong> to accept the <strong><em>host key fingerprint</em></strong> into our allowed SSH hosts file</li><li>We should now be on the <strong><em>command line interface (CLI)</em></strong> of our UbuntuWebServer instance, type the command: <strong><em>systemctl status apache2</em></strong></li><li>We should get a responce back that shows the apache2 service is <strong><em>running</em></strong></li><li>We have successfully connected to our Ubuntu instance using SSH with the key-pair we created and validated the apache2 service is running</li><li>Now lets open our <strong><em>browser</em></strong> and goto: <strong><em>http://&lt;UbuntuWebServer_Public_IPv4_Address&gt; e.g. </em></strong><a href="http://44.204.58.19/"><strong><em>http://44.204.58.19</em></strong></a></li><li>We should now see a <strong><em>LUIT Green DevOps Team</em></strong> static page with a button, click it to join in on the fun here at Level Up In Tech buckle up and get ready to cloud</li></ol><figure><img alt="UbuntuWebServer Instance Ready" src="https://cdn-images-1.medium.com/max/1024/1*_2LKxMNWpHh7jJ8OfF8FiQ.png" /><figcaption>UbuntuWebServer Instance Ready</figcaption></figure><figure><img alt="Shelling Over To UbuntuWebServer Instance" src="https://cdn-images-1.medium.com/max/573/1*CAWiW1DujcLpljbPoTd20A.png" /><figcaption>Shelling Over To UbuntuWebServer Instance</figcaption></figure><figure><img alt="Apache2 Service Running" src="https://cdn-images-1.medium.com/max/690/1*MABsbzgHmB92HXFTR3oB0w.png" /><figcaption>Apache2 Service Running</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/799/1*CFheO6emiR44FhwfJ45H4g.png" /></figure><h3>Conclusion</h3><p>We have successfully launched an Ubuntu EC2 instance using user data which patched the Operating System then installed the apache2 service and lastly configured our static web page file index.html.</p><ol><li>Logged into the AWS Console</li><li>Navigated to EC2</li><li>Launched an Ubuntu instance with:<br>- Generated an SSH KeyPair<br>- Created a Security group that allows SSH &amp; HTTP traffic from the public<br>- Defined user data that installed updates, installed apache2 service, and configured apache2 service with our static web page index.html under the default web root of /var/www/html</li><li>Shelled over to our web server and validated the apache2 service was running</li><li>Lastly, using our browser, we viewed our static web page using the public IPv4 address</li></ol><p>Thank you for sticking in there with me. If you have any feedback please feel free to reach out to me.</p><p>Somedays it just feels like forever, take some time and rest, head out into nature to recharge. I have faith in you, you can cloud.</p><p><a href="https://medium.com/u/331e9964766c">LaSherr&#39;e Osborne</a> <a href="https://medium.com/u/da6921733fdd">Sarah Obioma</a> <a href="https://medium.com/u/228876be1381">Dara</a> <a href="https://medium.com/u/681182b8e683">Peter Nguyen</a> <a href="https://medium.com/u/b73c9ddc7da4">Abdihakim Shukri</a> <a href="https://medium.com/u/e34cbb4c970a">Shaun Latimore</a> <a href="https://medium.com/u/9de90b4c65d7">Austin Towns</a> <a href="https://medium.com/u/e2a308ee5f26">Anthony Williams</a> <a href="https://medium.com/u/331e55d999a0">derrick pope</a> <a href="https://medium.com/u/7aaeb664baa9">Janita Williamson</a> <a href="https://medium.com/u/b86a3d7b4099">Carl Hayes</a> <a href="https://medium.com/u/a37a3a009138">Troy Ingram</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5242632a491" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>