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

[object Object] as environment variable when using CF functions #5209

Open
AndreaAdvanon opened this Issue Aug 13, 2018 · 14 comments

Comments

Projects
None yet
@AndreaAdvanon
Copy link

AndreaAdvanon commented Aug 13, 2018

This is a Bug Report

Description

I wanted to define a custom arn:

custom:
  myCustomTopic:
    Fn::Join:
      - ":"
      - - arn
        - aws
        - sns
        - Ref: AWS::Region
        - Ref: AWS::AccountId
        - my-custom-topic

and use it as an environment variable:

  environment:
    MY_CUSTOM_TOPIC: ${self:custom.myCustomTopic}

But if I try at runtime:

console.dir(process.env.MY_CUSTOM_TOPIC)

I get:

'[object Object]'

Additional Data

  • Serverless Framework Version you're using: 1.29.2
  • Operating System: Fedora 28
@choxnox

This comment has been minimized.

Copy link

choxnox commented Aug 20, 2018

I can confirm I have the same issue on Windows using Serverless v1.30.1 when I try to reference the DynamoDB table from within environment variable:

provider:
  environment:
    DYNAMODB_TABLES_EVENTS:
      Ref: EventsTable

resources:
  Resources:
    EventsTable:
      Type: AWS::DynamoDB::Table
      Properties:
        TableName: ${self:custom.stackName}-events
        AttributeDefinitions:
          - AttributeName: id
            AttributeType: S
        KeySchema:
          - AttributeName: id
            KeyType: HASH
        ProvisionedThroughput:
          ReadCapacityUnits: ${self:custom.tableThroughput}
          WriteCapacityUnits: ${self:custom.tableThroughput}

When I use that environment variable inside Lambda function I get back the string with value: [object Object].

@nerdmax

This comment has been minimized.

Copy link

nerdmax commented Aug 30, 2018

+1

@shawnmclean

This comment has been minimized.

Copy link

shawnmclean commented Sep 15, 2018

When running this locally, it would be good to have the env var resolved to undefined instead of [Object object]

@alexdorand

This comment has been minimized.

Copy link

alexdorand commented Oct 10, 2018

Any plans to fix this bug anytime soon?

@mapsi

This comment has been minimized.

Copy link

mapsi commented Oct 19, 2018

Same here with

sls 1.32.0
aws-sdk 2.338.0

@snajahi

This comment has been minimized.

Copy link

snajahi commented Oct 30, 2018

+1

@herebebogans

This comment has been minimized.

Copy link

herebebogans commented Oct 30, 2018

serverless-export-env plugin along with serverless-offline will allow it to be referenced locally but note it doesnt support all CF Intrinsic functions eg Fn::GetAtt

@marekopatril

This comment has been minimized.

Copy link

marekopatril commented Jan 10, 2019

+1

@pmuens pmuens added the bug label Jan 17, 2019

@dschep dschep added the cat/variable label Jan 31, 2019

@yashutanna

This comment has been minimized.

Copy link

yashutanna commented Feb 7, 2019

+1

4 similar comments
@devashish90

This comment has been minimized.

Copy link

devashish90 commented Feb 14, 2019

+1

@keaeriksson

This comment has been minimized.

Copy link

keaeriksson commented Feb 16, 2019

+1

@gromozeka1974

This comment has been minimized.

Copy link

gromozeka1974 commented Mar 19, 2019

+1

@bryan-lifelink

This comment has been minimized.

Copy link

bryan-lifelink commented Mar 28, 2019

+1

@diosney

This comment has been minimized.

Copy link

diosney commented Apr 4, 2019

Bump!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.