ENV=dev

build: lambda cdksynth
dnsbuild: lambda dnscdksynth

buildcdk:
	npm run build

cdksynth: buildcdk
	npx cdk synth $(ENV)

deploy: build
	 npx cdk -v deploy $(ENV)

dnscdksynth: buildcdk
	npx cdk synth dns-$(ENV)

dnsdeploy: dnsbuild
	 npx cdk -v deploy dns-$(ENV)

# This is a horrible hack, I should move the CDK for the API out into it's own thing
lambda:
	mkdir -p build/api/src/code.justin.tv/event-engineering && rm -rf build/api/src/code.justin.tv/event-engineering/* && cd build/api/src/code.justin.tv/event-engineering && git clone git@git-aws.internal.justin.tv:event-engineering/moonlight-api.git
	cd build/api/src/code.justin.tv/event-engineering/moonlight-api && GOPATH=${CURDIR}/build/api make build

buildlocal: lambdalocal cdksynth

deploylocal: buildlocal
	npx cdk -v deploy dev # we're hard coding this to dev

# This is a horrible hack, I should move the CDK for the API out into it's own thing
# It assumes the API you want to build is in ../moonlight-api
lambdalocal:
	mkdir -p build/api/src/code.justin.tv/event-engineering && rm -rf build/api/src/code.justin.tv/event-engineering/* && cp -R ../moonlight-api build/api/src/code.justin.tv/event-engineering
	cd build/api/src/code.justin.tv/event-engineering/moonlight-api && GOPATH=${CURDIR}/build/api make build
