Skip to content

Instantly share code, notes, and snippets.

@michimani
Created June 3, 2020 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michimani/c30ea6bbaa672f4f8b4f08d61d98d0a6 to your computer and use it in GitHub Desktop.
Save michimani/c30ea6bbaa672f4f8b4f08d61d98d0a6 to your computer and use it in GitHub Desktop.
Sample of AWS Lambda function that runs at the 1st day of month in Japanese time.
package main
import (
"context"
"time"
)
// IsFirstDay is function to check today is the 1st day of month in JST
func IsFirstDay() bool {
var isFirstDay bool = false
nowUTC := time.Now()
jst := time.FixedZone("Asia/Tokyo", 9*60*60)
nowJST := nowUTC.In(jst)
if nowJST.Day() == 1 {
isFirstDay = true
}
return isFirstDay
}
// Handler is function of Lambda handler
func Handler(ctx context.Context, event InvokeEvent) (string, error) {
isFirstDay := IsFirstDay()
if isFirstDay == false {
var message string = "Today is not 1st."
return message, nil
}
// any process
}
func main() {
lambda.Start(Handler)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment