arabold/serverless-sentry-plugin

Cannot load config from an external file

BlitzBanana opened this issue · 2 comments

Hello

I'm facing a problem using external .yml config files in my serverless.yml.

This works:

# serverless.yml
custom:
  sentry:	
    dsn: https://xxxx:yyyy@sentry.io/zzzz
    organization: my-organziation
    project: my-project
    authToken: my-token
    release: true

This doesn't work:

# serverless.yml

custom: ${file(staging.yml)}
# staging.yml
sentry:	
  dsn: https://xxxx:yyyy@sentry.io/zzzz
  organization: my-organziation
  project: my-project
  authToken: my-token
  release: true

This doesn't work either:

# serverless.yml

custom:
  env: ${file(staging.yml)}
  sentry: ${self:custom.env.sentry}
# staging.yml
sentry:	
  dsn: https://xxxx:yyyy@sentry.io/zzzz
  organization: my-organziation
  project: my-project
  authToken: my-token
  release: true

The only solution is:

# serverless.yml

custom:
  env: ${file(staging.yml)}
  sentry:	
    dsn: ${self:custom.env.sentry.dsn}	
    environment: ${self:custom.env.sentry.environment}
    organization: ${self:custom.env.sentry.organization}
    project: ${self:custom.env.sentry.project}
    authToken: ${self:custom.env.sentry.authToken}
    release: ${self:custom.env.sentry.release}
# staging.yml
sentry:	
  dsn: https://xxxx:yyyy@sentry.io/zzzz
  organization: my-organziation
  project: my-project
  authToken: my-token
  release: true

configPlugin() {
this.sentry = {};
if (_.has(this._custom, "sentry") && _.isPlainObject(this._custom.sentry)) {
_.assign(this.sentry, this._custom.sentry);
}
}

return this._serverless.variables.populateObject(this.sentry)
.then(populatedObject => {
this.sentry = populatedObject;

Maybe we could use this._serverless.variables.populateObject() directly on custom instead of custom.sentry (and only if sentry is an object) ?

👍 💯 need this fix too

I don't think this is still a problem in v2.