logo
Menu

Detect and remediate cost waste | S02 E29 | Build On Weekly

This week, Rohini and Darko are joined by Steph, as we look at a way to detect potential unwanted costs and remediate them.We did this using AWS Config and some AWS Systems Manager magic

Darko Mesaros
Darko Mesaros
Amazon Employee
Rohini Gaonkar
Rohini Gaonkar
Amazon Employee
Published Sep 21, 2023

Screenshot of the AWS Config Dashboard showing non-compliant resources
This is what success looks like

It is very important to be aware of your costs when running workloads in the cloud. Do you know if you have any lingering resources (unused Elastic IPs, detached EBS volumes) that are causing you unwanted cots? 🤔 Well, today we have Steph joining us and demonstrating how we can fix all this using AWS Config and AWS Systems Manager Automation.

We ended up not being able to fix it on stream, BUT, Darko did spend some time and made it work at the end. And here is how it works now:

Alright, the issue we had is that we were not able to pass the SSM Automation document the correct parameters and execute the automation. After some time spent searching online and looking at other options in the SSM Automation documentation, we've realized that the solution is to use a different action type.

Instead of using aws:executeAwsApi, the better option was just to use aws:createTags, as that is what we actually wanted! 🥳 This simple change has made it possible to create a new automation document that has the following contents:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
description: |-
This automation document tags Unused Elastic IPs so we can track them.
schemaVersion: '0.3'
assumeRole: '{{AutomationAssumeRole}}'
parameters:
Resources:
type: StringList
description: (Required) The allocation IDs of the Elastic IP Addresses to be tagged.
AutomationAssumeRole:
type: String
description: The role that allows Automation to execute the actions on your behalf.
Tags:
type: MapList
description: 'Tags to apply to the elastic IP addresses. Enter in teh following format: {"Key":"COST_ALERT","Value":"UnusedEip"}'
mainSteps:
- name: 'TagElasticIP'
action: 'aws:createTags'
inputs:
ResourceType: EC2
Tags: '{{Tags}}'
ResourceIds: '{{Resources}}'

Then - to pass it the Tags parameter we use the following format: {"Key":"COST_ALERT","Value":"UnusedEip"}. Huzzah!

If you wish to see this in action, check out the addendum video here:

Check out the full stream recording here:

Reach out to the hosts and guests: