Created
June 3, 2020 22:52
-
-
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.
This file contains 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 ( | |
"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