Created
January 11, 2019 21:09
-
-
Save ScriptAutomate/54ab687ff560e85191db1ff8c732e7f8 to your computer and use it in GitHub Desktop.
Adding an Alexa Skills Kit Permission w/ InvokeFunction Permissions After Deploying w/ SAM CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# Push package to S3 bucket | |
$STACK_NAME="hello-world-dev" | |
sam deploy \ | |
--template-file packaged.yaml \ | |
--stack-name $STACK_NAME \ | |
--capabilities CAPABILITY_IAM | |
# Setup Alexa Skills Kit skill ID | |
GOOD_ALEXA="amzn1.ask.skill.xxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" | |
LAMBDA_ARN=`aws cloudformation describe-stacks --stack-name $STACK_NAME | grep "OutputValue.*:lambda:*" | sed s/.*\"arn/arn/ | sed s/\",//` | |
# [As of 01/11/19] | |
# NOTE: If you have deployed via sam-cli, with an AlexaSkillEvent configuration included in your template.yaml, | |
# the following code needs to be executed to remove it because it is useless without an Alexa Skill Kit skill Id | |
# BAD_ALEXA=`aws lambda get-policy --function-name $LAMBDA_ARN --output text | sed s/.*Sid\"\:\"// | sed s/\".*//` | |
# aws lambda remove-permission \ | |
# --function-name $LAMBDA_ARN \ | |
# --statement-id $BAD_ALEXA | |
aws lambda add-permission \ | |
--function-name $LAMBDA_ARN \ | |
--statement-id 1 \ | |
--action lambda:InvokeFunction \ | |
--principal alexa-appkit.amazon.com \ | |
--event-source-token $GOOD_ALEXA |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Further research and testing shows that the following works in the
template.yaml
withsam-cli
, without needing to resort to post-configuration modification viaaws-cli
: