0

I have created an AMI from an Instance with the user data

#!/bin/bash
yum update -y
yum install httpd -y
systemctl enable httpd
systemctl start httpd

which starts the Apache server, within I have a index page where Instance details are stored so when I visit the webpage via the Instance IP address it will display this info which it has done so I created an AMI from that Instance and then created a Launch Configuration, Load Balancer and ASG with it attached along with my VPC and public subnets.

I am working towards where it will be a managed Load balancing auto scaling web app that launches Instances based on my Metric which it does but the problem is the 'User Data' is not displaying when new instances are launched and it does not let me connect via the IP Address.

I also have a CPU script that will run my CPU Utilization on my Instance at 100% so it will trigger my metric of if it goes above 60% it will launch new instances every minute or so and i'm also wondering how would I see the load distributed between these Instances to make sure it is distributing equally to all separate Availability Zones? Would there be a log?

Marcin
  • 215,873
  • 14
  • 235
  • 294
HmNoon
  • 21
  • 8
  • Your userdata does not generate any index page with ip? How it is obtained? What is its source code? If this is custom AMI, why do you have this userdata? Your custom ami does not have apache setup? – Marcin Jul 30 '21 at 01:04
  • No but it doesn't display when a Instance is launched which doesn't even allow me to connect or view the web page with them details. After launching an Instance with the User data, SSHing into that Instance via ec2-user@ and inputting the details into /var/www/html/index.html I then created an AMI from that version of the Instance which each Instance created from the Metric of CPU going over 60% would launch another Instance with these saved configurations? Also still unsure how to see if load is distributed equally across Instance – HmNoon Jul 30 '21 at 01:20
  • Does your website show if you `curl localhost` from the instance? – Marcin Jul 30 '21 at 01:39
  • It doesn't allow me to SSH into the Instance to try nor connect via the AWS EC2 Instances so how would I check? Shouldnt the AMI I created from the Instance save the 'User Data' I inputted to that Instance and load it with no problems when launched from the ASG? – HmNoon Jul 31 '21 at 18:06
  • @Marcin I found that the problem was it would only load normally if it was under AZ eu-west-1a and no other availability zones, I think this is to do with when I created the AMI of the Instance it was under eu-west-1a but I have a VPC with 3 subnets that should distribute traffic evenly between them so how would I go abouts attaching all 3 Availability Zones instead of just 1? – HmNoon Jul 31 '21 at 22:25
  • You just attach the missing AZs to your ALB. Did you try that? – Marcin Aug 19 '21 at 00:45

0 Answers0