{"id":3528,"date":"2026-05-07T16:49:00","date_gmt":"2026-05-07T08:49:00","guid":{"rendered":"https:\/\/ichwanchandra.com\/blog\/?p=3528"},"modified":"2026-11-02T23:50:45","modified_gmt":"2026-11-02T15:50:45","slug":"aws-solutions-architect-project-cost-optimization-part-3","status":"publish","type":"post","link":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/","title":{"rendered":"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3"},"content":{"rendered":"\n<p>We will start automating the resource cleanup by setting up necessary infrastructure such as creating an IAM Role and IAM User for automation access, defining an SSM Automation Document that performs the cleanup actions, and setting up an SNS Topic to notify the users about resources being deleted. These steps ensure the cleanup process has the right permissions, execution logic, and visibility before we actually run it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 1: Setup SSM Automation Document<\/h2>\n\n\n\n<p>In this step, we will setup the workflow for cleanup automation<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to <strong>AWS Systems Manager console<\/strong>, select <strong>Documents<\/strong>, click <strong>Create Document<\/strong>, click <strong>Automation<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1069\" height=\"935\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-27.png\" alt=\"\" class=\"wp-image-3543\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-27.png 1069w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-27-300x262.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-27-1024x896.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-27-768x672.png 768w\" sizes=\"auto, (max-width: 1069px) 100vw, 1069px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Document Name: <strong>CostManager-Cleanup<\/strong><\/li>\n\n\n\n<li>Select Code tab and paste the following JSON code below:<\/li>\n<\/ul>\n\n\n\n<pre class=\"wp-block-code\"><code>{\n  \"schemaVersion\": \"0.3\",\n  \"description\": \"Automates cleanup of unattached EBS volumes and unassociated Elastic IPs.\",\n  \"assumeRole\": \"{{ AutomationAssumeRole }}\",\n  \"parameters\": {\n    \"AutomationAssumeRole\": {\n      \"type\": \"String\",\n      \"description\": \"IAM role that allows Automation to clean up resources\"\n    },\n    \"Approver\": {\n      \"type\": \"String\",\n      \"description\": \"Email or ARN of the approver for cleanup actions\"\n    }\n  },\n  \"mainSteps\": &#91;\n    {\n      \"name\": \"FindUnattachedVolumes\",\n      \"action\": \"aws:executeAwsApi\",\n      \"nextStep\": \"FindUnassociatedEIPs\",\n      \"isEnd\": false,\n      \"inputs\": {\n        \"Service\": \"ec2\",\n        \"Api\": \"DescribeVolumes\",\n        \"Filters\": &#91;\n          {\n            \"Name\": \"status\",\n            \"Values\": &#91;\n              \"available\"\n            ]\n          }\n        ]\n      },\n      \"outputs\": &#91;\n        {\n          \"Name\": \"VolumeIds\",\n          \"Selector\": \"$.Volumes..VolumeId\",\n          \"Type\": \"StringList\"\n        }\n      ]\n    },\n    {\n      \"name\": \"FindUnassociatedEIPs\",\n      \"action\": \"aws:executeAwsApi\",\n      \"nextStep\": \"ApproveDeletion\",\n      \"isEnd\": false,\n      \"inputs\": {\n        \"Service\": \"ec2\",\n        \"Api\": \"DescribeAddresses\",\n        \"Filters\": &#91;\n          {\n            \"Name\": \"domain\",\n            \"Values\": &#91;\n              \"vpc\"\n            ]\n          }\n        ]\n      },\n      \"outputs\": &#91;\n        {\n          \"Name\": \"EipAllocationIds\",\n          \"Selector\": \"$.Addresses\",\n          \"Type\": \"MapList\"\n        }\n      ]\n    },\n    {\n      \"name\": \"ApproveDeletion\",\n      \"action\": \"aws:approve\",\n      \"nextStep\": \"DeleteResources\",\n      \"isEnd\": false,\n      \"inputs\": {\n        \"Approvers\": &#91;\n          \"{{ Approver }}\"\n        ],\n        \"MinRequiredApprovals\": 1,\n        \"Message\": \"Approve cleanup of unattached Volumes and unassociated EIPs.\"\n      }\n    },\n    {\n      \"name\": \"DeleteResources\",\n      \"action\": \"aws:executeScript\",\n      \"nextStep\": \"NotifySuccess\",\n      \"isEnd\": false,\n      \"inputs\": {\n        \"Runtime\": \"python3.12\",\n        \"Handler\": \"cleanup_handler\",\n        \"InputPayload\": {\n          \"volumes\": \"{{ FindUnattachedVolumes.VolumeIds }}\",\n          \"raw_eips\": \"{{ FindUnassociatedEIPs.EipAllocationIds }}\"\n        },\n        \"Script\": \"import boto3\\n\\ndef cleanup_handler(event, context):\\n    ec2 = boto3.client('ec2')\\n    results = &#91;]\\n    \\n    volumes = event.get('volumes', &#91;])\\n    if isinstance(volumes, str):\\n        volumes = &#91;volumes] if volumes else &#91;]\\n        \\n    for vol in volumes:\\n        try:\\n            ec2.delete_volume(VolumeId=vol)\\n            results.append(f'Deleted volume: {vol}')\\n        except Exception as e:\\n            results.append(f'Failed volume {vol}: {str(e)}')\\n            \\n    raw_eips = event.get('raw_eips', &#91;])\\n    for eip in raw_eips:\\n        if 'AssociationId' not in eip:\\n            allocation_id = eip.get('AllocationId')\\n            if allocation_id:\\n                try:\\n                    ec2.release_address(AllocationId=allocation_id)\\n                    results.append(f'Released EIP: {allocation_id}')\\n                except Exception as e:\\n                    results.append(f'Failed EIP {allocation_id}: {str(e)}')\\n                    \\n    return {'status': 'completed', 'details': results}\"\n      }\n    },\n    {\n      \"name\": \"NotifySuccess\",\n      \"action\": \"aws:executeAwsApi\",\n      \"isEnd\": true,\n      \"inputs\": {\n        \"Service\": \"sns\",\n        \"Api\": \"Publish\",\n        \"TopicArn\": \"arn:aws:sns:us-east-1:505679505148:CostManagerAlerts\",\n        \"Message\": \"Cleanup completed for unattached Volumes and EIPs. Check details in Automation execution output.\"\n      }\n    }\n  ]\n}\n<\/code><\/pre>\n\n\n\n<p>Make sure to replace the <strong>REGION:ACCOUNT_ID<\/strong> with our region and account ID<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1069\" height=\"1661\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-28.png\" alt=\"\" class=\"wp-image-3548\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-28.png 1069w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-28-193x300.png 193w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-28-659x1024.png 659w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-28-768x1193.png 768w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-28-989x1536.png 989w\" sizes=\"auto, (max-width: 1069px) 100vw, 1069px\" \/><\/figure>\n\n\n\n<p>The flow diagram on the right side shows us the document works with the following steps:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Step 1-2<\/strong>: Discovers unattached EBS volumes and Elastic IPs <\/li>\n\n\n\n<li><strong>Step 3<\/strong>: Pauses for human approval before deletion <\/li>\n\n\n\n<li><strong>Step 4<\/strong>: Executes cleanup using Python script <\/li>\n\n\n\n<li><strong>Step 5<\/strong>: Sends success notification via SNS<\/li>\n<\/ul>\n\n\n\n<p>Then click <strong>Create Runbook<\/strong>, our CostManager-Cleanup runbook is ready to be used now<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1069\" height=\"609\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-29.png\" alt=\"\" class=\"wp-image-3549\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-29.png 1069w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-29-300x171.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-29-1024x583.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-29-768x438.png 768w\" sizes=\"auto, (max-width: 1069px) 100vw, 1069px\" \/><\/figure>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2: Setup SNS Topic for Notifications<\/h2>\n\n\n\n<p>This will enable email notifications for approval requests and completion status<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to <strong>SNS Console, select Topics, click Create topic<\/strong><\/li>\n\n\n\n<li><strong>Type<\/strong>: Standard <\/li>\n\n\n\n<li><strong>Name<\/strong>: <code>CostManagerAlerts<\/code><\/li>\n\n\n\n<li>Click <strong>Create topic<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1069\" height=\"557\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-30.png\" alt=\"\" class=\"wp-image-3552\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-30.png 1069w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-30-300x156.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-30-1024x534.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-30-768x400.png 768w\" sizes=\"auto, (max-width: 1069px) 100vw, 1069px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Add Email Subscription \u2192 <strong>Create subscription<\/strong><\/li>\n\n\n\n<li><strong>Protocol<\/strong>: Email <\/li>\n\n\n\n<li><strong>Endpoint<\/strong>: Add Email Subscription<\/li>\n\n\n\n<li>Click Create subscription<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"725\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-31-1024x725.png\" alt=\"\" class=\"wp-image-3553\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-31-1024x725.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-31-300x212.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-31-768x544.png 768w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-31.png 1069w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Next, check email inbox and confirm our subscription<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"567\" height=\"271\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-32.png\" alt=\"\" class=\"wp-image-3554\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-32.png 567w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-32-300x143.png 300w\" sizes=\"auto, (max-width: 567px) 100vw, 567px\" \/><\/figure>\n\n\n\n<p>This way, automation will send us an email whenever it needs approval or cleanup completed.<\/p>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3: Setup IAM User for Automation Approval<\/h2>\n\n\n\n<p>We need to create a dedicated user account that can approve cleanup actions during automation execution. Because AWS Systems Manager requires explicit user ARNs for approval workflows, not just email addresses.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to to <strong>IAM Console, <\/strong>select<strong> IAM Users, <\/strong>click<strong> Create user<\/strong> <\/li>\n\n\n\n<li>Name the user: <strong>CostManager-AutomationUser<\/strong> <\/li>\n\n\n\n<li>Enable <strong>Programmatic and Console access<\/strong> (optional). <\/li>\n\n\n\n<li>Select \u201c<em>I want to create an IAM user\u201d<\/em> <\/li>\n\n\n\n<li>Console password: <strong><em>Autogenerated<\/em><\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1059\" height=\"1010\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-33.png\" alt=\"\" class=\"wp-image-3559\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-33.png 1059w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-33-300x286.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-33-1024x977.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-33-768x732.png 768w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click <strong>Next<\/strong> <\/li>\n\n\n\n<li>Select <strong>Attach Policies directly \u2192<\/strong> Attach the following policies:\n<ul class=\"wp-block-list\">\n<li><strong>AmazonEC2FullAccess<\/strong> (for deleting volumes and release IPs)<\/li>\n\n\n\n<li><strong>AmazonSNSFullAccess<\/strong> (for sending notifications)<\/li>\n\n\n\n<li><strong>AmazonSSMFullAccess<\/strong> (for approving automation executions)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1059\" height=\"782\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-34.png\" alt=\"\" class=\"wp-image-3560\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-34.png 1059w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-34-300x222.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-34-1024x756.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-34-768x567.png 768w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Click next for review<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1059\" height=\"841\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-35.png\" alt=\"\" class=\"wp-image-3561\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-35.png 1059w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-35-300x238.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-35-1024x813.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-35-768x610.png 768w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Then click <strong>Create user<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"591\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-36-1024x591.png\" alt=\"\" class=\"wp-image-3562\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-36-1024x591.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-36-300x173.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-36-768x443.png 768w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-36.png 1059w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Please note down the IAM ARN for this user and also the login credentials (can download it in form .csv file)<\/li>\n\n\n\n<li>When executing the automation:\n<ul class=\"wp-block-list\">\n<li>Use this IAM user&#8217;s ARN for the <strong>Approver field<\/strong>.<\/li>\n\n\n\n<li>Log in as this IAM user (not root) to manually approve the request in <strong>Systems Manager \u2192 Automation Executions<\/strong>.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<div style=\"height:40px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4: Setup IAM Role for Automation Execution<\/h2>\n\n\n\n<p>Here we will provide the automation document that we have created at the 1st step with necessary permissions to discover and delete AWS resources. SSM Automation needs temporary AWS credentials to execute the Python cleanup script.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Go to<strong> IAM Console, <\/strong>select<strong> Roles, <\/strong>click<strong> Create Role<\/strong><\/li>\n\n\n\n<li><strong>Trusted entity:<\/strong> AWS Service <\/li>\n\n\n\n<li><strong>Use case:<\/strong> Systems Manager<\/li>\n\n\n\n<li>click Next<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1059\" height=\"1009\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-37.png\" alt=\"\" class=\"wp-image-3563\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-37.png 1059w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-37-300x286.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-37-1024x976.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-37-768x732.png 768w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Attach policies:<\/strong>\n<ul class=\"wp-block-list\">\n<li><strong>AmazonEC2FullAccess<\/strong> (describe\/delete volumes, release EIPs)<\/li>\n\n\n\n<li><strong>AmazonSNSFullAccess<\/strong> (send notifications)<\/li>\n\n\n\n<li><strong>AmazonSSMFullAccess<\/strong> (run automation without permission issues)<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1059\" height=\"595\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-38.png\" alt=\"\" class=\"wp-image-3564\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-38.png 1059w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-38-300x169.png 300w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-38-1024x575.png 1024w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-38-768x432.png 768w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Role name: <\/strong><code>CostManager-AutomationRole<\/code> <\/li>\n\n\n\n<li>Click <strong>Create role<\/strong><\/li>\n<\/ul>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1059\" height=\"1538\" src=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-39.png\" alt=\"\" class=\"wp-image-3565\" srcset=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-39.png 1059w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-39-207x300.png 207w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-39-705x1024.png 705w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-39-768x1115.png 768w, https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/05\/image-39-1058x1536.png 1058w\" sizes=\"auto, (max-width: 1059px) 100vw, 1059px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Important:<\/strong> Copy the Role ARN &#8211; needed for automation execution parameter<\/li>\n<\/ul>\n\n\n\n<p>This role is only assumed by AWS Systems Manager during automation execution, not by users directly<\/p>\n\n\n\n<div style=\"height:20px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><\/li>\n<\/ul>\n\n\n\n<p>In this part we have setup the automation infrastructure along with the IAM user and IAM role that can be used by AWS system manager run the workflow starting from resource detection, deletion approval, and notification sending through email.<\/p>\n\n\n\n<p>In the next part, we will trigger this automation, approve cleanup via the console, and verify the deletion<\/p>\n","protected":false},"excerpt":{"rendered":"<p>We will start automating the resource cleanup by setting up necessary infrastructure such as creating an IAM Role and IAM User for automation access, defining an SSM Automation Document that performs the cleanup actions, and setting up an SNS Topic to notify the users about resources being deleted. These steps ensure the cleanup process has the right permissions, execution logic, and visibility before we actually run it.<\/p>\n","protected":false},"author":1,"featured_media":3611,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,20,85,75,8],"tags":[],"class_list":["post-3528","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aws","category-backend","category-projects","category-system-design","category-technology"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v28.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3 - Ichwan Chandra<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3 - Ichwan Chandra\" \/>\n<meta property=\"og:description\" content=\"We will start automating the resource cleanup by setting up necessary infrastructure such as creating an IAM Role and IAM User for automation access, defining an SSM Automation Document that performs the cleanup actions, and setting up an SNS Topic to notify the users about resources being deleted. These steps ensure the cleanup process has the right permissions, execution logic, and visibility before we actually run it.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/\" \/>\n<meta property=\"og:site_name\" content=\"Ichwan Chandra\" \/>\n<meta property=\"article:published_time\" content=\"2026-05-07T08:49:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-11-02T15:50:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/11\/aws-solutions-architect-project-cost-optimization-part-3.jpeg\" \/>\n\t<meta property=\"og:image:width\" content=\"1376\" \/>\n\t<meta property=\"og:image:height\" content=\"768\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Ichwan Chandra\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Ichwan Chandra\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/\"},\"author\":{\"name\":\"Ichwan Chandra\",\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/#\\\/schema\\\/person\\\/2fa69a7a1008a3369584752194b063d5\"},\"headline\":\"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3\",\"datePublished\":\"2026-05-07T08:49:00+00:00\",\"dateModified\":\"2026-11-02T15:50:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/\"},\"wordCount\":588,\"image\":{\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/aws-solutions-architect-project-cost-optimization-part-3.jpeg\",\"articleSection\":[\"AWS\",\"Backend\",\"Projects\",\"System Design\",\"Technology\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/\",\"url\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/\",\"name\":\"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3 - Ichwan Chandra\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/aws-solutions-architect-project-cost-optimization-part-3.jpeg\",\"datePublished\":\"2026-05-07T08:49:00+00:00\",\"dateModified\":\"2026-11-02T15:50:45+00:00\",\"author\":{\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/#\\\/schema\\\/person\\\/2fa69a7a1008a3369584752194b063d5\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/#primaryimage\",\"url\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/aws-solutions-architect-project-cost-optimization-part-3.jpeg\",\"contentUrl\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/wp-content\\\/uploads\\\/2026\\\/11\\\/aws-solutions-architect-project-cost-optimization-part-3.jpeg\",\"width\":1376,\"height\":768},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/aws-solutions-architect-project-cost-optimization-part-3\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/\",\"name\":\"Ichwan Chandra\",\"description\":\"In a Lifelong Learning Mode\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/#\\\/schema\\\/person\\\/2fa69a7a1008a3369584752194b063d5\",\"name\":\"Ichwan Chandra\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8d8d64c76e361108ee058442df7c49c539eefd1d1e5a3e8dbcc9d70289e0bbf2?s=96&d=retro&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8d8d64c76e361108ee058442df7c49c539eefd1d1e5a3e8dbcc9d70289e0bbf2?s=96&d=retro&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/8d8d64c76e361108ee058442df7c49c539eefd1d1e5a3e8dbcc9d70289e0bbf2?s=96&d=retro&r=g\",\"caption\":\"Ichwan Chandra\"},\"sameAs\":[\"https:\\\/\\\/ichwanchandra.com\\\/blog\"],\"url\":\"https:\\\/\\\/ichwanchandra.com\\\/blog\\\/author\\\/isuchan193\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3 - Ichwan Chandra","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/","og_locale":"en_US","og_type":"article","og_title":"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3 - Ichwan Chandra","og_description":"We will start automating the resource cleanup by setting up necessary infrastructure such as creating an IAM Role and IAM User for automation access, defining an SSM Automation Document that performs the cleanup actions, and setting up an SNS Topic to notify the users about resources being deleted. These steps ensure the cleanup process has the right permissions, execution logic, and visibility before we actually run it.","og_url":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/","og_site_name":"Ichwan Chandra","article_published_time":"2026-05-07T08:49:00+00:00","article_modified_time":"2026-11-02T15:50:45+00:00","og_image":[{"width":1376,"height":768,"url":"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/11\/aws-solutions-architect-project-cost-optimization-part-3.jpeg","type":"image\/jpeg"}],"author":"Ichwan Chandra","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Ichwan Chandra","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/#article","isPartOf":{"@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/"},"author":{"name":"Ichwan Chandra","@id":"https:\/\/ichwanchandra.com\/blog\/#\/schema\/person\/2fa69a7a1008a3369584752194b063d5"},"headline":"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3","datePublished":"2026-05-07T08:49:00+00:00","dateModified":"2026-11-02T15:50:45+00:00","mainEntityOfPage":{"@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/"},"wordCount":588,"image":{"@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/#primaryimage"},"thumbnailUrl":"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/11\/aws-solutions-architect-project-cost-optimization-part-3.jpeg","articleSection":["AWS","Backend","Projects","System Design","Technology"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/","url":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/","name":"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3 - Ichwan Chandra","isPartOf":{"@id":"https:\/\/ichwanchandra.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/#primaryimage"},"image":{"@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/#primaryimage"},"thumbnailUrl":"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/11\/aws-solutions-architect-project-cost-optimization-part-3.jpeg","datePublished":"2026-05-07T08:49:00+00:00","dateModified":"2026-11-02T15:50:45+00:00","author":{"@id":"https:\/\/ichwanchandra.com\/blog\/#\/schema\/person\/2fa69a7a1008a3369584752194b063d5"},"breadcrumb":{"@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/#primaryimage","url":"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/11\/aws-solutions-architect-project-cost-optimization-part-3.jpeg","contentUrl":"https:\/\/ichwanchandra.com\/blog\/wp-content\/uploads\/2026\/11\/aws-solutions-architect-project-cost-optimization-part-3.jpeg","width":1376,"height":768},{"@type":"BreadcrumbList","@id":"https:\/\/ichwanchandra.com\/blog\/aws-solutions-architect-project-cost-optimization-part-3\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/ichwanchandra.com\/blog\/"},{"@type":"ListItem","position":2,"name":"AWS Solutions Architect Project (Cost Optimization Pillar) \u2013 Automated Cost Management \u2013 Part 3"}]},{"@type":"WebSite","@id":"https:\/\/ichwanchandra.com\/blog\/#website","url":"https:\/\/ichwanchandra.com\/blog\/","name":"Ichwan Chandra","description":"In a Lifelong Learning Mode","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/ichwanchandra.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/ichwanchandra.com\/blog\/#\/schema\/person\/2fa69a7a1008a3369584752194b063d5","name":"Ichwan Chandra","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/8d8d64c76e361108ee058442df7c49c539eefd1d1e5a3e8dbcc9d70289e0bbf2?s=96&d=retro&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/8d8d64c76e361108ee058442df7c49c539eefd1d1e5a3e8dbcc9d70289e0bbf2?s=96&d=retro&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/8d8d64c76e361108ee058442df7c49c539eefd1d1e5a3e8dbcc9d70289e0bbf2?s=96&d=retro&r=g","caption":"Ichwan Chandra"},"sameAs":["https:\/\/ichwanchandra.com\/blog"],"url":"https:\/\/ichwanchandra.com\/blog\/author\/isuchan193\/"}]}},"_links":{"self":[{"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/posts\/3528","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/comments?post=3528"}],"version-history":[{"count":14,"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/posts\/3528\/revisions"}],"predecessor-version":[{"id":3589,"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/posts\/3528\/revisions\/3589"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/media\/3611"}],"wp:attachment":[{"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/media?parent=3528"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/categories?post=3528"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ichwanchandra.com\/blog\/wp-json\/wp\/v2\/tags?post=3528"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}