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

TypeError : Cannot read property "Properties" of undefined #178

Open
hstefanov opened this issue Oct 11, 2019 · 4 comments
Open

TypeError : Cannot read property "Properties" of undefined #178

hstefanov opened this issue Oct 11, 2019 · 4 comments

Comments

@hstefanov
Copy link

TypeError : Cannot read property "Properties" of undefined in \lib\stackops\lambdaRole.js:38:11 when role attribute is not included as root property in serverless.yml file.

How to reproduce:

Include serverless-aws-alias plugin and leave lambda role ARN in the function explicitly without overriding with global value.

service:
name: api

provider:
name: aws

functions:
api:
handler: handler
name: name
role: arn:aws:iam::account:role/rolename
events:
- http

@Lethgir
Copy link

Lethgir commented Jan 23, 2020

I have the same error when i am trying to deploy my lambda function (i don't have the error without serverless-aws-alias). Here my serverless.yml file :

frameworkVersion: '>=1.0.0 <2.0.0'

custom: ${file(../.custom.json)}
plugins:
    - serverless-pseudo-parameters
    - serverless-aws-alias
provider:
  name: aws
  region: ${opt:region, 'eu-west-1'}
  stage: ${opt:stage, 'production'}
  stackName: ${self:custom.FUNCTION_NAME}
  deploymentBucket:
    name: BUCKET_NAME

package:
  individually: true
  exclude:
    - "*.swp"
    - Jenkinsfile
    - Makefile
    - Pipfile
    - Pipfile.lock
    - tests/**

service: ${self:custom.FUNCTION_NAME}
functions:
  records_transformer:
    handler: lambda_handler.lambda_handler
    name: ${self:custom.FUNCTION_NAME}
    description: Doing something
    memorySize: 128
    role: arn:aws:iam::#{AWS::AccountId}:role/${self:custom.FUNCTION_NAME}
    runtime: python3.6
    timeout: ${self:custom.FUNCTION_TIMEOUT}
    environment:
      API_KEY: ${ssm:/MY_KEY~true}
      PARAM_1: ${self:custom.PARAM_1}
      PARAM_2: ${self:custom.PARAM_2}
      LOG_LEVEL: ${self:custom.LOG_LEVEL}
    package:
      include:
        - "**/*.py"

Detailed logs :

WARNING: You are using pip version 19.3; however, version 19.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
Serverless: Creating an empty package.json file in your service directory
Serverless: Installing plugin "serverless-pseudo-parameters@latest" (this might take a few seconds...)
Serverless: Successfully installed "serverless-pseudo-parameters@latest"
Serverless: Installing plugin "serverless-aws-alias@latest" (this might take a few seconds...)
Serverless: Successfully installed "serverless-aws-alias@latest"
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command create
Serverless: Load command install
Serverless: Load command package
Serverless: Load command deploy
Serverless: Load command deploy:function
Serverless: Load command deploy:list
Serverless: Load command deploy:list:functions
Serverless: Load command invoke
Serverless: Load command invoke:local
Serverless: Load command info
Serverless: Load command logs
Serverless: Load command metrics
Serverless: Load command print
Serverless: Load command remove
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command slstats
Serverless: Load command plugin
Serverless: Load command plugin
Serverless: Load command plugin:install
Serverless: Load command plugin
Serverless: Load command plugin:uninstall
Serverless: Load command plugin
Serverless: Load command plugin:list
Serverless: Load command plugin
Serverless: Load command plugin:search
Serverless: Load command config
Serverless: Load command config:credentials
Serverless: Load command rollback
Serverless: Load command rollback:function
Serverless: Load command alias
Serverless: Load command alias:remove
Serverless: Load command login
Serverless: Load command logout
Serverless: Load command generate-event
Serverless: Load command test
Serverless: Load command dashboard
Serverless: [AWS ssm 200 0.234s 0 retries] getParameter({ Name: '/MY_KEY',
  WithDecryption: true })
Serverless: Invoke deploy
Serverless: Invoke aws:common:validate
Serverless: [AWS s3 200 0.194s 0 retries] getBucketLocation({ Bucket: 'BUCKET_NAME' })
Serverless: Invoke aws:common:moveArtifactsToTemp
Serverless: Invoke aws:deploy:deploy
Serverless: WARNING: Inappropriate call of provider.request()
Serverless: WARNING: Inappropriate call of provider.request()
Serverless: [AWS cloudformation 400 0.189s 0 retries] listImports({ ExportName: 'LAMBDA_NAME-ServerlessAliasReference' })
Serverless: [AWS cloudformation 200 0.218s 0 retries] getTemplate({ StackName: 'LAMBDA_NAME',
  TemplateStage: 'Processed' })
Serverless: Preparing alias ...
 
  Type Error ---------------------------------------------
 
  TypeError: Cannot read property 'Properties' of undefined
      at AwsAlias.module.exports (/code/.tmp/.package/node_modules/serverless-aws-alias/lib/stackops/lambdaRole.js:38:11)
      at AwsAlias.aliasHandleLambdaRole (/code/.tmp/.package/node_modules/serverless-aws-alias/lib/aliasRestructureStack.js:43:21)
  From previous event:
      at PluginManager.invoke (/var/lang/lib/node_modules/serverless/lib/classes/PluginManager.js:489:22)
      at PluginManager.spawn (/var/lang/lib/node_modules/serverless/lib/classes/PluginManager.js:509:17)
      at AwsDeploy.BbPromise.bind.then (/var/lang/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:93:48)
  From previous event:
      at Object.deploy:deploy [as hook] (/var/lang/lib/node_modules/serverless/lib/plugins/aws/deploy/index.js:89:30)
      at BbPromise.reduce (/var/lang/lib/node_modules/serverless/lib/classes/PluginManager.js:489:55)
  From previous event:
      at PluginManager.invoke (/var/lang/lib/node_modules/serverless/lib/classes/PluginManager.js:489:22)
      at getHooks.reduce.then (/var/lang/lib/node_modules/serverless/lib/classes/PluginManager.js:524:24)
  From previous event:
      at PluginManager.run (/var/lang/lib/node_modules/serverless/lib/classes/PluginManager.js:524:8)
      at variables.populateService.then (/var/lang/lib/node_modules/serverless/lib/Serverless.js:115:33)
      at runCallback (timers.js:794:20)
      at tryOnImmediate (timers.js:752:5)
      at processImmediate [as _immediateCallback] (timers.js:729:5)
  From previous event:
      at Serverless.run (/var/lang/lib/node_modules/serverless/lib/Serverless.js:102:74)
      at serverless.init.then (/var/lang/lib/node_modules/serverless/bin/serverless.js:72:30)
      at /var/lang/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:111:16
      at /var/lang/lib/node_modules/serverless/node_modules/graceful-fs/graceful-fs.js:45:10
      at FSReqWrap.oncomplete (fs.js:135:15)
  From previous event:
      at initializeErrorReporter.then (/var/lang/lib/node_modules/serverless/bin/serverless.js:72:8)
      at runCallback (timers.js:794:20)
      at tryOnImmediate (timers.js:752:5)
      at processImmediate [as _immediateCallback] (timers.js:729:5)
  From previous event:
      at Object.<anonymous> (/var/lang/lib/node_modules/serverless/bin/serverless.js:57:4)
      at Module._compile (module.js:652:30)
      at Object.Module._extensions..js (module.js:663:10)
      at Module.load (module.js:565:32)
      at tryModuleLoad (module.js:505:12)
      at Function.Module._load (module.js:497:3)
      at Function.Module.runMain (module.js:693:10)
      at startup (bootstrap_node.js:188:16)
      at bootstrap_node.js:609:3

How did you solve your issue @hstefanov ?

@raymercb
Copy link

raymercb commented Apr 29, 2020

This may be related to the role at the function level.

I have the same problem in a project with two functions. Each function has its own role. No role at the provider level. Without the plugin, it works fine.

If you only have one function in the serverless.yml, try setting the role at the provider level.

@jacobsidford
Copy link

Issue still present.
Running serverless: 1.16.2
serverless-aws-alias: 1.8.0

@raymercb 's suggestion of setting role at the provider level worked for me

@emmaLP
Copy link

emmaLP commented Jun 13, 2024

Has anyone managed to get this working?

Getting the same error

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

No branches or pull requests

5 participants