首页 > 解决方案 > 如何从 AWS CLI 创建 Amplify React 应用程序

问题描述

我想在 CI 管道中创建 AWS Amplify React 应用程序时遇到问题。如何从 AWS CLI 创建 Amplify 应用程序?文件应该来自 S3。在这种情况下,Git 不是一个选项。

aws --profile master amplify create-app --name appName

此命令创建放大应用程序,但我如何让它使用 S3 文件,压缩与否。

标签: amazon-web-servicesamazon-s3aws-cliaws-amplify

解决方案


执行以下 aws-cli 命令;也可以有不同的命令组合。

第 1 步:创建名称为 appName 的应用程序。aws amplify create-app --name appName --region eu-west-1

第二步:创建分支。aws amplify create-branch --region eu-west-1 --app-id "{appId from Step 1 here}" --branch-name "master". 还有其他方法可以创建分支。

第三步:部署。aws amplify start-deployment --region eu-west-1 --app-id "{appId from Step 1 here}" --branch-name "master" --source-url "s3://{s3-bucket-name}/app_src_package.zip"

第 4 步:要验证部署状态,aws amplify get-job --region eu-west-1 --app-id "{appId from Step 1 here}" --branch-name "master" --job-id "{jobId from Step 3 here}"

注意:确保您的 IAM 用户/角色需要放大和 s3 策略。


推荐阅读