Subscribe to an SNS topic and / or SQS queue in golang?











up vote
0
down vote

favorite












I know how to do this in java, but I just can't figure it out in Go at all.



All I want to do, is have a way to detect that an item got created in an S3 bucket, then have that trigger an SNS topic, which then notifies me of the file location in S3.



Has anybody got a working example of how I can do the go side of this for subscribing to the SNS topic or the SNS queue if I need one? Because all I seem to be able to find is Java and Node. I can find publish examples for go, but they are of little use to my use case.










share|improve this question


















  • 2




    S3 can publish events to SNS when an object gets created with just configuration and no coding. Where is your problem?
    – Kannaiyan
    Nov 7 at 22:49

















up vote
0
down vote

favorite












I know how to do this in java, but I just can't figure it out in Go at all.



All I want to do, is have a way to detect that an item got created in an S3 bucket, then have that trigger an SNS topic, which then notifies me of the file location in S3.



Has anybody got a working example of how I can do the go side of this for subscribing to the SNS topic or the SNS queue if I need one? Because all I seem to be able to find is Java and Node. I can find publish examples for go, but they are of little use to my use case.










share|improve this question


















  • 2




    S3 can publish events to SNS when an object gets created with just configuration and no coding. Where is your problem?
    – Kannaiyan
    Nov 7 at 22:49















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I know how to do this in java, but I just can't figure it out in Go at all.



All I want to do, is have a way to detect that an item got created in an S3 bucket, then have that trigger an SNS topic, which then notifies me of the file location in S3.



Has anybody got a working example of how I can do the go side of this for subscribing to the SNS topic or the SNS queue if I need one? Because all I seem to be able to find is Java and Node. I can find publish examples for go, but they are of little use to my use case.










share|improve this question













I know how to do this in java, but I just can't figure it out in Go at all.



All I want to do, is have a way to detect that an item got created in an S3 bucket, then have that trigger an SNS topic, which then notifies me of the file location in S3.



Has anybody got a working example of how I can do the go side of this for subscribing to the SNS topic or the SNS queue if I need one? Because all I seem to be able to find is Java and Node. I can find publish examples for go, but they are of little use to my use case.







amazon-web-services go amazon-s3 amazon-sqs amazon-sns






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 7 at 22:41









MickeyThreeSheds

18216




18216








  • 2




    S3 can publish events to SNS when an object gets created with just configuration and no coding. Where is your problem?
    – Kannaiyan
    Nov 7 at 22:49
















  • 2




    S3 can publish events to SNS when an object gets created with just configuration and no coding. Where is your problem?
    – Kannaiyan
    Nov 7 at 22:49










2




2




S3 can publish events to SNS when an object gets created with just configuration and no coding. Where is your problem?
– Kannaiyan
Nov 7 at 22:49






S3 can publish events to SNS when an object gets created with just configuration and no coding. Where is your problem?
– Kannaiyan
Nov 7 at 22:49














1 Answer
1






active

oldest

votes

















up vote
0
down vote













To use SNS you will need a simple HTTP/HTTPS endpoint to receive SNS notifications. Which is divided into two parts (Confirm the subscription and Processing messages from HTTP/HTTPS endpoint)



1. Confirm the subscription
Do something as simple as this:



func confirmSubscription(subcribeURL string) {
response, err := http.Get(subcribeURL)
if err != nil {
fmt.Printf("Unbale to confirm subscriptions")
} else {
fmt.Printf("Subscription Confirmed sucessfully. %d", response.StatusCode)
}
}


2. Processing messages from HTTP/HTTPS endpoint



Parse the request's body, the documentations mentions how the body should be structured.



Sources:



https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html



https://github.com/viveksyngh/aws-sns-subscriber/blob/master/subscriber/subscriber.go






share|improve this answer























  • Ok! Thanks! But I have one more question! SubscribeURL? I've never seen that before, I am SURE I used ARNs for subscribing before, no?
    – MickeyThreeSheds
    Nov 8 at 2:17










  • The SubscribeURL is sent to you in the body during the "confirmation" step. All what you need to do is make a GET request to that URL and you will start receiving messages from SNS as soon as they sent from S3.
    – mostafazh
    Nov 8 at 7:33











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53199003%2fsubscribe-to-an-sns-topic-and-or-sqs-queue-in-golang%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













To use SNS you will need a simple HTTP/HTTPS endpoint to receive SNS notifications. Which is divided into two parts (Confirm the subscription and Processing messages from HTTP/HTTPS endpoint)



1. Confirm the subscription
Do something as simple as this:



func confirmSubscription(subcribeURL string) {
response, err := http.Get(subcribeURL)
if err != nil {
fmt.Printf("Unbale to confirm subscriptions")
} else {
fmt.Printf("Subscription Confirmed sucessfully. %d", response.StatusCode)
}
}


2. Processing messages from HTTP/HTTPS endpoint



Parse the request's body, the documentations mentions how the body should be structured.



Sources:



https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html



https://github.com/viveksyngh/aws-sns-subscriber/blob/master/subscriber/subscriber.go






