Https on Elastic Beanstalk Without Load Balancer - amazon-web-services

I would like to decrease my AWS bill and deactivate load balancing on some of my elastic beanstalk applications.
I managed to setup https through AWS Certificate Manager with the free Amazon issued certificates.
When I remove the load balancing, I don't have the option to setup the SSL certificate. Any ways to add it somewhere else, like from the EC2 instant linked to EBS?
Thanks for your help,

You can't use ACM certificates without either a load balancer or a CloudFront distribution. If you don't have either of those, you will need to obtain an SSL certificate through some other means, and install it on your web server software running on the EC2 instance.

Related

Multiple SSL Certificates on Elastic Beanstalk ALB

Is it possible to link more than 1 SSL certificate to an Elastic Beanstalk ALB?
I understand that one can create a bundle domain certificate in Certificate Manager, but I would ultimately want to give my clients the ability to add their own domain pointers pointing to the EB environment.
Yes, you can do this. Probably not from EB console, but you can deploy multiple SSL certs on ALB as explained in:
Application Load Balancers Now Support Multiple TLS Certificates With Smart Selection Using SNI
You would have to go to EC2 console -> Load balancers, and work with the ALB there. Obviously you could do the same things using AWS CLI or SDK if you want to automate things.

Installing SSL on EC2 as well as load balancer

