Skip to main content

Posts

Showing posts from July, 2019

How to Use AWS SES Template Using Golang

👉 Amazon Simple Email Service Template (Amazon SES) is a highly scalable and cost-effective bulk and transactional email-sending service for businesses and developers. Subscription is quick and is on pay-as-you-go basis. You can read more about Amazon SES here  👏. Create an AwsSES.go file (Code Explained below) package main import ( "fmt" "utilities" "github.com/spf13/cast" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/ses" ) const ( sesRegion = "us-east-1" ) /* Create SES Session Function */ func newSESSession() (*session.Session, error) { return session.NewSession(&aws.Config{ Region: aws.String(sesRegion), }) } Create a Template Struct Format // SESTemplate ... contains template name, subject, htmlpart & text part type SESTemplate struct { TemplateName string `json:"templateName"` Subject stri

How to Publish message to SNS with AWS Golang

Publish to SNS With Golang SNS is a notification service. A user can send a notification to a topic. Each topic can have multiple subscribers, which receive a copy of every message sent to the topic – something like an HTTP endpoint, an email address, or an Amazon SQS queue. Sending a single notification can go to multiple places. Steps to publish an SNS message on an Amazon SNS Topic An AWS Account to set up an SNS topic and 1 queue that receives from the topic you just created. Place your key and secret in your .aws/credentials file [ http://docs.aws.amazon.com/AWSImportExport/latest/DG/SaveCredentials.html ] Use GoLang 1.7+ [ https://golang.org/doc/install Set your GOPATH [ https://golang.org/doc/install#install ] Install Amazon Core and SNS libraries go get  github . com / aws / aws - sdk - go / aws go get  github . com / aws / aws - sdk - go / aws / session go get  github . com / aws / aws - sdk - go / service / sn Create an AwsSns.go file (Code Explained

How To Upload files to AWS S3 bucket using golang

You can use the code below to upload files to aws s3 bucket using go : "import "github.com/aws/aws-sdk-go/service/s3" Package s3 provides the client and types for making API requests to Amazon Simple Storage Service. package main import ( "bytes" "fmt" "github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws/session" "github.com/aws/aws-sdk-go/service/s3" "log" "net/http" ) Get Bucket Region: GetBucketRegion will attempt to get the region for a bucket using a region hint to determine which AWS partition to perform the query on. Use this utility to determine the region a bucket is in. var S3_REGION, S3_BUCKET string func LS3BucketInitialization() { S3REGION, errRegion := "S3_REGION NAME" S3BUCKET, errBucket := "S3_BUCKET NAME" if errRegion != nil || errBucket != nil { log.Fatal(errRegion, errBucket) return } S3_REGION = S3REGION.Value S3