A sample CICD Deployment Pipeline for your Alexa Skills, using AWS CDK, CodeBuild and CodePipeline

Overview

Alexa Skils - CI/CD CDK Pipeline

This repository will help you setting up a CI/CD pipeline for your Alexa Skills.
This pipeline is powered by AWS Cloud Development Kit (CDK), CloudFormation CodePipeline and CodeBuild.

This repository is meant to help you getting started with Alexa Skills Development by adopting GitOps to manage changes to business logic and supporting infrastructure.

Solution Overview

Solution High Level Diagram
This solution is designed to automate the promotion of changes to business logic and infrastructure supporting your Alexa Skill. In the Develop phase, you make changes to the source code and commit to a form of source code versioning system. In the Automate phase, you use scripts and GitOps features to trigger changes to the state of your application. In the Build phase, you delegate the building of executable articacts and other assets to a designated environment. In the Operate phase, you create infrastructure able to run and monitor your application. In the Distribute phase, you make your application available to your target audiences.

Pipeline Steps

Pipeline Steps Diagram
The pipeline itslef has 5 steps:

  • Source is triggered by a new commit pushed to a monitored branch of the Build Repository. In this example, the Build Repository is separated from the Development Repository. This is to decouple the development source hosted in a central repository and the repository deployed in your AWS account. The goal of this step is to check out the latest commit and evaluate if any changes need to be propagated.
  • Build is triggered by the previous step. Its goal is to compile executable artifacts and assets.
  • Update Pipeline checks if the source code of the pipeline itslef has been changed in the latest commit. If so, changes to the pipeline are applied and the build step is restarted.
  • Artifacts publishes the articacts built at the previous stage.
  • Deploy triggers the creation of the supporting infrastructure and deployment of the artifacts previously built.

Cloud9 Environment Setup

The recommendation is that you run the first deployment from an AWS Cloud9 Environment making use of an IAM role that is able to create infrastructure via CloudFormation and IAM Roles. The recommended OS is Amazon Linux2.
You can follow this tutorial to set up your Cloud9 environment.

ASK CLI

If you haven't done this before, please install and configure ASK CLI by following these instructions. You'll have to run this procedure only once per Cloud9 environment.
In your Cloud9 terminal

  1. install CLI tool
npm install -g ask-cli
  1. configure the ASK profile
ask configure --no-browser
  1. When asked if you want to link your AKS profile to your AWS account, say no.

Expand your disk

Follow these instructions to expand your Cloud9 Environment disk. We recommend a disk size of at least 20GiB.

AWS Credentials

Your AWS Credentials should already be available in your Cloud9 Environment.
If you're not using Cloud9, you can verify this by running the following command

aws configure

Preparing your Amazon Developer Account

To create and manage Alexa Skills via CDK, you will need to provide Alexa Developer account credentials, which are separate from our AWS credentials. The following values must be supplied in order to authenticate:

  • Vendor ID: Represents the Alexa Developer account.
  • Client ID: Represents the developer, tool, or organization requiring permission to perform a list of operations on the skill. In this case, our AWS CDK project.
  • Client Secret: The secret value associated with the Client ID.
  • Refresh Token: A token for reauthentication. The ASK service uses access tokens for authentication that expire one hour after creation. Refresh tokens do not expire and can retrieve a new access token when needed.

Get Alexa Developer Vendor ID

Easily retrieve your Alexa Developer Vendor ID from the Alexa Developer Console.

  • Navigate to the Alexa Developer console and login with your Amazon account.
  • After logging in, on the main screen click on the “Settings” tab.

Screenshot of Alexa Developer console showing location of Settings tab

  • Your Vendor ID is listed in the “My IDs” section. Note this value.

Screenshot of Alexa Developer console showing location of Vendor ID

Create Login with Amazon (LWA) Security Profile

The Skill Management API utilizes Login with Amazon (LWA) for authentication, so first we must create a security profile for LWA under the same Amazon account that we will use to create the Alexa Skill.

  • Navigate to the LWA console and login with your Amazon account.
  • Click the “Create a New Security Profile” button.

Screenshot of Login with Amazon console showing location of Create a New Security Profile button

  • Fill out the form with a Name, Description, and Consent Privacy Notice URL, and then click “Save”.

