AWS Setup Guide¶
Some of these steps are focused on running on a local GNU/Linux environment, but most of it is also relevant to Windows OS as well.
Steps to automate AWS infrastructure¶
1. Get OpenTofu CLI¶
Retrieve the cli from GitHub release page by running:
Verity that tofu is detected by running:
which will output the tofu version v1.9.0.
2. Clone git repo¶
Clone the git repo that has been communicated to you using the specific GitLab access token:
3. Set Up Tofu Code¶
3.1 Use terraform.tfvars¶
Copy the existing terraform.tfvars.example to terraform.tfvars and make changes to the variables in that file. Make sure to modify the GitLab user and GitLab access token there with those credentials provided to you. Basically, you'll have 2 sets of tokens. This access token is separate from the other token mentioned in the previous section which is used to clone the repo. The current token is used to pull the containers from the GitLab registry.
3.2 Tofu Init¶
Before initializing tofu, make sure to login to your AWS SSO through the CLI:
and setup the sso config locally. And finally, initialize tofu with:
3.3 Tofu Plan / Apply¶
To view the resources that will be created, run:
and once that is completed, you should apply the changes
which will actually create the resources in AWS.
Manual Steps¶
These manual steps can be done either through AWS UI or cli. However for now, we will cover AWS UI only.
App Version in Parameter Store¶
Make changes to app version parameter only on the first time you deploy this resource. On later deploys, tofu will take care of updating this parameter. This will be the app version that ECS Task Definition from tofu uses to deploy the application (frontend, backend and db migration images).