<?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 Mario Tolic on Medium]]></title>
        <description><![CDATA[Stories by Mario Tolic on Medium]]></description>
        <link>https://medium.com/@mariotolic?source=rss-e98ded98b65f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*eY2d6bCedMR15fL3</url>
            <title>Stories by Mario Tolic on Medium</title>
            <link>https://medium.com/@mariotolic?source=rss-e98ded98b65f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 08:46:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mariotolic/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[A Step-by-Step Guide to Enabling Amazon ECS Exec]]></title>
            <link>https://medium.com/@mariotolic/a-step-by-step-guide-to-enabling-amazon-ecs-exec-a88b05858709?source=rss-e98ded98b65f------2</link>
            <guid isPermaLink="false">https://medium.com/p/a88b05858709</guid>
            <category><![CDATA[ec]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[Mario Tolic]]></dc:creator>
            <pubDate>Tue, 02 Jan 2024 14:46:48 GMT</pubDate>
            <atom:updated>2024-01-02T14:48:43.193Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/278/1*KaaI9EiGxxAQ2nnAyp6OGw.png" /></figure><p>Amazon Elastic Container Service (ECS) offers a powerful feature known as ECS Exec, revolutionizing how developers interact with containers within ECS clusters, bringing efficient management and debugging.</p><h3>Understanding Amazon ECS Exec</h3><p>Amazon ECS Exec simplifies container management by enabling direct access to containers in an ECS cluster without requiring SSH or other external access. It provides a secure, interactive shell to troubleshoot, diagnose, and monitor containers in real time, enhancing operational efficiency.</p><h3>Key Benefits of ECS Exec</h3><ol><li><strong>Streamlined Debugging:</strong> Debugging containerized applications becomes more accessible with ECS Exec, allowing real-time access to container environments without compromising security.</li><li><strong>Improved Troubleshooting:</strong> Gain deeper insights into container behavior by executing commands within the container context, aiding in identifying and resolving issues swiftly.</li><li><strong>Enhanced Security:</strong> ECS Exec ensures secure interactions by utilizing AWS IAM policies, restricting access to authorized users and roles only.</li></ol><h3>How to Use ECS Exec</h3><h3>Prerequisites</h3><p>Before diving in, ensure you have the following:</p><ul><li>AWS CLI installed</li><li>Session Manager plugin for the AWS CLI installed (<a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/session-manager-working-with-install-plugin.html">Installation Guide</a>)</li></ul><h3>Creating an IAM Role</h3><ul><li>Navigate to IAM &gt; Roles &gt; Create Role.</li><li>Choose a custom trust policy and paste the provided JSON content.</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;Principal&quot;: {<br>                &quot;Service&quot;: &quot;ecs-tasks.amazonaws.com&quot;<br>            },<br>            &quot;Action&quot;: &quot;sts:AssumeRole&quot;<br>        }<br>    ]<br>}</pre><ul><li>Create a role without adding a policy and name it. Edit the role to create an inline policy using specific JSON values for resources based on your AWS region, account ID, and cluster name.</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;ssmmessages:CreateControlChannel&quot;,<br>                &quot;ssmmessages:CreateDataChannel&quot;,<br>                &quot;ssmmessages:OpenControlChannel&quot;,<br>                &quot;ssmmessages:OpenDataChannel&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;logs:DescribeLogGroups&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;*&quot;<br>        },<br>        {<br>            &quot;Effect&quot;: &quot;Allow&quot;,<br>            &quot;Action&quot;: [<br>                &quot;logs:CreateLogStream&quot;,<br>                &quot;logs:DescribeLogStreams&quot;,<br>                &quot;logs:PutLogEvents&quot;<br>            ],<br>            &quot;Resource&quot;: &quot;arn:aws:logs:YOUR_REGION_HERE:YOUR_ACCOUNT_ID_HERE:log-group:/aws/ecs/CLUSTER_NAME:*&quot;<br>        }<br>    ]<br>}</pre><h3>ECS Task Configuration</h3><ul><li>Access ECS and Update Task Definition.</li><li>Create a new revision, select the previously created role for “Task role” (distinct from “Task execution role”), and update the task definition.</li><li>Ensure you add the following JSON snippet under containerDefinitions to enable ‘initProcessEnabled’:</li></ul><pre>&quot;containerDefinitions&quot;: [<br>        {<br>            &quot;linuxParameters&quot;: {<br>                &quot;initProcessEnabled&quot;: true<br>            }<br>        }<br>    ],</pre><h3>Service Update</h3><ul><li>Navigate to your ECS Service and Update. Ensure the revision is set to the latest version and complete the update. This action provisions your new task with its designated role.</li></ul><h3>Enabling Execution Commands</h3><p>Once, the service has been updated, it is time to enable execute command:</p><pre>aws ecs update-service --cluster CLUSTER_NAME --service SERVICE_NAME --region REGION --enable-execute-command --force-new-deployment</pre><p>To see if the execution is enabled properly, you should run:</p><pre>aws ecs describe-services --cluster CLUSTER_NAME--region REGION --service SERVICE_NAME</pre><p>Output would result in showing that Execute Command is enabled:</p><pre>            &quot;enableExecuteCommand&quot;: true</pre><p>To ‘EXEC into an instance’ use following syntax:</p><pre>aws ecs execute-command --region REGION --cluster CLUSTER_NAME --task TASK_ARN --container CONTAINER --command &quot;sh&quot; --interactive</pre><p>The end goal would be successful connectivity to the container as showed in the example below:</p><pre>#aws ecs execute-command --region eu-west-1 --cluster devcluster --task arn:aws:ecs:eu-west-1:############:task/devcluster/9f14b0d5b59d4f688f6074debf6332d6 --container website --command &quot;sh&quot; --interactive<br><br>The Session Manager plugin was installed successfully. Use the AWS CLI to start a session.<br><br><br>Starting session with SessionId: ecs-execute-command-0e18738065c7daa0a<br>#</pre><p>For a detailed walk-through, refer to the <a href="https://docs.aws.amazon.com/AmazonECS/latest/developerguide/ecs-exec.html">Amazon ECS Exec guide</a>.</p><p>Enabling access to all your instances becomes efficient with ECS Exec, allowing streamlined container management without compromising security.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a88b05858709" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>