Screenshot of Login with Amazon console showing Create a New Security Profile form

  • The new Security Profile should now be listed. Hover over the gear icon, located to the right of the new profile name, and click “Web Settings”.

Screenshot of Login with Amazon console showing location of Web Settings link

  • Click the “Edit” button and add the following under “Allowed Return URLs”:
http://127.0.0.1:9090/cb
https://s3.amazonaws.com/ask-cli/response_parser.html
https://ask-cli-static-content.s3-us-west-2.amazonaws.com/html/ask-cli-no-browser.html 
  • Click the “Save” button to save your changes.
  • Click the “Show Secret” button to reveal your Client Secret. Note your Client ID and Client Secret.

Screenshot of Login with Amazon console showing location of Client ID and Client Secret values

Environmental Variables

In the root of this repository, create the following file to export your Amazon Developer Console credentials, Login with Amazon Credentials and other variables the deployment will make use of.

touch .env

Add your credentials and custom values to this file.

export ALEXA_VENDOR_ID=<YOUR-VALUE-HERE>
export ALEXA_CUSTOMER_ID=<YOUR-VALUE-HERE>
export LWA_CLIENT_ID=<YOUR-VALUE-HERE>
export LWA_CLIENT_SECRET=<YOUR-VALUE-HERE>
export SKILL_STACK_NAME=<YOUR-VALUE-HERE>

This file will be sourced at deploy time to safely store your credentials in AWS SSM Parameter Store and Secrets Manager.

Deployment

Run the following command

./scripts/00-deploy.sh

This script has a few interactive steps, please follow its instruction.
It will

  • install local dependencies, such as jq and npm packages
  • generate a LWA refresh token
  • safely store your credentials in your AWS account via SSM Parameter Store and Secrets Manager
  • deploy the pipeline via CDK

The script will fail if any of the expected environment variables are missing.

Build Repo

Now that the pipeline has been deployed to your AWS account, it will monitor the branch feature/pipeline of a CodeCommit Build Repository deployed by the same stack.
To connect this repository to the Build Repository, run the following command

./scripts/10-build-repo.sh

This will add a new remote to this repository pointing to the Build Repository.
The new remote is called build. The script will also checkout

Triggering a Build

Push to the build remote to trigger a build.

git push build feature/pipeline

Security

See CONTRIBUTING for more information.

License

This sample is licensed under the Amazon Software License.

References

Acknowledgments

  • Thanks to Jeff Gardner for writing the post that inspired this code sample
  • This project was made possible by the Auto-Lab Team Europe
You might also like...

🚀 A boilerplate with generic configurations to a Nextjs project with bun, vitest, cicd and etc

