Skip to content

Instantly share code, notes, and snippets.

@ScriptAutomate
Created January 16, 2019 20:12
Show Gist options
  • Save ScriptAutomate/5af445ba5e0272a2e74a5e7732048b92 to your computer and use it in GitHub Desktop.
Save ScriptAutomate/5af445ba5e0272a2e74a5e7732048b92 to your computer and use it in GitHub Desktop.
Properly Configure Alexa Skill Id Permissions to Invoke Backend Lambda Function with SAM CLI Template
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Alexa App Hello World Lambda Endpoint
Mappings:
Variables:
AlexaSkillKit:
Id: amzn1.ask.skill.xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Globals:
Function:
Timeout: 3
Resources:
HelloWorldFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: hello_world/
Handler: app.lambda_handler
Runtime: python3.6
HelloWorldFunctionAskPermission:
Type: AWS::Lambda::Permission
DependsOn: HelloWorldFunction
Properties:
Action: lambda:InvokeFunction
EventSourceToken: !FindInMap
- Variables
- AlexaSkillKit
- Id
FunctionName: !GetAtt HelloWorldFunction.Arn
Principal: alexa-appkit.amazon.com
Outputs:
HelloWorldFunction:
Description: "Alexa Hello World Lambda Function ARN"
Value: !GetAtt HelloWorldFunction.Arn
HelloWorldFunctionIamRole:
Description: "Implicit IAM Role created for Alexa Hello World function"
Value: !GetAtt HelloWorldFunctionRole.Arn
HelloWorldFunctionAlexaSkillKitId:
Description: "Alexa Skill Permitted Lambda Invokation Permissions"
Value: !FindInMap
- Variables
- AlexaSkillKit
- Id
@ScriptAutomate
Copy link
Author

NOTE: If one is using Alexa Smart Home as the needed permissions, the Principal would instead be alexa-appkit.amazon.com

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment