Home > Mobile >  Getting the complete endpoint name of an API Gateway stage before deploying it
Getting the complete endpoint name of an API Gateway stage before deploying it

Time:12-11

I'm deploying my infrastructure using CDK and I want to automate the entire deployment of my app. Without using something like Route53, is there a way for me to know beforehand what will be the name of my API Gateway endpoint? I need it so I can automatically build and compile my Angular frontend and deploy it in a bucket, and I need to hit those endpoints to get some data. Right now I'm first deploying the infrastucture, then I manually get the endpoint and paste it in the frontend project but I wonder if there's a nicer way to do this.

CodePudding user response:

A complete solution would need to employ a CodeBuild service. You will need to do:

  • Deploy API Gateway and wait for the stage to be available.
  • Take the endpoint name and add in a parameter in Parameter Store.
  • Create a CodeBuild project that will build (and deploy) your web app. The endpoint name could be set as an environmental variable or through the Parameter Store.

CodePudding user response:

You can't have a fixed API Gateway endpoint before its creation, because its generated at the time of creation. (with a new id)

For your need, you must store the url generated of your API Gateway in a store, like SSM parameter Store, or parameter Store, or other location. Then in your build of your angular, inject the url in your env file or as env variable, from a env file like this for example https://www.jvandemo.com/how-to-use-environment-variables-to-configure-your-angular-application-without-a-rebuild/

  • Related