如何从 AWS CLI 创建 Amplify React 应用程序

How to create Amplify React app from AWS CLI

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

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

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

执行以下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 user/role 具有所需的放大和 s3 策略。