[英]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.
这是我遵循的程序。
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.