I have an ec2 instance behind Application ELB in AWS. I want to apply SSL to both ec2 instance as well as loadbalancer. For ec2 instance i have purchased ssl and installed it and it is working fine. For load balancer i will be using the free AWS ACM certificate and installing it on load balancer. Will this have any issues? i.e. installing SSL on both places ec2 and elb.
It will not have any issues but it does come with a caveat. The traffic in to the Application Load Balancer (ALB) will be encrypted and the ACM cert will be validated by the client. The traffic to the host from the ALB will also be encrypted but the certificate on the host will not be validated.
It looks like ALB Backend Authentication is on AWS's roadmap per the reference below. The reason given for it not being a priority is summarized in this quote from the AWS Engineer who wrote the first reference:
The role that server certificates play in TLS is to authenticate the server, so that it can’t be impersonated or MITM. ALBs run exclusively on our Amazon VPC network, a Software Defined Network where we encapsulate and authenticate traffic at the packet level.
The upside of this is you can use self-signed certs on your hosts to save money when using an ALB or ELB in front of them.
If you need to ensure the certificate on the host is valid you can use a Classic Elastic Load Balancer (ELB). See the reference for more details.
References
AWS ALB Validation TLS Reply
AWS ELB Configure Backend Authentication
If you use SSl/TSL at ELB, it will handle the encryption/decryption of the HTTPS connections (freeing your EC2 instance's CPU to do other work).
If you use an HTTPS/SSL connection for your back end, you can enable authentication on the back-end instance. This authentication can be used to ensure that back-end instances accept only encrypted communication, and to ensure that the back-end instance has the correct certificates.
Using SSL/TLS on both ELB and Backend can create problems since ELB HTTPS listener does not support Client-Side SSL certificates.
I have considered that you are using a 2-way SSL (Mutual or Client Authentication)

AWS Certificate Manager Certificate is not visible to AWS Beanstalk from Console

I am new to AWS and need help to select the AWS Certificate Manager provisioned Certificate from Elastic Beanstalk Loadbalancer using AWS Console.
Deployed my Java application on Linux instance using Elastic
Beanstalk and that worked fine with Http.
Provisioned a new wildcard certificate using AWS Certificate Manager.
Under Elastic Beanstalk Configuration - Network Tier - Load Balancing Settings gear Icon, I changed "Secure listener port" = 443 and "Protocol" =
HTTPS.
But the "SSL Certificate ID" does not list the certificate to pick.
Please suggest what is that I am missing here.
I have read many suggestions to do by CLI but I am not an CLI expert and wanted to use the console feature for simplicity.
EDIT-1:
I can see the certificate under EC2 - Load Balancer - Listener TAB if I try to add HTTPS, but not under Beanstalk. I am not sure if I shall add this listener under EC2 or not, but I think I need to add SSL to Beanstalk as My application get deployed using Beanstalk into EC2.
This will happen if you created your SSL Certificate on a different Region to your Elastic Beanstalk instance. An easy gotcha!
To setup a SSL certificate for your Elastic Beanstalk environment, please see Configuring Your Elastic Beanstalk Environment's Load Balancer to Terminate HTTPS
There is a console setup step as you describe in step 3, so that looks good. Also note you need to update the EB configuration as shown in the above document.
From AWS documentation:
For Classic Load Balancer and Application Load Balancer, if the
drop-down menu doesn't show any certificates, you should create or
upload a certificate for your custom domain name in AWS Certificate
Manager (ACM) (preferred). Alternatively, upload a certificate to IAM
with the AWS CLI.
I guess AWS CLI with IAM must be used as described here

Configure SSL certificate by ACM on single instance tomcat on AWS

I have created a single instance web application on AWS with Elastic Beanstalk. Now I want to add ssl certificate to enable https access on it.
I created a ssl certificate using ACM and I was folowing this! link to add it to my web app in Elastic Beanstalk.
But I could not find and anywhere in acm.
How can i find them??
You can only use ACM with CloudFront or Elastic Load Balancers. Since you don't have an Elastic Load Balancer in a single instance Elastic Beanstalk environment, you can't use ACM, unless you want to put CloudFront in front of it.

How to add SSL certificate to AWS EC2 with the help of new AWS Certificate Manager service

AWS has come up with a new service AWS Certificate Manager. One thing I got from the description is that if we are using this service we don't have to pay for the certificate anymore.
They are providing certificates for Elastic Load Balancer (ELB) and CloudFront, but I didn't find EC2 anywhere.
Is there any way to use the certificate with EC2?
Q: Can I use certificates on Amazon EC2 instances or on my own servers?
No. At this time, certificates provided by ACM can only be used with specific AWS services.
Q: With which AWS services can I use certificates provided by ACM?
You can use ACM with the following AWS services:
• Elastic Load Balancing
• Amazon CloudFront
• AWS Elastic Beanstalk
• Amazon API Gateway
https://aws.amazon.com/certificate-manager/faqs/
You can't install the certificates created by Amazon Certificate Manager (ACM) on resources you have direct low-level access to, like EC2 or servers outside of AWS, because you aren't provided with access to the private keys. These certs can only be deployed on resources managed by the AWS infrastructure -- ELB and CloudFront -- because the AWS infrastructure holds the only copies of the private keys for the certificates that it generates, and maintains them under tight security with auditable internal access controls.
You'd have to have your EC2 machines listening behind CloudFront or ELB (or both, cascaded, would also work) in order to use these certs for content coming from EC2... because you can't install these certs directly on EC2 machines.
No, you cannot use aws certificate manager for deploying certs on EC2. The certificate manager certs can only be deployed against cloudfront and elastic load balancer. Inoredr to use it on ec2, you need to put elb on top of ec2, so that request from client to load balancer will be https protected and from elb to ec2 webserver will be on http.
If you are using AWS ACM Cert for internal purpose only then you could probably use AWS ACM Private CA to issue the certs.(I think you can use it for public/external traffic purpose as well if your root CA is publicly trusted CA).
https://docs.aws.amazon.com/acm-pca/latest/userguide/PcaGetStarted.html
During Application/EC2/Container startup, set a step to export your ACM Private CA issued Cert/Private Key to your destination and start referring that for serving the traffic.
https://docs.aws.amazon.com/cli/latest/reference/acm/export-certificate.html
One good thing is, you can control who can call export cert feature using IAM Role so not everyone can download private key of the cert.
One downside with this is, private CA is expensive AWS service($400/month).
https://aws.amazon.com/certificate-manager/pricing/
Adding to the comments above, you can't use the AWS Certificate Manager for this, but you can add a Let's Encrypt certificate to ec2 on a Windows server running IIS and it's pretty easy:
Associate an elastic ip with your ec2 instance.
Make sure you have a registered domain. You can't use ec2----------.us-east-1.compute.amazonaws.com type names that come with your instance.
Through your domain provider's DNS settings have your domain point to your Elastic IP.
Connect to your ec2 instance and add your domain name to the site bindings.
Go to https://github.com/PKISharp/win-acme/releases
Look under assets, and use the latest version (win-acme.v2.0.10.444.zip for example). This is the only assets folder that you need.
Unzip the folder, open the terminal as administrator, and cd into the unzipped folder.
Run wacs.exe and follow the prompts.
Make sure the security group assigned to your instance allows traffic (at the very least your own IP) through the HTTPS port you chose in IIS; this is port 443 by default.
I found the links below helpful when I was figuring this out. Here is a video using an earlier release if you need more help, but it's the same idea.
https://www.youtube.com/watch?v=fq5OUOjumuM
Also this article might be helpful:
https://weblog.west-wind.com/posts/2016/feb/22/using-lets-encrypt-with-iis-on-windows