{{announcement.body}}
{{announcement.title}}

DevOps Your Skill: Deploy

DZone 's Guide to

DevOps Your Skill: Deploy

In this article, we discuss how to deploy your Alexa Skill to development stage in your pipeline and its importance in the day-to-day Alexa Skills development.

· DevOps Zone ·
Free Resource

When the code is checked in the previous steps, it is time to deploy the Skill to the Alexa cloud in order to start the next steps that will run different kind of tests. There are some tests, like VUI tests, integrations tests, end-to-end tests, and validation tests that we cannot run in localhost only with our code. This is why we need to deploy the Alexa Skill to the development stage.

These step are automated in the continuous integration system (CircleCI) and are executed in each new version of the software.

Prerequisites

Here you have the technologies used in this project

  1. ASK CLI - Install and configure ASK CLI.
  2. CircleCI Account - Sign up here.
  3. Node.js v10.x.
  4. Visual Studio Code.

ASK CLI (Alexa Skill Kit CLI)

The Alexa Skills Kit Command Line Interface (ASK CLI) is a tool for you to manage your Alexa skills and related resources, such as AWS Lambda functions. With ASK CLI, you have access to the Skill Management API, which allows you to manage Alexa skills programmatically from the command line. We will use this powerful tool to validate our Alexa Skill. Let's start!

Installation

The ASK CLI is included in the Docker image we are using so it is not necessary to install anything else.

Deploy

In this step of the pipeline, we are going to deploy our Alexa Skill using the ASK CLI to the development stage. When you deploy your skill to the development stage, it will update the skill manifest, interaction models, buckets, in-skill-purchasing products ,and lambda to the Alexa Cloud and AWS. We can use the following commands in the ASK CLI to manage this deployment of our Alexa skill:

  1. For ask cli v1:
Shell
 




x


 
1
ask deploy --debug --force



  1. For ask cli v2:
Shell
 




xxxxxxxxxx
1


 
1
ask deploy --debug --ignore-hash


Reports

There are not reports defined in this job.

Integration

It is not necessary to integrate it in package.json file.

Pipeline Job

The deploy job will execute the following tasks:

  1. Restore the code that we have used in the previous step in /home/node/project folder.
  2. Copy the package.json to src/ folder.
  3. Execute the npm run build-production command that will install only the production libraries in the src/ folder.
  4. Run ask deploy --debug --force that will deploy all the code in src/ folder as an AWS lambda.
  5. Persist again the code that we will reuse in the next job
YAML
 




x
12


1
  deploy:
2
    executor: ask-executor
3
    steps:
4
      - attach_workspace:
5
          at: /home/node/
6
      - run: cd lambda/custom && npm run copy-package
7
      - run: cd lambda/custom/src && npm run build-production
8
      - run: ask deploy --debug --force
9
      - persist_to_workspace:
10
          root: /home/node/
11
          paths:
12
            - project



Note: If you want to run successfully every ASK CLI command, you have to set up 5 environment variables:

  • ASK_DEFAULT_PROFILE
  • ASK_ACCESS_TOKEN
  • ASK_REFRESH_TOKEN
  • ASK_VENDOR_ID
  • AWS_ACCESS_KEY_ID
  • AWS_SECRET_ACCESS_KEY

And configure the __ENVIRONMENT_ASK_PROFILE__ profile in your .ask/config file.

How to obtain these variables and how to configure this profile are explained in this post.

Resources

Conclusion

Thanks to the ASK CLI we can perform this complex task.

That’s all, folks!  

You can find the code in my GitHub.

I hope it will be useful! If you have any doubts or questions, do not hesitate to contact me or put a comment below.

Happy coding!

Topics:
alexa, alexa skill, alexa skill development, alexa skills, alexa skills developer, alexa skills development, cicd, cicd pipeline, deploy, devops

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}