Pizza application in React and deploy in AWS S3 Bucket.
Only for the application frontend, an S3 bucket will be deploying it. The application backend is located here
To run this application without a CI/CD tool, the software needed is:
- NPM
- terraform
Also, an AWS and CircleCI account is required.
- You need to create an S3 bucket and a DynamoDB table to store the Terraform state. Also, change the following variables in the state_config.tf:
Line | Variable | Description |
---|---|---|
3 | bucket | Your bucket name |
4 | key | Path to the state file in the bucket |
6 | dynamodb_table | Table to store the terraform Lock |
- Change the projects variables
Line | Variable | Description |
---|---|---|
1 | profile | AWS profile to execute the terraform |
14 | tags | Adjust the tags for your needs |
23 | s3_name | Bucket name |
- Install the node modules.
npm i
NOTE
You can launch the test runner with:
npm test
Also, you can run the app in the development mode:
npm start
- Set the API endpoint into .env
echo "REACT_APP_API_URL=$BACKEND_API_ENV" >> .env
- Build it.
npm run build
- Enter the terraform directory and run the following commands:
# Initialize Terraform
terraform init
# Infrastructure checkout
terraform plan
# Infrastructure deploy
terraform apply
- Upload the built frontend to the bucket
aws s3 sync . s3://<bucket name>
-
Follow the project from your CircleCI account.
-
Set the environment variables in CircleCI:
Variable | Description |
---|---|
AWS_ACCESS_KEY_ID | AWS access key |
AWS_DEFAULT_REGION | AWS default region |
AWS_SECRET_ACCESS_KEY | AWS secret access key |
BACKEND_API | Backend API URL |
- You need to change the configuration pipeline in the step deploy to change the bucket name
aws s3 sync . s3://<bucket name>
- Build the project.
In the terraform output, a variable called website_endpoint contains the application URL.
NOTE
To destroy the application manually:
terraform destroy
In the pipeline, commit to a branch called "destroy".