Special Issues solutions - SeshuVarma/websys GitHub Wiki

Special ISSUE 1 - what happens when an instance stops running??

To prevent re-setup for our environment and data. We can create our own AMI.

Just right click on your running EC2 instance, and attend “Image” -> ”Create Image”.Notice that, your EC2 instance is going to be shut down during the image creation process.

After a few minutes, your AMI is prepared to place it into use. Click on “Image” => “AMIs”

You can see your just created AMI is there.

To configure a replacement EC2 instance press "Launch". This instance can be added to the existing security group. Now we can access this instance through the ssh terminal after a few minutes setting up the instance. Please log in and verify After several minutes for setting up a new instance. We are free to access that instance through the ssh terminal. Let’s log in and check.

sudo service docker start And then, run the rails service directly,

sudo docker run -it -p 3000:3000 rojabalakrishnan/photosite_railapp And let’s check to EC2-IP:3000. Yeah! It’s working! Now, you are free to turn off any EC2 instance if you like!.

Uploading EC2 Instance to S3 bucket

  • S3 bucket needs to be created in the same AWS Region the EC2 instance is running.

  • "vmimport" IAM role needs to be created with a trust policy trust-policy.json that further allows the VM import service to assume the role.

  • "vmimport" IAM policy should now be attached to the IAM role to grant permissions.

  • Upload the image to S3 bucket

  • Run the AWS CLI command import-image from the client machine

  • Run the AWS CLI command describe-import-image-tasks to check the import task status

  • After the image is imported as an AMI, follow the instructions for Launching Your Instance from an AMI.

Special ISSUE 2 - what happens when you reboot an instance and what can you do?

Option - Use Elastic IP

Go to EC2 console, Press on the Elastic IPs.

And press Allocate elastic Ip addresses. Right-click on that address item, and select Associate elastic Ip address. So now the instance can be chosen to set up it with IP address

The instance is now binded with a “static” IP address. This can stop/restart at any time without changing our public IP address.

Elasticbeanstalk vs Ec2

  • EC2 is a service that allows us to provision the VPC's whereas Elastic Beanstalk is an abstraction layer that provides certain features on top of EC2
  • In EC2 user has full control over the machine and hence need to take care of setting up security groups and load balancer whereas in Elastic Beanstalk all this comes as automated and the user just need to focus on the application rather the infrastructure.
  • If you need more details on the implementation please refer to the below links which I used as a reference. Reference

End