Skip to content
This repository has been archived by the owner on Dec 31, 2021. It is now read-only.

Cannot read property 'Resources' of undefined #17

Closed
huksley opened this issue Nov 3, 2020 · 6 comments
Closed

Cannot read property 'Resources' of undefined #17

huksley opened this issue Nov 3, 2020 · 6 comments

Comments

@huksley
Copy link

huksley commented Nov 3, 2020

Hello,

I am using "serverless-default-aws-resource-properties": "0.0.15" and "serverless": "^1.78.1"
and getting following error when trying to deploy:

  TypeError: Cannot read property 'Resources' of undefined
      at DefaultAwsProperties.addDefaults (/Users/ruslan/src/myproject/node_modules/serverless-default-aws-resource-properties/index.js:35:49)

this line contains:

const resources = this.serverless.resources.Resources;

I also use a bunch of other plugins, if it is matter.

@neverendingqs
Copy link
Owner

Thanks for reporting. Do you have a sample serverless.yml file you can share that reproduces this issue?

@huksley
Copy link
Author

huksley commented Nov 4, 2020

@neverendingqs Here is the example app which inhibits this behaviour https://github.com/huksley/serverless-default-aws-resource-properties-example

@huksley
Copy link
Author

huksley commented Nov 5, 2020

@huksley huksley closed this as completed Nov 5, 2020
@mars-lan
Copy link

mars-lan commented Aug 30, 2021

Seems like the plugin expects there to be a resources key in serverless.yml so a workaround is to an empty key like this

# serverless.yaml
...
functions: 
  ...
resources:
  Resources:

@neverendingqs could you reopen this issue and handle the case of missing resources key gracefully?

@mars-lan
Copy link

Actually never mind. Seems like this plugin only deal with custom resources. For the default s3 bucket created by serverless framework, simply set the following

# serverless.yaml
provider: 
  deploymentBucket:
    blockPublicAccess: true 

@neverendingqs
Copy link
Owner

Hmmm that's interesting. It's possible to deal with all resources, but that might be viewed as unexpected behaviour in other scenarios.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants