Probably you’ve heard this pretty often but, I’m very new to terraform and I am in love with this product which I want to master.
I have a challenge which I’d like to exercise with and I’d appreciate any tutorial, advice, or documentation on how I can deploy this app on AWS with the current architecture >>>
Terraform is just a tool to create whatever resources you are wanting, so the first step is to decide how you actually want to implement what you posted. Are you wanting to host things using EC2, EKS, ECS, Beanstalk, etc? Are you wanting to use RDS? Are you wanting to manage TLS certificates & DNS?
I’d suggest making a full diagram of your solution and then you can start figuring out how to make some code to implement that - there are lots of third part modules available to simplify some of that, or you can take a look at the AWS provider documentation to add resources directly.
Hi @stuart-c ,
Thanks for the reply.
The idea is that I do have build files of both frontend and backend, and I am aiming to host it on AWS using EC2 instances for the frontend/backend and add a postgres db (RDS) as a database for the backend.
With the use of EC2 instances you need to decide amongst the many options for how things might be build and deployed, and Terraform is likely to only be one tool amongst several to achieve that. For example you might use Packer to build AMIs containing the software, which Terraform then deploys. Or you might use Ansible to install the software on an EC2 instance, or use cloud0init to trigger Chef once an instance starts up.
Within the instance itself there are also many ways to handle things. For example you could use Docker/Docker Compose to manage things, install RPMs or DEB packages, handle start up via systemd.
All of the various option have advantages and disadvantages and really depend on what you are trying to achieve and your existing experience (for example do you need instant scaling of the apps as usage increases, etc.)
At the simplest, assuming you just want a single EC2 instance using an AMI that already contains the software then you just need a single
aws_instance resource. More likely however you need VPCs, ASGs, Route53, ACM, ALBs, etc. to build something that is sufficiently fault tolerant, scalable and monitorable.
As I mentioned I’d suggest a full diagram of all the AWS bits you are needing/wanting, and then it should be easier to break that down into Terraform code.