【Amplify】localをcloudの環境で上書きする方法(ver違いによるエラーの解消法も)

Amplifyでlocalのenvをcloudで構築した環境で上書きする方法についてまとめました。

ユースケース

こんなときに使用します!

チーム開発では、amplifyのbackend環境が、他の誰かによって変更されることがあります。

その変更された環境を、自分のlocal環境に反映する必要がありますので、その際に使用します。

実行コマンド

以下コマンドを実行すれば反映ができます。

$ amplify env pull --restore

これは、シンプルに以下コマンドでもいけます。

$ amplify pull

公式ドキュメントがこちら

Commands - JavaScript - AWS Amplify Documentation
Use these Amplify CLI commands to manage a team workflow with multiple environments. AWS Amplify Documentation

Amplifyのversion違いによるエラー解決法

上記コマンドでpullをした際に、localとcloudでamplifyのversionが異なると、以下のようなエラーが発生します。

Invalid feature flag configuration

These feature flags are defined in the "amplify/cli.json" configuration file and are unknown to the currently running Amplify CLI:

- graphqltransformer.securityenhancementnotification
- graphqltransformer.showfieldauthnotification

This issue likely happens when the project has been pushed with a newer version of Amplify CLI, try updating to a newer version.

Learn more about feature flags: 
Feature flags - JavaScript - AWS Amplify Documentation
More information about feature flags in Amplify CLI AWS Amplify Documentation
(https://docs.amplify.aws/cli/reference/feature-flags)

これの解消方法は以下になります。

エラー解消方法

エラー文に記載されている通り、”amplify/cli.json”ファイル内の以下2行の部分を削除します。

- graphqltransformer.securityenhancementnotification
- graphqltransformer.showfieldauthnotification

これで、再度pullをして、以下メッセージが出ればpull完了です!

Successfully pulled backend environment payment

以上、お読みいただきありがとうございました。

コメント