No hay resultados
October 21, 2019Greg Bulmash
In this blog post, I’ll discuss how to work on multiple projects which require different credentials by using the profile functionality in the Amazon Alexa Skills Kit Command Line Interface (ASK CLI).
I’m new to the Alexa team and as I started setting up my development environment with the ASK CLI, I had a question about the best way to do it. The ASK CLI needs credentials to run many commands. But how do you make sure it uses the right ones?
I have an Amazon developer account associated with my personal email address, one associated with my Amazon work address, and it’s possible I might have to use identities for team or organizational accounts. I realized that developers who work for multiple clients or on projects with separate Amazon Web Services or Amazon Developer team accounts could have the same problem.
A profile is a developer identity stored in your ASK CLI configuration, containing information about which Amazon developer account and AWS IAM user account should be used when executing commands. You can have multiple profiles with different names to specify which credentials to use when running a command.
Running `ask init` from the command line for the first time will start a wizard to help you set up your default profile, but don’t do that yet. I’ll talk a little later in this post about whether a default profile is your best option.
To set up a named profile, use `ask init –p [name]`, where “[name]” is the name you want to use for the profile.
After you have set up any profile, when you run the setup wizard, it will ask you to select an existing profile to modify or provide a name for the new profile. Using `ask init –p [name]` will skip the selection/naming step.
On any ASK CLI commands you want to run with a named profile, add `–p [name]` to execute those commands with that profile.
Now you can work on multiple projects with different sets of credentials more easily.
Let’s look at some pros and cons around the default profile.
Having a default profile:
Not having a default profile:
If you’re going to work on one project for a while, you can set a session-limited default from your command line by setting the `ASK_DEFAULT_PROFILE` environment variable with the name of the profile you want to use. Here’s how to do that:
[Windows Command Prompt] set ASK_DEFAULT_PROFILE=[profile name] [Linux / BSD / Mac] export ASK_DEFAULT PROFILE=[profile name]
The ASK CLI, when run in the terminal where you set the variable, will use that specified profile as the default until you close the terminal session.
Thanks for reading this post on using profiles with the Alexa Skills Kit Command Line Interface (ASK CLI). Do you have a tip or trick of your own for managing multiple accounts? Share them with me on Twitter at @YiddishNinja.