Alibaba CloudのFunction Computeに環境変数を設定する方法

Function Computeに環境変数を設定するためにはtemplate.ymlにEnvironmentVariablesセクションを追加します。

例えば、NODE_ENV=productionを追加したいときはtemplate.ymlに以下を追加します。

EnvironmentVariables:
  NODE_ENV: production

以下はtemplate.ymlの全文です。

# template.yml
ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
  MyServicei: # service name
    Type: 'Aliyun::Serverless::Service'
    Properties:
      Description: 'fc for auto testing'
    graphql: # function name
      Type: 'Aliyun::Serverless::Function'
      Properties:
        Handler: index.handler
        Runtime: nodejs8
        CodeUri: './'
        Timeout: 60
        EnvironmentVariables:
          NODE_ENV: production

  MyFunctionGroup: # group name
    Type: 'Aliyun::Serverless::Api'
    Properties:
      StageName: RELEASE
      DefinitionBody:
        '/':
          post:
            x-aliyun-apigateway-api-name: myapi
            x-aliyun-apigateway-request-config:
              requestProtocol: 'https'
            x-aliyun-apigateway-fc:
              arn: acs:fc:::services/${MyService.Arn}/functions/${graphql.Arn}/

公式のサンプル(github.com/aliyun/fun)が参考になります。