share|improve this answer























  • Ok! Thanks! But I have one more question! SubscribeURL? I've never seen that before, I am SURE I used ARNs for subscribing before, no?
    – MickeyThreeSheds
    Nov 8 at 2:17










  • The SubscribeURL is sent to you in the body during the "confirmation" step. All what you need to do is make a GET request to that URL and you will start receiving messages from SNS as soon as they sent from S3.
    – mostafazh
    Nov 8 at 7:33















up vote
0
down vote













To use SNS you will need a simple HTTP/HTTPS endpoint to receive SNS notifications. Which is divided into two parts (Confirm the subscription and Processing messages from HTTP/HTTPS endpoint)



1. Confirm the subscription
Do something as simple as this:



func confirmSubscription(subcribeURL string) {
response, err := http.Get(subcribeURL)
if err != nil {
fmt.Printf("Unbale to confirm subscriptions")
} else {
fmt.Printf("Subscription Confirmed sucessfully. %d", response.StatusCode)
}
}


2. Processing messages from HTTP/HTTPS endpoint



Parse the request's body, the documentations mentions how the body should be structured.



Sources:



https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html



https://github.com/viveksyngh/aws-sns-subscriber/blob/master/subscriber/subscriber.go






share|improve this answer























  • Ok! Thanks! But I have one more question! SubscribeURL? I've never seen that before, I am SURE I used ARNs for subscribing before, no?
    – MickeyThreeSheds
    Nov 8 at 2:17










  • The SubscribeURL is sent to you in the body during the "confirmation" step. All what you need to do is make a GET request to that URL and you will start receiving messages from SNS as soon as they sent from S3.
    – mostafazh
    Nov 8 at 7:33













up vote
0
down vote










up vote
0
down vote









To use SNS you will need a simple HTTP/HTTPS endpoint to receive SNS notifications. Which is divided into two parts (Confirm the subscription and Processing messages from HTTP/HTTPS endpoint)



1. Confirm the subscription
Do something as simple as this:



func confirmSubscription(subcribeURL string) {
response, err := http.Get(subcribeURL)
if err != nil {
fmt.Printf("Unbale to confirm subscriptions")
} else {
fmt.Printf("Subscription Confirmed sucessfully. %d", response.StatusCode)
}
}


2. Processing messages from HTTP/HTTPS endpoint



Parse the request's body, the documentations mentions how the body should be structured.



Sources:



https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html



https://github.com/viveksyngh/aws-sns-subscriber/blob/master/subscriber/subscriber.go






share|improve this answer














To use SNS you will need a simple HTTP/HTTPS endpoint to receive SNS notifications. Which is divided into two parts (Confirm the subscription and Processing messages from HTTP/HTTPS endpoint)



1. Confirm the subscription
Do something as simple as this:



func confirmSubscription(subcribeURL string) {
response, err := http.Get(subcribeURL)
if err != nil {
fmt.Printf("Unbale to confirm subscriptions")
} else {
fmt.Printf("Subscription Confirmed sucessfully. %d", response.StatusCode)
}
}


2. Processing messages from HTTP/HTTPS endpoint



Parse the request's body, the documentations mentions how the body should be structured.



Sources:



https://docs.aws.amazon.com/sns/latest/dg/sns-http-https-endpoint-as-subscriber.html



https://github.com/viveksyngh/aws-sns-subscriber/blob/master/subscriber/subscriber.go







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 7 at 23:06

























answered Nov 7 at 22:58









mostafazh

1,558718




1,558718












  • Ok! Thanks! But I have one more question! SubscribeURL? I've never seen that before, I am SURE I used ARNs for subscribing before, no?
    – MickeyThreeSheds
    Nov 8 at 2:17










  • The SubscribeURL is sent to you in the body during the "confirmation" step. All what you need to do is make a GET request to that URL and you will start receiving messages from SNS as soon as they sent from S3.
    – mostafazh
    Nov 8 at 7:33


















  • Ok! Thanks! But I have one more question! SubscribeURL? I've never seen that before, I am SURE I used ARNs for subscribing before, no?
    – MickeyThreeSheds
    Nov 8 at 2:17










  • The SubscribeURL is sent to you in the body during the "confirmation" step. All what you need to do is make a GET request to that URL and you will start receiving messages from SNS as soon as they sent from S3.
    – mostafazh
    Nov 8 at 7:33
















Ok! Thanks! But I have one more question! SubscribeURL? I've never seen that before, I am SURE I used ARNs for subscribing before, no?
– MickeyThreeSheds
Nov 8 at 2:17




Ok! Thanks! But I have one more question! SubscribeURL? I've never seen that before, I am SURE I used ARNs for subscribing before, no?
– MickeyThreeSheds
Nov 8 at 2:17












The SubscribeURL is sent to you in the body during the "confirmation" step. All what you need to do is make a GET request to that URL and you will start receiving messages from SNS as soon as they sent from S3.
– mostafazh
Nov 8 at 7:33




The SubscribeURL is sent to you in the body during the "confirmation" step. All what you need to do is make a GET request to that URL and you will start receiving messages from SNS as soon as they sent from S3.
– mostafazh
Nov 8 at 7:33


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53199003%2fsubscribe-to-an-sns-topic-and-or-sqs-queue-in-golang%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()