Amazon Web Services - Using an existing EC2 instance as Beanstalk environment - amazon-web-services

I'm new to AWS, and I want to deploy a web application on an EC2 instance,
So far I've tried Elastic Beanstalk, but AWS always requires me to create a new Environment for the application instead of letting me choose an existing EC2 instance that I've created before.
Actually my main purpose is to set a policy group that allow HTTPS access, and idk how to set it to the "Environment" instance.
Any help is greatly welcome. :)

That is not currently viable, as you'd need to set up an AMI based on your instance and use a custom AMI for beanstalk, and that is not a trivial task. If you need to run a custom environment in Elastic Beanstalk, using Docker would be much easier.
But none of that is required to set a security group allowing HTTPS, you can configure security groups and HTTP/s listeners for ELBs on you Environment configuration.

Related

Change Elastic Beanstalk environment from Launch Configuration to Launch Template

The Elastic Beanstalk docs say:
Web server environments have ... one of the following two resources.
AWSEBAutoScalingLaunchConfiguration (AWS::AutoScaling::LaunchConfiguration) – The launch configuration attached to your environment's Auto Scaling group.
AWSEBEC2LaunchTemplate (AWS::EC2::LaunchTemplate) – The Amazon EC2 launch template used by your environment's Auto Scaling group.
AWS is in the process of deprecating Launch Configurations, as Launch Templates are strictly more featured. In particular, AWS has sent a notice to customers saying:
After December 31, 2022 no new Amazon Elastic Compute Cloud (Amazon EC2) instance types will be added to launch configurations.
How do I convert an Elastic Beanstalk environment that is currently using a Launch Configuration to use a Launch Template instead?
I have contacted AWS support about this issue. As of December 31 2022 AWS will deprecate launch configurations. So we have to use launch templates instead of launch configurations. And this is their response.
Firstly, the current guidance is that no action will be needed on your
end regarding the launch configuration deprecation. Beanstalk will use
launch configurations when needed, and will automatically use launch
templates for new instances and newer features as needed. However, I
will be sure to update you if this guidance changes.
However, if you wish to change your Elastic Beanstalk environments to
make use of launch templates instead of a launch configuration, I
suggest to enable the 'Disable IMDSv1' option in your EB environments
configuration [2]. IMDS is instance metadata service and is used by
code to access instance metadata. Disabling IMDSv1 requires using
Amazon EC2 launch templates. When you configure this feature during
environment creation or updates, Elastic Beanstalk attempts to
configure your environment to use Amazon EC2 launch templates (if the
environment isn't using them already).If you have custom scripts which
communicates with the IMDSv1 endpoint, then you will need to ensure
those are migrated to the newer IMDSv2 [3].
Additionally, please note that this may introduce some downtime while
the configuration changes are being applied to the environment. I
recommend creating a new environment and performing a Blue/Green
deployment [4] to minimize this potential downtime. Please test this
is in your non production and proceed to production based on the
results in non-production.
Please refer the provided documentation and let me know if you need
any help.
References:
[1] Managing environments - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.html
[2] Configuring IMDS using the Elastic Beanstalk console - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/environments-cfg-ec2-imds.html#environments-cfg-ec2-imds.console
[3] IMDSv2 - https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/configuring-instance-metadata-service.html
[4] Blue/Green deployments with Elastic Beanstalk - https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.CNAMESwap.html
I was in this exact position. I connected with AWS support and the answer I received is that launch configurations being used in Elastic beanstalk apps will be migrated automatically behind the scenes. So if your only launch configurations are generated as part of an elastic beanstalk then you have nothing to do, and the notice only applies to configurations created outside of Elastic Beanstalk.

AWS beanstalk EC2 instance within a VPC and without Load Balancing

I am creating the first betas of a project. I need a SpringBoot server connecting to MongoDBs in AWS.
MongoDB is already deployed as a replicaset in different EC2 instances. I was exploring AWS Beanstalk as environment to deploy the SpringBoot. However I am not yet ready to deploy a Load Balancer, because is costly.
I am looking for the way to deploy a Single-Instance Environment (https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features-managing-env-types.html?ref_=pe_395030_31184250_9#single-instance-environ) in a VPC (which would be shared with MongoDB).
Does AWS Beanstalk allows you to configure a EC2 instance within an VPC but without Load Balancer?
If not, I am planning to deploy an EC2 instance in the VPC myself without Beanstalk.
Other temporary solution would be accessing MongoDB over the internet, with the right security group rules, but i do not think is a good practice at all, so I am not considering it.
All Elastic Beanstalk environments are in a VPC, unless you have a really old AWS account that still supports EC2 classic. What you are looking for is the EB Single-Instance Environment type.

AWS Elastic Beanstalk: Steps to move existing RDS from db.t1.micro to db.t2.small

I'm new to AWS and having a web server environment on elastic beanstalk with EC2 (t1.micro) with RDS (db.t1.micro). Now the db.t1.micro instance is deprecated, no more new instance can be created and no support in near future.
I would be helpful if anybody refers me steps to do create the t2 clone of the machine and switch over (Or) how to handle the depreciation of the instance.
Change Instance Type: You can change the Instance type by following the AWS documentation here
Next, Creating RDS instance in the Elastic Beanstalk environment is not ideal for production environments, because the lifecycle of the database instance is tied to the lifecycle of your application's environment. Hence it is always recommended to create RDS instance outside of the Elastic Beanstalk environment and configure your Elastic Beanstalk application to connect it on launch, which will provide the benefits of performing blue/green deployments, and tear down your Beanstalk environment without affecting the database instance. Refer to the documentation here to know more information.
For now, if you would like to modify the RDS instance type, you can do so by going to the RDS section in Configuration tab.
I have created a new Elastic Beanstalk environment with the source of the "db.t1.micro" snapshot, within the VPC. This helped me to launch the clone. Once this is done I have to swap the cname with the t1 and t2 setup. The new instance is up and running with t2 configuration.

Will existing EC2 instances be unaffected if I create an autoscalling solution with Elastic Beanstalk?

Maybe it is a simple question, but I want to be sure anyway.
We already have a simple architecture with one Amazon EC2 instance and are planning to scale to architecture with load balancing, multiple autoscaling EC2 instances, and separate RDS.
If I create such a configuration with Elastic Beanstalk, will the existing EC2 instance at the same account stay untouched and working?
Elastic Beanstalk will only modify the instances, autoscaling groups it creates as part of environment creation. If you already have instances running in your account they should not be affected by simply using Elastic Beanstalk to launch new instances.
Make sure you do not share those resources with your new environment. e.g. If you have an existing RDS and you access that RDS from your application on the newly launched instances by beanstalk, then it goes without saying that the state of the RDS can be modified by your application. Likewise if you use preexisting security groups then you are sharing state between your existing resources and your beanstalk environment and should be avoided.
But just launching a new beanstalk environment, deploying your application there will keep the existing instances in your account untouched.

Amazon Elastic Beanstalk: Can multiple applications share a single Amazon RDS database instance?

When creating an application in Amazon Elastic Beanstalk, you have the option of creating a new Amazon RDS database instance. Is it possible to associate an existing RDS database instance with an Elastic Beanstalk application?
If you want to share an RDS instance between multiple applications, the best thing to do is set that up independent of your beanstalk application.
Set up privs for each application and configure each application to use the RDS instance.
You will probably have to manually configure your application security group to access the database instance.
I was facing same issue and fixed using following steps :
1) Go to EC2 instance and note your security group example "sg-121212121212"
2) Go to RDS Security Group ad=nd inbound traffic
3) Edit rule select all traffic and add your new ebs security group "sg-121212121212"
Hope it will helpful
A single database can only be used with one Elastic Beanstalk environment. Although, it can be moved between environments.
Also important to remember that a clone operation doesn't clone the database.