Enable "Ignore load balancer 4xx errors" health rule on AWS Elastic Beanstalk using .ebextensions
I love the web ๐ธ
I also write about personal finance in Spanish at https://perrodinero.blog
Search for a command to run...
I love the web ๐ธ
I also write about personal finance in Spanish at https://perrodinero.blog
No comments yet. Be the first to comment.
I've been wanting to learn Rails since ages ago, but, you know, life was getting in the way (or me, rather). A couple of weeks ago I decided to start a side-project related to another side-project. Sounds like an entry for a GitHub Graveyard, I know....
Sometimes we only need a font for a couple of words, like a logo or slogan. Why do we download the whole font file if we only need a few letters? In this post, I'll show you how you can reduce your font file size by more than 80%. This size reduction...

Queues are a natural phenomenon in everyday life. You queue to buy food, to pay in the supermarket, or to get on a plane. But queues are also used in software to handle heavy processes. A queue can help devs like me and you store a request for later ...

Software development is hard. Time zones are hard. Dealing with time zones in software development? Yeah, harder. Here are 4 places where time zones might differ; and 4 personal bug stories for each case. I'll be referring to the same app for each s...

I started the #100DaysOfCode challenge on March 21st and finished it today, August 7th. FINALLY! ๐ฅณ And yeah, that's way more than 100 days ๐ For those who don't know, the #100DaysOfCode challenge consists of coding at least one hour every day for t...
If you are an Elastic Beanstalk (EB) user, you are probably aware of a frequently requested feature that was released on July 25, 2018: To ignore application 4xx errors when determining your environment's health. It's was a new EB health rule that ignores 400-499 HTTP status codes when alerting if your environment instances are having trouble ๐ฅ.
It is common for applications to receive many 4xx errors, for example, due to:
I started to use this feature since the moment it was released.
Today I logged in into my EB console and switched the design to the latest version of the console. Everything okay. Then, as I was exploring the new console, I noticed a new configuration that was not previously available: To ignore load balancer 4xx errors.
In this post, I will show you, through a story, how to enable this feature using .ebextensions, because, infrastructure-as-code, you know ๐ค. The funny part, I can't seem to find the documentation anywhere on AWS. Never happened before, right? ๐.
Follow along!
The first thing I do when trying to configure this new feature is: go to the docs page where the almost identical feature is documented, that is, the ignore application 4xx errors. I found that is the same page as it was before, with no extra information about a load balancer health rule. Citing the docs:
Currently, this is the only available enhanced heath rule customization. You can't configure enhanced health to ignore HTTP errors returned by an environment's load balancer, or other HTTP errors in addition to 4xx.
Liars! Just kidding ๐
Without luck on this doc page, I proceeded to look somewhere else:
I had already searched through a lot of docs without any progress. I posted the question on Twitter and StackOverflow, and I wasn't expecting any response soon. I thought about trying to guess the new field names and do a try-error session.
My current configuration document looks like this:
{
"Rules": {
"Environment": {
"Application": {
"ApplicationRequests4xx": {
"Enabled": false
}
}
}
},
"Version": 1
}
If I were the software developer that created this feature, how would I call the new field? Some options:
But, should they be nested under "Application" or should it be another high-level field? By this time I was already hungry, so I went to cook and eat ๐จ๐ปโ๐ณ๐ฒ
Taking a break helps, you should consider it in your daily routine. Back to the topic...
I realized that even though I can't find a way to configure this feature through code, I can do it directly in the console. This would only be temporary because the environments re-create themselves on each deploy- any new environment would have this feature disabled.
And here is where I got an idea๐ก What if I:
That's exactly what I did. Once the configuration was saved, I retrieved it:
$ eb config get NAME_OF_MY_CONFIGURATION
and ๐ฅ, the configuration showed itself:
{
"Rules": {
"Environment": {
"ELB": {
"ELBRequests4xx": {
"Enabled": false
}
},
"Application": {
"ApplicationRequests4xx": {
"Enabled": false
}
}
}
}
}
There was a high-level field called "ELB", and a property "ELBRequests4XX"; I was not that erred ๐จ๐ปโ๐ป.
I added those new fields to my .config file on the .ebextensions folder and everything worked as expected ๐๐ผ Here is the final .config file I used:
option_settings:
- namespace: aws:elasticbeanstalk:healthreporting:system
option_name: ConfigDocument
value: {
"Rules": {
"Environment": {
"ELB": {
"ELBRequests4xx": {
"Enabled": false
}
},
"Application": {
"ApplicationRequests4xx": {
"Enabled": false
}
}
}
},
"Version": 1
}
I can't imagine how complex is to add a feature to a system as big as AWS while maintaining all the docs updated. I don't blame them.
Nonetheless, we figured out at the end ๐๐ผ. In short, to configure your EB environments to ignore load balancer 4xx errors, you need to add the previous .config file to your .ebextensions folder and deploy a new version.
Maybe the docs are updated by the time you read this, and the story will not be that fun ๐ Anyhow, it was a blast to write.
I hope you enjoyed it. Thanks for reading me ๐