What’s the best way to automate the deployment of a fullstack monorepo app on AWS?

0
5
Asked By TechExplorer42 On

Hey everyone! I'm working on a project that consists of two AWS Lambda functions (built with Java) and a simple frontend application using vanilla JavaScript. I'm currently using Infrastructure as Code (IaC), specifically AWS SAM, but I'm open to other options. My main goals are to provision the infrastructure (including Lambda and API Gateway), deploy the Lambda functions, retrieve the public API Gateway URLs for each function, inject those URLs into the frontend app (as environment variables or in a configuration file), and finally build and publish the frontend, possibly to S3 or CloudFront. I want this workflow to function both on my local machine and in a CI/CD pipeline. Any advice on automating this process? Are there any best practices or preferred patterns within the AWS ecosystem for dynamically integrating deployed API URLs into a frontend application? I'd really appreciate any tips or examples you can share!

5 Answers

Answered By DevOps_Dynamo On

Given that you're using AWS heavily, it might be worth considering a CI/CD solution that operates outside of AWS. Things like GitHub Actions or GitLab CI can help you accomplish all your goals while also allowing for integration with other services as your project scales. Plus, they can run locally too.

Answered By OutputNinja On

You can output the necessary information in your CloudFormation stacks and create a script to read those outputs. This script can save them in a place your frontend can access, like a config.json file in S3. Just be aware that this method is not secure for sensitive information, though.

Answered By FrontendGuru On

A simple approach is to output the API Gateway URLs after deployment and inject them into your frontend configuration as part of the build process. In your CI/CD pipeline, capture those outputs, update a config.js or .env.js file, and then build and push to S3 or CloudFront. It keeps everything clean and repeatable!

Answered By CloudWizzy On

It's definitely doable! Personally, I'd recommend using AWS CDK instead of SAM. With CDK, you can use S3BucketDeployment to include a JSON file that has the API URLs, which your frontend can read. Just remember to think about how you'll secure those APIs, as they'll be publicly accessible.

Answered By CodeCrafter99 On

If I were in your shoes, I'd go with GitHub Actions for CI/CD and maybe use cdktf or just stick with CDK for your IaC.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.