Skip to content

Instantly share code, notes, and snippets.

@bboure
Created March 25, 2023 10:09
Show Gist options
  • Save bboure/51a80540492232af893d2ea20a8e6c99 to your computer and use it in GitHub Desktop.
Save bboure/51a80540492232af893d2ea20a8e6c99 to your computer and use it in GitHub Desktop.
AppSync to SNS with Serverless Framework
resolvers:
Mutation.doSomething:
kind: UNIT
request: resolvers/sendMessage.request.vtl
response: resolvers/sendMessage.response.vtl
substitutions:
topicArn: !GetAtt MyTopic.TopicArn
dataSource:
type: HTTP
config:
endpoint: 'https://sns.us-east-1.amazonaws.com/'
iamRoleStatements:
- Effect: Allow
Action:
- sns:Publish
Resource: !GetAtt MyTopic.TopicArn
authorizationConfig:
authorizationType: AWS_IAM
awsIamConfig:
signingServiceName: sns
signingRegion: !Ref AWS::Region
#set($message=$util.urlEncode($util.toJson($ctx.args.post)))
{
"version": "2018-05-29",
"method": "POST",
"resourcePath": "/",
"params": {
"headers": {
"content-type": "application/x-www-form-urlencoded; charset=utf-8"
},
"body": "Action=Publish&Version=2010-03-31&TopicArn=${topicArn}&Message=${message}"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment