AWS Load Balancer Report
What will I learn? | In this tutorial we will generate a simple load balancer report that shows AWS EC2 Load Balancers in the current account to help us identify Load Balancers with unhealthy targets. |
Difficulty |
What you'll need
Software & Services
- Docker version 16.14 or above
- An AWS User or Role with read-only permissions to list the resources AWS IAM read-only
- An active AWSH from AWSH Intro with some AWS credentials loaded
Permissions & Access
AWS provide an existing ReadOnlyAccess IAM Policy that covers all of the permissions needed for this tutorial. You can simply attach this AWS provided IAM Policy to your existing IAM User, Group or Role
Tutorial
In each of the examples below we will take advantage of several of the environment variables that are loaded and set when we activate a set of credentials in AWSH
env | grep ^AWS_
AWS_ACCOUNT_ALIAS=dummy-account
AWS_DEFAULT_REGION=eu-central-1
AWS_SESSION_EXPIRATION=2022-11-28 16:05:01
AWS_SECRET_ACCESS_KEY=f3hfuss77fffdUToVx+T1iFNV+6tLgL3dUhCJY6jhPccRQW
AWS_ID_NAME=dummy-account/[email protected]
AWS_ACCOUNT_NUMBER=011111221051
AWS_ACCESS_KEY_ID=ASIAQO7RUGABCDEFYXLOK
AWS_TOKEN_EXPIRY=1669651501
We will use these environment variables to generate useful report names. This tutorial also makes use of one of the built-in commands available in AWSH awsh report-ec2-lb
which allows us to generate report and print it to console.
Simple Format Report
Create a simple text summary report of Application Load Balancers
AWSH❯awsh report-ec2-lb -a
Create a simple text summary report of Classic Load Balancers
AWSH❯awsh report-ec2-lb -c
Here is a sample output generated from the load balancer report
Markdown Format Report
Create a markdown summary report of Application Load Balancers
AWSH❯awsh report-ec2-lb -a -f pipe
Create a markdown summary report of Classic Load Balancers
AWSH❯awsh report-ec2-lb -c -f pipe
The Markdown format report is plain text but can be converted into many other common formats (HTML, PDF, MS Word, etc). One of our favourite online converters is https://dillinger.io/ or the extensions available for Microsoft VS Code
HTML Format Report
Create an HTML header for our report
AWSH❯cat > "${HOME}/workspace/${AWS_ACCOUNT_NUMBER}-AWS-EC2-LoadBalancers.html" <<EOF
<html>
<head>
<title>AWS EC2 Load Balancer Summary for A/C: ${AWS_ACCOUNT_NUMBER}</title>
</head>
<body>
<h1>AWS EC2 Load Balancer Summary for A/C: ${AWS_ACCOUNT_NUMBER}</h1>
<p>
This EC2 Load Balancer report was generated using AWSH on $(date)
for AWS Account ${AWS_ACCOUNT_NUMBER} with alias: ${AWS_ACCOUNT_ALIAS}
</p>
<div>
EOFCreate a HTML summary report of Application Load Balancers
AWSH❯awsh report-ec2-lb -a -f html >> "${HOME}/workspace/${AWS_ACCOUNT_NUMBER}-AWS-EC2-LoadBalancers.html"
Create a HTML summary report of Classic Load Balancers
AWSH❯awsh report-ec2-lb -c -f html >> "${HOME}/workspace/${AWS_ACCOUNT_NUMBER}-AWS-EC2-LoadBalancers.html"
Add the HTML page footer to make a valid HTML page
AWSH❯echo "</div></body></html>" >> "${HOME}/workspace/${AWS_ACCOUNT_NUMBER}-AWS-EC2-LoadBalancers.html"
Now that you've had a look around why not check out the full documentation here.
At Hestio, we have taken our experience with designing and building on cloud to codify these patterns and made them available as a low-code pattern library for AWS. Why spend time and effort on reinventing the wheel when it's already a solved problem? Would you start developing office productivity software in a world where Microsoft Office already exists?
If you'd like to find out about worX, our low-code patterns library for AWS you can read more here or get in touch today to schedule a demo.
If you'd like to find out more about the products and services Hestio has to offer, select one of the options below.