edmamerto
edmamerto

Reputation: 8165

Initializing an array from serverless.yaml and calling it from the handler

I have an array in my handler that looks like this

process_list = [ 'Terminate', 'Launch', 'ScheduledActions', 'AlarmNotification' ]

I want to be able to set them in serverless.yaml

Is there an elegant way to do this?

Upvotes: 1

Views: 374

Answers (1)

edmamerto
edmamerto

Reputation: 8165

You can do this

serverles.yaml

environment:
    MY_LIST: "foo,bar"

handler.py

my_list = os.environ['MY_LIST'].split(",")

Upvotes: 2

Related Questions