Posted in

使用 Terraform 部署 AWS Amplify React 项目_AI阅读总结 — 包阅AI

包阅导读总结

1. `AWS Amplify`、`Terraform`、`React`、`部署`、`自动化`

2. 本文介绍了如何使用 Terraform 将 React 项目部署到 AWS Amplify,包括环境设置、创建应用、定义变量、应用更改等步骤,并强调了其自动化和便捷性。

3.

– 软件工程师希望使用 Terraform 部署 AWS Amplify React 项目以实现自动化部署。

– 准备工作

– 设置运行 Terraform 的环境,可使用多种 CI/CD 工具。

– 启动 AWS 命令行界面进行认证。

– 项目创建

– 创建 React.js 应用:`npx create-react-app example_reactjs_amplify`

– 创建 AWS Amplify 应用、分支和域名,并在特定文件中定义变量值。

– 输出与验证

– 在 `outputs.tf` 文件中定义输出。

– 运行命令应用更改,在 AWS 管理控制台验证部署是否成功。

– 总结

– 希望读者觉得此部署过程有用,可查看 GitHub 上的完整代码。

思维导图:

文章地址:https://thenewstack.io/deploy-an-aws-amplify-react-project-using-terraform/

文章来源:thenewstack.io

作者:Adetokunbo Ige

发布时间:2024/6/27 20:31

语言:英文

总字数:548字

预计阅读时间:3分钟

评分:81分

标签:sponsor-andela,赞助帖子,AWS Amplify,Terraform,React


以下为原文内容

本内容来源于用户推荐转载,旨在分享知识与观点,如有侵权请联系删除 联系邮箱 media@ilingban.com

Recently, I received a question from a software engineer that I was determined to help solve:

I would like to deploy my AWS Amplify React project using Terraform so that I can automate my workflow and eliminate any manual intervention during deployment.

AWS Amplify can help you build and deploy full-stack applications with ease, while Terraform allows you to define your infrastructure configurations in code using a declarative configuration language.

Terraform enables you to automate the provision and management of your AWS Amplify resources. Once you’ve defined your changes in the declarative configuration language, Terraform will apply the changes automatically, reducing any manual or human intervention.

I will walk through the process I used to achieve this task using Terraform. I will assume that you already have an understanding of using Terraform and AWS.

If you are new to Terraform, Amplify and AWS, there are many valuable resources to get you up to speed including Terraform: Beyond the Basics with AWS and Fullstack TypeScript: Reintroducing AWS Amplify.

Step 1

Set up your environment for running Terraform. You can use any CI/CD tool you’re comfortable running Terraform projects with, such as Jenkins, GitHub Actions, Spinnaker, CircleCI, GitLab or Makefile.

Step 2

Start the AWS command-line interface (CLI) running on your workstation so that you can authenticate with AWS.

Step 3

For this tutorial, create a React.js app using the command below. This is the code that will be deployed on AWS Amplify.

npx createreactapp example_reactjs_amplify

You can find the code for this tutorial on GitHub.

Step 4

Create the AWS Amplify app, the branch to deploy from and the domain on AWS with the script below. You will have to define the values for the variables in separate files called variables.tf and values.tfvars. Since enable_branch_auto_build is set to true, this script will automatically deploy the Amplify app once it detects that new code has been added to the React.js project. This means that once you push a new line of code to the main branch, it will automatically redeploy your Amplify app.

Step 5

Define the values for the variables in the variables.tf file. The file should include the following code:

Step 6

The output will be defined in the outputs.tf file and look similar to this:

These outputs, generated from the outputs.tf file, will provide you with all the necessary information on how to access your AWS Amplify app.

Step 7

Run the following command to apply your changes:

Step 8

After the terraform apply command applies your configuration changes, you can verify that your Amplify resource has been created successfully by visiting the AWS Management Console.

Use the AWS Management Console to verify that your Amplify resource was created

Check the app by looking at the URL highlighted in the screenshot above (in this example, https://main.helpfiner.click).

The screenshot below shows the AWS Amplify React.js app.

View the AWS Amplify React project by using the URL found in the AWS console

Conclusion

I hope you find this process of deploying React on AWS Amplify using Terraform useful. Check out the complete code on GitHub.

Discover more about the cloud tools and services that can help you navigate the complexities of cloud migration in Andela’s How DevOps Skills Are Evolving to Deploy Kubernetes in the Cloud.

YOUTUBE.COM/THENEWSTACK

Tech moves fast, don’t miss an episode. Subscribe to our YouTubechannel to stream all our podcasts, interviews, demos, and more.

GroupCreated with Sketch.