lifadev / archive_aws-lambda-go-shim

Author your AWS Lambda functions in Go, effectively.
https://github.com/eawsy/aws-lambda-go-shim
Apache License 2.0
789 stars 66 forks source link

how to use environment variable #51

Closed rchaser53 closed 6 years ago

rchaser53 commented 6 years ago

i want to use environment variable to post the message to slack. so i add the environment variable like below in Makefile.

docker:
    docker run --rm\
        -e SlackUrl=$(SlackUrl)\
        -e HANDLER=$(HANDLER)\
        -e PACKAGE=$(PACKAGE)\
        -e GOPATH=$(GOPATH)\
        -e LDFLAGS='$(LDFLAGS)'\
        -v $(CURDIR):$(CURDIR):Z\
        $(foreach GP,$(subst :, ,$(GOPATH)),-v $(GP):$(GP)):Z\
        -w $(CURDIR)\
        eawsy/aws-lambda-go-shim:latest make -f $(MAKEFILE) all

and use like below. but get empty.

url := os.Getenv("SlackUrl")  // url is ""

how should i do?

fsenart commented 6 years ago

Hi @rchaser53,

In order to use environment variables inside your Lambda code, you don't have to do anything special. You just have to configure your Lambda function (by cli or by the web console). So do not modify your Makefile.

rchaser53 commented 6 years ago

oh. it's no relation for this module. it worked. thank you for that!