How to public access of Elastic vpc endpoint - amazon-web-services

I have create elastic service in AWS with Dev Testing(t2 small)
Detials shown below
VPCvpc-7620c30b
Security Groups
sg-7e9b1759
IAM RoleAWSServiceRoleForAmazonElasticsearchService
AZs and Subnets
us-east-1e: subnet-2f100a11
How to access my VPC endpoint https://vpc-xxx.us-east-1.es.amazonaws.com access from outside.
Kibana is below : https://vpc-xx.us-east-1.es.amazonaws.com/_plugin/kibana/
I am not running on Ec2 instance

From docs:
To access the default installation of Kibana for a domain that resides within a VPC, users must have access to the VPC. This process varies by network configuration, but likely involves connecting to a VPN or managed network or using a proxy server.
One way of setting up the proxy server has been explained in detail in the recent AWS blog post:
How do I use an NGINX proxy to access Kibana from outside a VPC that's using Amazon Cognito authentication?
The instruction could also be adapted to not using Congnito.
Extra links, with other, probably easier setup with ssh tunnels:
How to connect to AWS Elasticsearch cluster from outside of the VPC
How To: Access Your AWS VPC-based Elasticsearch Cluster Locally
SSH Tunnel Access to AWS ElasticSearch Domain and Kibana | Howto
How can I use an SSH tunnel to access Kibana from outside of a VPC with Amazon Cognito authentication?

VPC endpoints are not accessible directly from outside of the VPC.
If you want to allow this you will need to use a proxy instance in your VPC that can connect to the VPC endpoint, then proxy all requests through the EC2 instance in order to access the endpoint.
More information is available here.

Related

Is the connection from EC2 to AWS Service (like dynamodb) happening within the AWS Network, or via public internet?

I have VPC with couple of subnets containing EC2 instances.
The EC2 instances have code that invokes various AWS services like dybamodb.
Is the connection from EC2 to AWS Service (like dynamodb) happening within the AWS Network, or via public internet?
Is there any way to control this?
Is the connection from EC2 to AWS Service (like dynamodb) happening within the AWS Network, or via public internet?
Technically the process on EC2 would be hitting the AWS DynamoDB public API which is on the Internet. The traffic would be routed through the Internet Gateway you have attached to the VPC. I think if it is all in the same region it may not actually leave the AWS data center, and you could try testing that via tools like traceroute, but I don't think there are any guarantees of that.
Is there any way to control this?
Yes, add a VPC Endpoint to your VPC for the service you want to connect to. Then the DNS server in your VPC will route all traffic to that service over the VPC Endpoint, instead of routing it to your VPC's Internet Gateway. The traffic will then be guaranteed to stay within the AWS network.

Tunnel between aws ec2 instance and elastic cloud deployment

We have an elasticsearch service deployment at elastic.co. During the creation of the deployment "AWS" was chosen as the cloud platform. We are given an endpoint URL that resolves to a public IP address.
Also, we have an AWS account that has multiple ec2 instances running. When we access elasticsearch service from ec2 instances, the traffic goes through the internet.
Is it possible to make elasticsearch service visible to ec2 instances, as if both are in the same network?
If you want to use a secure connection, you have to use a special subscription called Elasticsearch Service Private. It is mentioned in the FAQs [1]:
We support secure peering using AWS Private Link. To run Elasticsearch Service in a dedicated VPC with a secure connection from your environment, use the Elasticsearch Service Private subscription. For more information, see Set up Elasticsearch Service Private.
There is a guide which outlines all the steps you need to take. [2]
I do not know the pricing details though. In the guide, they state that you need to contact their team in order to get more information. After you get in touch with them and order the Elasticsearch Service Private subscription, they set up a VPC inside their account for you. Next, they create a VPC PrivateLink Endpoint Service and whitelist your account. Finally, they give you the Elasticsearch Service Private Endpoint Service name which you can use to create an Interface VPC Endpoint (powered by PrivateLink). [3]
You should create an interface endpoint in each of the subnets used by your EC2 instances.
After creating the interface endpoints, you are able to access the Elasticsearch endpoint via a DNS name which is added to the AWS DNS servers automatically by PrivateLink. You just have to make sure that your EC2 instances are using the VPC's DNS servers. It should be the default configuration if you did not change the VPC's default DHCP option set.
References
[1] https://www.elastic.co/guide/en/cloud/current/ec-faq.html (see question: "Do you support VPC peering to Elasticsearch Service?")
[2] https://www.elastic.co/guide/en/cloud/current/ec-getting-started-private.html
[3] https://docs.aws.amazon.com/vpc/latest/userguide/vpce-interface.html

AWS Lambda Function Timeout on Connecting To RDS Database through RDS Proxy

I'm trying to test AWS RDS proxy so I created a lambda function and done all steps that are present in this official link
https://aws.amazon.com/blogs/compute/using-amazon-rds-proxy-with-aws-lambda
store RDS credentials in Secret Manager
create new role and also add Trust Policy
in lambda function, from the AWS console, add proxy and its status is available.
When I execute the lambda function, it times out with no errors it seems like the error might be on connecting to db with rds proxy because when I run the lambda function again without proxy, it works just fine.
I initially thought that it might be a security group issue, so I edit the security group of RDS Proxy and update inbound and allow 0.0.0.0 (outbound was already 0.0.0.0).
I used defaut VPC in RDS Database and RDS Proxy. The endpoint of RDS database is public.
Since RDS proxy is not available outside the VPC. Configure your lambda function to run inside the VPC. The following link will help:
https://docs.aws.amazon.com/lambda/latest/dg/configuration-vpc.html
Late answer.. thought these might help others.
You have to keep your lambdas inside the same VPC and subnets to access RDS proxy.
In any case if you want to access third party web api from your lambda, you have make the lambda subnets private (no Internet Gateway in route table) and assign a NAT gateway which is tied with a public subnet.
If you are accessing other AWS services which are out of VPC like S3, Secret Manager etc. then you have to create VPC endpoints for those services in your VPC.

How to setup access to ElasticDomain from different AWS account?

I created an ElasticDomain in private subnet which has a VPC endpoint and a security group which allows access from port 443. We want to access this ElasticDomain from another AWS account's EC2 instance. But we are not able to do that.
We tried creating ElasticDomain with a public endpoint which is accessible from anywhere but is not the right option for us.
We are considering to use apache as a reverse proxy and then set up a VPC private-link on a consumer account. Is that a right approach?
AWS PrivateLink via VPC and Network Load Balancer doesn't support ElasticDomain for now.
Check out the following two links:
1) https://aws.amazon.com/blogs/security/how-to-control-access-to-your-amazon-elasticsearch-service-domain/
2) AWS ElasticSearch write to account "A" from lambda in account "B"

What is the firewall rule to restrict access to external web api calls running on AWS EC2 instance

I am new on AWS. I've been hosting an ASP.NET Web API on an AWS EC2 instance. I would like to access this web api securely through AWS API Gateway. I configured the AWS API gateway service successfully, however EC2 instance accepts and responses external api requests which are coming directly from the internet.
My web api should only accept and response aws api gateway requests.
What is the correct firewall rule(s) in security group of my EC2 instance? Or do I need to create a policy in AWS IAM user.
This configuration shouldn't be restrict aws internal traffic in order to allow access aws api gateway requests.
Thanks
You need to assign you EC2 instance under a security group. And configure the security group with inbound rules. Which will allow you to white list IP range, port, protocol etc.