24
votes

I'm going to build microservices' architecture on AWS and I want to ask you to clarify my doubts.

My current general concept

I would like to use API Gateway, which exposes microsevices' APIs running in Elastic Beanstalk. I would like to place the Elastic Beanstalk in VPC without direct access from Internet to its instances.

enter image description here

Questions & Doubts:

  1. Elastic Beanstalk gets subdomain on application creation. This subdomain should be used by API Gateway with integration type: AWS service, in action configuration - Am I right?
  2. What would represent a single microservice? An Elastic Beanstalk's application is a specific scalable microservice?
  3. How the microservices should communicate with each other? There would be some task where Im going to use SQS (Simple Queue Service). But in other cases, is it better when two microservices communicates with each other through API Gateway rather than directly - am I right?
  4. Test environment: What structure should I use in test environment (or staging env.)? I think about creating separate VPC with another Elastic Beanstalk and other Amazon services.
  5. Test environment and API Gateway: How should I set up an API Gateway? It should allow clients to access the microservices in test environment if request has specific subdomain, like: test.mydomain.com/hello_world/say_hello. I'm not sure how to use API Gateway in CI/CD to make it fast and simple, without manual copying some configuration from test stage to the production stage. (I'm not expecting any complex solution, only some hints about what components, parts, concepts could I use for it. More details I'll find on my own).
  6. Have you any experience in deploying apps to Elastic Beanstalk using Codep Deploy and/or Jenkins? I'm interesting in which way could be better: Jenkins, AWS Code Deploy or Jenkins+CodeDeploy.
2
In general when people refer to microservices, they're talking about AWS Lambda or Azure Functions. In the case of Lambda, the functions can be called directly from the API gateway externally, then either perform SQS tasks or kickoff other lambda functions directly. Also, I don't see the need for a VPC unless you're connecting the VPC to some on-prem infrastructure and have the Lambda functions access those assets.Jordan
I think you're confusing "microservices" with "serverless".jrc

2 Answers

15
votes

I'll answer the points that are not opinion based:

  1. Elastic Beanstalk gets subdomain on application creation. This subdomain should be used by API Gateway with integration type: AWS service, in action configuration - Am I right?

No, AWS service integration would only apply if you were actually calling the Elastic Beanstalk service. You would be calling your own beanstalk instance so you would use HTTP integration.

  1. What would represent a single microservice? An Elastic Beanstalk's application is a specific scalable microservice?

This is up to you, but as mentioned in comments, many customers choose to do this via Lambda functions rather than beanstalk applications. Using Lambda has the benefit that you do not need to managed the scaling of your beanstalk application.

  1. Test environment: What structure should I use in test environment (or staging env.)? I think about creating separate VPC with another Elastic Beanstalk and other Amazon services.

Just a note here, API Gateway cannot contact resources in your VPC currently. Any beanstalk instance would need to be publically accessible.

  1. Test environment and API Gateway: How should I set up an API Gateway? It should allow clients to access the microservices in test environment if request has specific subdomain, like: test.mydomain.com/hello_world/say_hello. I'm not sure how to use API Gateway in CI/CD to make it fast and simple, without manual copying some configuration from test stage to the production stage. (I'm not expecting any complex solution, only some hints about what components, parts, concepts could I use for it. More details I'll find on my own).

You should take a look at stage variables. This would allow you to use basic configuration with differences between dev/test/prod stored in these variables.

8
votes

API Gateway now supports integration with Private VPC, so I'd expect you can deploy your ELB in a private VPC and front it with API Gateway using an .ebextension

Source: https://aws.amazon.com/about-aws/whats-new/2017/11/amazon-api-gateway-supports-endpoint-integrations-with-private-vpcs/