I want to create websocket api using amazon API gateway. Is it possible to configure it such a way that can transfer data from/to EC2 instances? I know with lambda function it is possible but instead of lambda, is it possible to leverage EC2 server a backend for WebSocket API implementation?
WebSocket API implementation using API Gateway has a integration support for HTTP. So you can expose your HTTP endpoint on EC2 server, then integrate this with your WebSocket API implementation with EC2 as a backend(integration type). For details, refer to below AWS doc:
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-websocket-api-integration-requests.html
in my case, it would be AWS service. we will use EC2 as aws service in backend. we dont have HTTP endpoint. there are many documents and tutorials available but 99% of those are using lambda function. I am trying to integrate with EC2.
Related
I have a use case where i am supposed to connect my client to apigateway using websockets. I have seen the API gateway can be configured with WAF rules in case of a REST api but i am not able to see the websockets API gateway under the list of resources that can be added to WAF protected resource in AWS console. Does it mean that websocket connections to API gateway cannot be protected using WAF ?
As of now, WAF cannot be used with a WebSocket API in Amazon API Gateway. However, by configuring authorizer and throttling, you can protect your API.
Reference: https://docs.aws.amazon.com/apigateway/latest/developerguide/websocket-api-protect.html
I have a slack bot which is running on a EC2 in a VPC.
The VPC/ API gateway is supposed to only be exposed to slack (for slack event listening), Its not supposed to be publicly accessible.
How would I filter based on slack's DNS? https://api.slack.com/robots
I saw that API gateway has resource policies however they are only IP\ AWS account\ VPC based.
Any other AWS services that can help?
If the only reason you're exposing it to the web is for Slack to access it, then you could try using Socket Mode, which pushes all the Slack traffic to websockets, meaning you don't need a public endpoint anymore.
I have gone through the Amazon API gateway and lamda and its i understand the combination as lamda proving computation.
Is lamda is providing computation only or it can connect to EC2 linux instance and further to RDS?
Or Amazon API gateway direct connect to EC2 Linux instance?
I am confused?
Can any one help me on this?
Thanks
So in my opinion you are looking at serverless framework which is an API gateway which is configured with stages that send requests to your lambda function.
There is no need for Ec2 instance usage. Lambda function will establish connections with your database and make calls to it. Your database setup can be either private or public.
Additionally, on top of your api gateway you can implement something like cloudfront distribution and WAF which will provide further enhancements to your setup.
Assuming an web application is deployed in Amazon EC2 instance(say in 5 instances/servers) behind Elastic Load Balancer(ELB).
I want to call an API in deployed web application in each server to do some admin level operation in each instance.
eg : https://testapplicaiton/doadminupdate
How can i invoke this API in each server? Can i use AWS API to get list of server/ip address from ELB and invoke API in each instance by http://instance:8080/doadminupdate ? Or is there any provision in ELB or AWS itself?
How can i invoke this API in each server? Can i use AWS API to get
list of server/ip address from ELB and invoke API in each instance by
http://instance:8080/doadminupdate ?
Yes, that is a valid way to accomplish your requirement.
Or is there any provision in ELB or AWS itself?
No, the ELB will only send a request to a single instance. It won't fan-out the request.
Alternatively, you might look into configuring each server to subscribe to an SNS topic on startup, and send your admin requests to the SNS topic, which will fan out the message to all subscribers.
I need to communicate elasticache(Redis engine) using AWS API gateway. I successfully connected the ElastiCache from lambda function in the same VPC. I cant connect from outside VPC.
So I tried to create an API gateway, and select integration type as AWS Service Proxy and AWS Service as ElastiCache.
This is the screenshot for creating an API gateway
But I don't know, how to test this created API for executing Redis commands.
eg: SET A FOO
is it possible to communicate ElastiCache using API gateway?
API Gateway service proxy is for proxying the AWS API, not the Redis API, so that's not going to work for you. You will have to create a Lambda function and use API Gateway Lambda integration.