Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Support CloudFormation Join & Sub function in environment variable #1842

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

yo-ga
Copy link

@yo-ga yo-ga commented Dec 10, 2024

Description

  • Support CloudFormation the following intrinsic functions in environment variable
    • Fn::Join
    • !Join
    • Fn::Sub
    • !Sub

Motivation and Context

How Has This Been Tested?

example yaml:

service: aws-node-project
frameworkVersion: '3'

provider:
  name: aws
  runtime: nodejs18.x
  region: ap-northeast-1
  stage: dev
  environment:
      getKeyARN:
        Fn::Join:
          - ':'
          - - 'arn:aws:lambda'
            - ${self:provider.region}
            - Ref: 'AWS::AccountId'
            - 'function'
            - ${self:service}-${self:provider.stage}-getKey
      qa: 12345

functions:
  function1:
    handler: index.handler
    environment:
      getKeyARN:
        Fn::Join:
          - ':'
          - - 'arn:aws:lambda'
            - ${self:provider.region}
            - Ref: 'AWS::AccountId'
            - 'function'
            - ${self:service}-${self:provider.stage}-getKey
      qa: 12345

plugins:
  - serverless-offline

eample js:

module.exports.handler = async (event) => {
  console.log("test")
  console.log(process.env)
  return {
    statusCode: 200,
    body: JSON.stringify(
      {
        message: 'Go Serverless v3.0! Your function executed successfully!',
        input: event,
      },
      null,
      2
    ),
  };
};

@DorianMazur DorianMazur reopened this Jan 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[object Object] as environment variable when using CF functions Using Fn::Join resolves to [Object Object]
2 participants