简体   繁体   English

AWS Amplify:将现有应用程序切换到新存储库?

[英]AWS Amplify: Switch existing app to new repository?

Question问题

Is there any way to point existing Amplify apps to new repositories?有没有什么方法可以将现有的 Amplify 应用程序指向新的存储库? Failing that, is there a way to clone Amplify app settings (including Backend environments) from one app to another?如果做不到这一点,是否有办法将 Amplify 应用程序设置(包括后端环境)从一个应用程序克隆到另一个应用程序?

Background背景

I was a complete newcomer to AWS until several months ago, when I inherited responsibility for an existing set of AWS apps developed by another team.直到几个月前,我才开始接触 AWS,当时我接手了另一个团队开发的一组现有 AWS 应用程序的职责。

In our AWS account, Amplify is configured to use GitLab repositories which were under the previous team's control.在我们的 AWS 账户中,Amplify 配置为使用 GitLab 个存储库,这些存储库由之前的团队控制。 I got a copy of the code, but I don't have access to the repositories.我得到了代码的副本,但我无权访问存储库。

So I uploaded the code to a new Bitbucket repository, and now I need to point the existing apps in Amplify to the new repositories.所以我将代码上传到新的 Bitbucket 存储库,现在我需要将 Amplify 中的现有应用程序指向新存储库。 My goal is to be able to push changes to my new repository and have Amplify detect those changes so the new build can be pushed.我的目标是能够将更改推送到我的新存储库并让 Amplify 检测到这些更改,以便可以推送新构建。

3 Unsuccessful Solutions 3 不成功的解决方案

I've tried approaching this problem from a few different angles.我尝试从几个不同的角度来解决这个问题。

1. Create a new app 1.创建一个新的应用程序

I created a new app which points to the new repository, which proved to be very simple.我创建了一个指向新存储库的新应用程序,事实证明这非常简单。 But I didn't anticipate how difficult it would be to migrate settings (especially the Backend environment) from one app to the other.但是我没有预料到将设置(尤其是后端环境)从一个应用程序迁移到另一个应用程序会有多困难。 So I thought it might be simpler to point the existing apps at the new repository.所以我认为将现有应用程序指向新存储库可能更简单。

2. Reconnect Repository 2.重新连接存储库

I thought that configuring a new repository for an existing app would be relatively straightforward.我认为为现有应用程序配置新存储库会相对简单。 Here's the procedure I followed.这是我遵循的程序。

  • Log into AWS Console and navigate to the Amplify service登录 AWS 控制台并导航到 Amplify 服务
  • From the list of apps, select the one I want to modify从应用程序列表中,select 我要修改的那个
  • Under "App settings", select the "General" tab在“应用程序设置”下,select“常规”选项卡
  • Click the "Reconnect repository" button单击“重新连接存储库”按钮

A dialog box popped up: "Reconnect your Git repository".弹出对话框:“重新连接您的 Git 存储库”。 It prompted me to select from a dropdown list of "Recently updated repositories", but that list was empty.它提示我从“最近更新的存储库”的下拉列表中转到 select,但该列表是空的。 There's no place to enter an address for a new repository, so this path seems to be a dead end.没有地方可以输入新存储库的地址,所以这条路似乎是死胡同。

3. Create a Connection 3.创建连接

I tried to "Create a connection to Bitbucket" as described in AWS documentation here: https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-create-bitbucket.html我尝试按照 AWS 文档中的说明“创建与 Bitbucket 的连接”: https://docs.aws.amazon.com/dtconsole/latest/userguide/connections-create-bitbucket.html

But the "Developer Tools" console seems unrelated to Amplify.但“开发者工具”控制台似乎与 Amplify 无关。 The connection was created successfully, but it doesn't appear in the "Recently updated repositories" list, and I don't know how else it can be used.连接创建成功,但它没有出现在“最近更新的存储库”列表中,我不知道它还能如何使用。

If you are okay with a CLI solution, have a look at the comment below from https://github.com/aws-amplify/amplify-hosting/issues/288#issuecomment-737192995如果您对 CLI 解决方案没问题,请查看以下来自https 的评论://github.com/aws-amplify/amplify-hosting/issues/288#issuecomment-737192995

aws amplify update-app --app-id AMPLIFY_APP_ID --repository REPOSITORY_URL --access-token ACCESS_TOKEN

... worked for me, transferring from one github account to another github account and repo. ... 为我工作,从一个 github 帐户转移到另一个 github 帐户和回购。 I know it's not quite what the OP was doing, but thought it may be worth noting that:我知道这不是 OP 在做什么,但认为可能值得注意的是:

  • The AMPLIFY_APP_ID is the last bit of the app ARN (eg dXXXXXXXXXXXXX) AMPLIFY_APP_ID 是应用程序 ARN 的最后一位(例如 dXXXXXXXXXXXXX)
  • For github repositories, the access token is a Personal Access Token ( https://github.com/settings/tokens ).对于 github 存储库,访问令牌是个人访问令牌 ( https://github.com/settings/tokens )。 I gave it all of the repo and admin:repo_hook privileges.我给了它所有的 repo 和 admin:repo_hook 权限。 That had to be created from the repository owner's account, not a contributor.这必须从存储库所有者的帐户创建,而不是贡献者。

This helped me to change that app to point to a different GitHub repository.这帮助我将该应用更改为指向不同的 GitHub 存储库。

AWS CLI requires some setup though, the documentation is available here https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html AWS CLI 需要一些设置,文档可在此处获得 https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html

Edit : You might also have to Reconnect The Repository using the UI after changing it using the CLI编辑:在使用 CLI 更改后,您可能还必须使用 UI Reconnect The Repository

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将 AWS S3 数据添加到现有 Android 应用程序的最佳方法是什么 - AWSJDK、Amplify 或没有 Amplify 框架的 AWS Android JDK? - What is best way to add AWS S3 data gets to an existing Android app - AWSJDK, Amplify, or AWS Android JDK without Amplify framework? 将 AWS Amplify 连接到 Flutter 应用程序时出现问题 - Issue Connecting AWS Amplify to Flutter App 如何将现有的 AWS Amplify Back-End 导入本地空的 AWS Amplify 项目? - How to import existing AWS Amplify Back-End into an empty AWS Amplify project locally? AWS Amplify 托管的 React App url 重定向很棘手 - AWS Amplify hosted React App url redirects is tricky 如何在 React 应用程序中使用 AWS Amplify 环境变量? - How to use AWS Amplify environment variables in React app? 使用 AWS amplify 和 grahql 创建新用户时出现“未经授权”错误 - 'Unauthorized' error when using AWS amplify with grahql to create a new user AWS Amplify App - URL 路径返回拒绝访问 - AWS Amplify App - URL path returns access denied iOS 应用程序使用 AWS Amplify DataStore,它不与后端 (DynamoDB) 同步 - An iOS app uses AWS Amplify DataStore and it does not sync with backend (DynamoDB) React.js 应用程序在 AWS amplify 上显示空白页面 - React.js App shows blank page on AWS amplify React 应用程序构建在 AWS 上失败,使用 memory 中的 JavaScript 堆放大 - React app build fail on AWS amplify with JavaScript heap out of memory
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM