AWS Amplify headless mode allows you to specify amplify init
arguments as string literals without navigating menus using arrow keys. I use the --amplify
argument to specify the environment, and --providers
to specify the Amplify administrator profile. --yes
means to accept the defaults for everything else.
Here is my play that runs amplify init
. It presumes that you have already created your Angular (or other framework) project. It depends on predefined variables amplify_project_dir
and amplify_project_administrator_profile
:
- name: Initialize Amplify for this project
command:
chdir: "{{ amplify_project_dir }}"
cmd: >
amplify init
--yes
--amplify
{\"envName\":\"dev\"}
--providers
{\"useProfile\":true,\"profileName\":\"{{ amplify_project_administrator_profile }}\"}
creates: "{{ amplify_project_dir }}/amplify/"
The JSON argument values must contain no unescaped whitespace. Jinja2 eliminates the whitespace in {{ amplify_project_administrator_profile }}
.