Skip to content

Instantly share code, notes, and snippets.

@cgarvis
Last active September 22, 2020 18:21
Show Gist options
  • Save cgarvis/61d70eeb1288bfee540c59cad095be64 to your computer and use it in GitHub Desktop.
Save cgarvis/61d70eeb1288bfee540c59cad095be64 to your computer and use it in GitHub Desktop.
Makefile for AWS SAM Golang project
SAM_PACKAGE_TEMPLATE = ./aws-sam/build/template.yaml
SAM_TEMPLATE = ./template.yaml
SAM_INFRA_DEPENDENCIES := $(shell find infra -type f)
.PHONY: $(SAM_INFRA_DEPENDENCIES)
$(SAM_INFRA_DEPENDENCIES):
cfn-lint $@
.PHONY:lint
lint: ## Lint cloudformation template
@ echo "Linting $(SAM_TEMPLATE)"
@ cfn-lint $(SAM_TEMPLATE) && echo "Done"
$(SAM_PACKAGE_TEMPLATE):
@ echo "Linting $(SAM_TEMPLATE)"
@ cfn-lint $(SAM_TEMPLATE)
@ sam build
.PHONY: build
build: $(SAM_PACKAGE_TEMPLATE)
.PHONY: deploy
deploy: $(SAM_PACKAGE_TEMPLATE) ## Deploy to AWS
@ sam deploy
.PHONY: test
test: ## Run tests
@ go test ./...
.PHONY: help
help: ## Display available commands
@ grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment