DEV Community

sosmation
sosmation

Posted on

why you are unable to manage load and scale using EC2 in AWS

There are a number of services that take the hustle of managing computation resources examples are AWS fargate for serverless container, AWS lambda for general serverless purpose compute. They provide a "safe bet" to the customer with minimal configuration.
There cases that may demand setting up bit and pieces by using self managed services like EC2 instances, setting up load balancers and auto scaling groups to suit a desired resource balance. This is after numerous tests have been conducted by the team.
But with all that covered there are a number of issues that may arise even after having done numerous tests, they arise from a number of reasons:

AMI issues

An AMI is a pre-configured template that runs in an Ec2-instance. It contains the operating system, files and packages needed to configure and kickstart the application environment.
This are pegged to an elastic block device and mapped to an instance with the launch permissions. The AMI may exhibit a number of issues

  • An invalid device name This is caused when attaching the elastic block storage to an instance without a valid device name for the volume

*- The architect of the AMI does not march with the instance
*

Architecture conflicting with an instance prevents the Amazon auto scaling from launching new instances due to the incompatibility error.

*- Instance launching failed due to an AMI that is disabled
*

**- An AMI ID does not exist
It may occur when AMI may be deleted after creating the launch template or launch configuration.

**This may arise from the AMI not being available due to it being deleted

This are some of issues that affect the loading of EC2 instances on the instance level. for more comprehensive list visit

Here is a length documentation on AMI issues with solutions

Load balancer issues

A load balancer is a tool use to distribute traffic to instances, this varies based on one's configured settings. The auto scaling group works with the load balancer to trigger the creation of new instances, sometimes there are huddles that arise when using the services.

**- A load balancer cannot be found
**This occurs when an auto scaling group fails validating an elastic load balancer when launching a new instance

**- Target group(s) not found, the load balancer fails to validate
**This may arise from a target group attached from the Auto scaling group having been deleted.

- No active load balancer Available

It arises from the specified load balancer might have been deleted or cannot be located. You can tackle with this issue by either deleting your load balancer associated with the instance or create a new Auto Scaling group.
Here is a length documentation on load balancer issues and how to solve them

** instance launch failures**

Below are some of the reasons that prevent an instance from launching from an auto scaling group.

- Mismatch between the launch template / configuration and the instance type
**
**- A security group does not exist

This may come from the security group being deleted.
To solve this

  1. retrieve a list of the security groups using the AWS cli command from
  2. select the security group to use from the list.
  3. create a new launch template or launch configuration. 4.Update the new auto scaling group by using the aws cli

- Key pair types associated to an instance are unavailable
This may arise from the key pairs not being located, they might have been deleted.
To solve this:

  1. Retrieve the list of key pairs through the AWS cli, here is a link to guide
  2. Select a key pair from the list, one can also create a new one of choice. 3.Create a new launch template or launch configuration. 4.Update the new auto scaling group by using the aws cli

*- An invalid block device that might not be available or is not supported during an instance launch
*

*- An elastic block device isn't supported by the Instance store-AMIs
*

for a comprehensive list visit

Here is a length documentation on instance launch failure

launch Template issues

An instance launch template consist of versions and configurations used when launching an Ec2 instance, this is essential in cases where a certain set of standards are need to spin on even types of instances.

*- you must have a valid fully-formed launch template
*

This error may occur due to the amazon ec2 auto scaling to detect an issue with the launch template, it is caused by a number of issues.

it can be resolved by

  1. Noting the specificity at the end of the error flag i.e You must use a valid fully-formed launch template error this will direct one on addressing the issue.

  2. When unable to located the issue you can dry run some commands to assist you get insights on what might be the issue.

  3. Address information that is missing by verifying the settings, re-adjusting the launch template to the desired fit.

  4. Ensure necessary resources are accessible by the launch template, for example Amazon key pair are in the same account and region.

  5. Dry run the commands in step two to verify that your launch template uses valid values.

NB: here is a link to the AWS command line with commands for instances troubleshooting.

AWS provides a comprehensive documentation covering launch template issues

**- you are not authorized to use launch template
**This error stems from a lack of sufficient permissions, mainly the IAM policies assigned to user, group or role.
it may also arise from using a private AMI that is account specific.

In this particular case one case use the steps below to solve the issue

  1. Ensure that the IAM credentials used have the correct iam:PassRole permission role specified to the Amazon EC2 Auto Scaling service. Below is a link with a detailed lead and examples of IAM policies for EC2 and how to troubleshoot
  • You must use a valid fully-formed launch template This error may arise because the values in the template are only validated when an auto scaling that is using the launch template is created or updated.

Conclusion

AWS provides mechanisms to assist you the consumer, even with that covered the AWS has a guideline on share responsibility providing a blueprint on the cohesiveness when using the platform

This article is published by sospeter Muchiri

Top comments (0)