Autoscaling Groups With Terraform on AWS Part 2: Instance Security Group and Boot Script
In this post, we shall add a security group to the autoscaling group and an http server to serve the requests.
Join the DZone community and get the full member experience.Join For Free
Previously, we followed the minimum steps required in order to spin up an autoscaling group in Terraform. In this post, we shall add a security group to the autoscaling group and an http server to serve the requests.
Using our base configuration we shall create the security group for the instances.
Our instances shall spin up a server listening at port 8080 thus the security port shall allow ingress traffic to that port. Pay attention to the egress. We shall access resources from the internet thus we want to be able to download em.
Then we will just set the security group at the launch configuration.
Now it’s time to spin up a server on those instances. The aws_launch_configuration gives us the option to specify the startup script (user data on aws ec2). I shall use the Apache Ignite server and its http interface.
And now we are ready to spin up the autoscaling as shown previously.
We successfully added an instance security group and a bootstrap script. The next challenge is to add some load balancing and health checks.
Published at DZone with permission of Emmanouil Gkatziouras, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.