I have a Go AWS Lambda job that I release using a Makefile in the project. As part of the release I need to tell the Lambda job to update to the latest binary (kept in an S3 bucket). We use SAML for credentials, which will time out and need to be refreshed. This can be a pain when doing a release and learning that the credentials expired. So I found a way to check that will check. Here it is:

AWS_AUTH := $(shell aws --profile saml sts get-caller-identity > /dev/null 2>&1 ; echo $$?)

release: build
…
ifeq ($(AWS_AUTH), 255)
	@echo "Missing AWS credintials"
	@false
else
	@aws lambda update-function-code --profile saml --region us-east-1 --function-name <my lambda job name> --zip-file fileb://packages/<binary name here>.zip
endif
…

Nothing too fancy but hopefully someone else will find this useful.