This file contains hidden or 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
{ | |
"Type": "Notification", | |
"MessageId": "63a3f6b6-d533-4a47-aef9-fcf5cf758c76", | |
"TopicArn": "arn:aws:sns:ap-northeast-1:xxx:xxx", | |
"Subject" : "Test Subject", | |
"Message": "Test Message", | |
"Timestamp": "2018-07-7T05:12:16.901Z", | |
"SignatureVersion" : "1", | |
"Signature": "EXAMPLEnTrFPa37tnVO0FF9Iau3MGzjlJLRfySEoWz4uZHSj6ycK4ph71Zmdv0NtJ4dC/El9FOGp3VuvchpaTraNHWhhq/OsN1HVz20zxmF9b88R8GtqjfKB5woZZmz87HiM6CYDTo3l7LMwFT4VU7ELtyaBBafhPTg9O5CnKkg=", | |
"SigningCertURL": "https://sns.ap-northeast-1.amazonaws.com/SimpleNotificationService-xxx.pem", |
This file contains hidden or 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
import ( | |
"github.com/aws/aws-sdk-go/aws" | |
"github.com/aws/aws-sdk-go/aws/session" | |
"github.com/aws/aws-sdk-go/service/sqs" | |
"github.com/aws/aws-sdk-go/service/sns" | |
) |
This file contains hidden or 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
var ( | |
region = os.Getenv("AWS_DEFAULT_REGION") | |
queueURL = os.Getenv("QUEUE_URL") | |
topicARN = os.Getenv("TOPIC_ARN") | |
) | |
awsSession, err := session.NewSession(&aws.Config{Region: ®ion}) |
This file contains hidden or 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
snsClient := sns.New(awsSession) | |
subject := "Test Subject" | |
message := "Test Message" | |
_, err := snsClient.Publish(&sns.PublishInput{ | |
Subject: &subject, | |
Message: &message, | |
TopicArn: &topicARN, | |
}) |
This file contains hidden or 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
sqsClient := sqs.New(awsSession) | |
result, err := sqsClient.ReceiveMessage(&sqs.ReceiveMessageInput{ | |
QueueUrl: &queueURL, | |
AttributeNames: aws.StringSlice([]string{ | |
sqs.MessageSystemAttributeNameSentTimestamp, | |
}), | |
MaxNumberOfMessages: aws.Int64(1), | |
MessageAttributeNames: aws.StringSlice([]string{ | |
sqs.QueueAttributeNameAll, |
This file contains hidden or 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
import "time" | |
type SnsMessage struct { | |
Type string | |
MessageId string | |
TopicArn string | |
Subject string | |
Message string | |
Timestamp time.Time | |
SignatureVersion int `json:",string"` |
This file contains hidden or 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
snsMessage, _ := ReceiveMessage() | |
var message SnsMessage | |
json.Unmarshal([]byte(*snsMessage.Body), &message) | |
fmt.Println(message.Message) // "Test Message" |
This file contains hidden or 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
snsMessage, _ := ReceiveMessage() | |
message, _ := ParseMessageJSON(snsMessage) | |
_, err := sqsClient.DeleteMessage(&sqs.DeleteMessageInput{ | |
QueueUrl: &queueURL, | |
ReceiptHandle: snsMessage.ReceiptHandle, | |
}) | |
if err != nil { | |
fmt.Errorf("メッセージを削除できませんでした:" + *snsMessage.ReceiptHandle) |
This file contains hidden or 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
package main | |
import ( | |
"bytes" | |
"io" | |
"log" | |
"mime/multipart" | |
"net/http" | |
"os" | |
) |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"io" | |
"log" | |
"net/http" | |
"net/http/httputil" | |
"os" | |
"time" |
OlderNewer