Skip to content

Commit

Permalink
Handle lifecycle hook
Browse files Browse the repository at this point in the history
  • Loading branch information
direnakkoc committed Nov 23, 2022
1 parent 42a9275 commit a4e9dcc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
13 changes: 3 additions & 10 deletions serverless-plugin/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,15 @@ class ServerlessPlugin {

// Use the latest possible hook to ensure that `Resources` are included in the compiled Template
this.hooks = {
'before:aws:package:finalize:mergeCustomProviderResources': this.finalizeHook.bind(this)
// 'after:aws:package:finalize:mergeCustomProviderResources': () => this.cfTemplate
'after:aws:package:finalize:mergeCustomProviderResources': this.createSlicWatchResources.bind(this)
}
}

/**
* Modify the CloudFormation template before the package is finalized
*/
finalizeHook () {
// const appSyncConfig = (this.serverless.service.custom || {}).appSync || {}

createSlicWatchResources () {
const slicWatchConfig = (this.serverless.service.custom || {}).slicWatch || {}
// console.log(appSyncConfig)

const ajv = new Ajv({
unicodeRegExp: false
Expand All @@ -80,12 +76,9 @@ class ServerlessPlugin {

const awsProvider = this.serverless.getProvider('aws')

// console.log(appSyncConfig)
const cfTemplate = CloudFormationTemplate(
this.serverless.service.provider.compiledCloudFormationTemplate,
this.serverless.service.resources ? this.serverless.service.resources.Resources : {},
(this.serverless.service.custom || {}).appSync || {}
// this.serverless.service.custom ? (this.serverless.service.custom || {}).appSync : {}
this.serverless.service.resources ? this.serverless.service.resources.Resources : {}
)

const functionAlarmConfigs = {}
Expand Down
2 changes: 1 addition & 1 deletion serverless-test-project-appsync/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ configValidationMode: error
variablesResolutionMode: 20210219

plugins:
- serverless-slic-watch-plugin
- serverless-appsync-plugin
- serverless-slic-watch-plugin
- serverless-iam-roles-per-function
package:
exclude:
Expand Down

0 comments on commit a4e9dcc

Please sign in to comment.