👕 Next.JS Template with Linter 🔨 Tools: NextJS Typescript ESLint (Code Pattern) Prettier (Formatter) Husky (Pre-commit) Vitest (Unit/Integration Tes

Dec 18, 2022

AWS Lambda & Serverless - Developer Guide with Hands-on Labs. Develop thousands line of aws lambda functions interact to aws serverless services with real-world hands-on labs

AWS Lambda & Serverless - Developer Guide with Hands-on Labs. Develop thousands line of aws lambda functions interact to aws serverless services with real-world hands-on labs

AWS Lambda & Serverless - Developer Guide with Hands-on Labs UDEMY COURSE WITH DISCOUNTED - Step by Step Development of this Repository - https://www

Dec 17, 2022

Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK

Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK

serverless dynamodb integration tests 🚀 Example Serverless DynamoDB integration tests using Jest, TypeScript and the AWS CDK Introduction How to inte

Nov 4, 2022

An AWS Cloud Native application using CDK that defines a Serverless Event Driven application for interacting with Twitter and utilising Machine Learning / AI as a Service.

An AWS Cloud Native application using CDK that defines a Serverless Event Driven application for interacting with Twitter and utilising Machine Learning / AI as a Service.

AWS Serverless Event Driven Twitter Bot An AWS Cloud Native application using CDK (Written in TypeScript) that defines a Serverless Event Driven appli

Dec 18, 2022

Easy-to-use CDK constructs for monitoring your AWS infrastructure

CDK Monitoring Constructs Easy-to-use CDK constructs for monitoring your AWS infrastructure. Easily add commonly-used alarms using predefined properti

Jan 6, 2023

Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

May 18, 2022

Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

May 3, 2022

Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

Jan 3, 2023
Comments
  • Bump minimist from 1.2.5 to 1.2.6

    Bump minimist from 1.2.5 to 1.2.6

    Bumps minimist from 1.2.5 to 1.2.6.

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
  • Bump decode-uri-component from 0.2.0 to 0.2.2

    Bump decode-uri-component from 0.2.0 to 0.2.2

    Bumps decode-uri-component from 0.2.0 to 0.2.2.

    Release notes

    Sourced from decode-uri-component's releases.

    v0.2.2

    • Prevent overwriting previously decoded tokens 980e0bf

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.1...v0.2.2

    v0.2.1

    • Switch to GitHub workflows 76abc93
    • Fix issue where decode throws - fixes #6 746ca5d
    • Update license (#1) 486d7e2
    • Tidelift tasks a650457
    • Meta tweaks 66e1c28

    https://github.com/SamVerschueren/decode-uri-component/compare/v0.2.0...v0.2.1

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
    • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
    • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
    • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

    You can disable automated security fix PRs for this repo from the Security Alerts page.

    dependencies 
    opened by dependabot[bot] 0
Owner
null
ECS Blue/Green Deployment with AWS CodePipeline

ECS Blue/Green Deployment with AWS CodePipeline This repository contains a set of configuration to setup a CI/CD pipeline for an AWS ECS Cluster. All

Phạm Khắc Quyền 7 Sep 20, 2022
Sample solution to build a deployment pipeline for Amazon SageMaker.

Amazon SageMaker MLOps Build, Train and Deploy your own container using AWS CodePipeline and AWS CDK This’s a sample solution to build a deployment pi

AWS Samples 4 Aug 4, 2022
Learn Web 2.0 and Web 3.0 Development using Next.js, Typescript, AWS CDK, AWS Serverless, Ethereum and AWS Aurora Serverless

Learn Web 2.0 Cloud and Web 3.0 Development in Baby Steps In this course repo we will learn Web 2.0 cloud development using the latest state of the ar

Panacloud Multi-Cloud Internet-Scale Modern Global Apps 89 Jan 3, 2023
Sample code for resizing Images with Lambda@Edge using the Custom Origin. You can deploy using AWS CDK.

Resizing Images with Lambda@Edge using the Custom Origin You can resize the images and convert the image format by query parameters. This Lambda@Edge

AWS Samples 16 Dec 11, 2022
Sample AWS microservices app with service discovery defined using the CDK. Uses Docker + Fargate & ELB.

AWS Microservices Demo with CDK and Fargate About Simple AWS microservice-based app. Consists of two Spring Boot based services: Name Service GET /nam

Nick Klaene 7 Nov 23, 2022
A sample code that implements a simple Web app using AWS CDK v2

A sample code that implements a simple Web app using AWS CDK v2. This code will be introduced in a live coding session at AWS Summit Online Japan 2022 Developer Zone in 2022/5/25.

AWS Samples 29 Dec 5, 2022
Under the Sea is an official AWS workshop delivered by AWS SAs and AWS Partners to help customers and partners to learn about AIOps with serverless architectures on AWS.

Under the Sea - AIOps with Serverless Workshop Under the Sea is an exciting MMORPG developed by the famous entrepreneur behind Wild Rydes, the most po

AWS Samples 4 Nov 16, 2022
Alexa Skill & Google Action code that works on AWS Lambda

Jovo v4 Sample: Alexa Skill & Google Action on AWS Lambda Website - Docs - Marketplace - Template This Jovo v4 sample app showcases the following feat

Jovo 9 Nov 22, 2022
An Amazon Kendra REST API CDK example with an API Gateway, including authentication with AWS Cognito and AWS X-Ray Tracing

Amazon Kendra Web Service CDK Sample Amazon Kendra has a robust JSON API for use with the AWS SDK (software development kit), but does not expose endp

AWS Samples 8 Nov 28, 2022
MerLoc is a live AWS Lambda function development and debugging tool. MerLoc allows you to run AWS Lambda functions on your local while they are still part of a flow in the AWS cloud remote.

MerLoc MerLoc is a live AWS Lambda function development and debugging tool. MerLoc allows you to run AWS Lambda functions on your local while they are

Thundra 165 Dec 21, 2022