Posted On: Sep 9, 2021

With today’s launch, customers can execute custom scripts before, during, and after Amplify CLI commands (“amplify push”, “amplify api gql-compile”, and more). This allows you to extend Amplify’s best-practice defaults to meet your organization’s specific security guidelines and operational requirements. AWS Amplify CLI is a command line toolchain that helps frontend web and mobile developers create cloud backends and connect them to their app for common use cases. To create a command hook, customers place their bash shell scripts into the “amplify/hooks" folder with the associated Amplify CLI command as the script file name, such as "post-push.sh" or "pre-add-function.sh”. Command hooks support bash scripts by-default but customers can extend it with their preferred scripting runtime.

Customers can trigger validation checks before, during, and after an Amplify CLI command is executed. For example, organizations with multiple team members can enforce all team members use the same Amplify CLI version. Or, customers can also conditionally interrupt an Amplify backend deployment. For example, an IT administrator can enforce that deployment only begins if a custom credential scanner script passed successfully. Finally, customers can also use command hooks to execute scripts after a command was completed successfully. For example, after an “amplify push”, customers can trigger a script that automatically cleans up build artifacts.

To get started with Amplify CLI’s new command hooks capability, check out our documentation.