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

Use Serverless naming module to format log group name #7

Conversation

domaslasauskas
Copy link
Contributor

There is an issue with this plugin when using custom naming convention by overriding naming module in AWS provider in Serverless. This PR uses naming module when forming logGroupName.

I had to update tests to use actual Serverless instance with AWS provider plugin.

I've also had to remove explicit function names from test configuration as they are used to override function names for deployed lambdas.

@@ -22,6 +22,8 @@ class LogForwardingPlugin {
this.serverless.service.resources = {
Resources: {},
};
} else if (this.serverless.service.resources.Resources === undefined) {
this.serverless.service.resources.Resources = {};
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updates the resources object if it doesn\'t exist test was failing due to this.serverless.service.resources being instantiated by Serverless framework but didn't have Resources property set.

package.json Outdated
},
"scripts": {
"test": "node ./node_modules/istanbul/lib/cli.js cover _mocha -- -R spec && node ./node_modules/istanbul/lib/cli.js check-coverage --line 70 coverage/coverage.json",
"test": "node ./node_modules/istanbul/lib/cli.js cover ./node_modules/mocha/bin/_mocha -- -R spec && node ./node_modules/istanbul/lib/cli.js check-coverage --line 70 coverage/coverage.json",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fixes following error I was getting on Windows:

...\node_modules\.bin\_mocha.CMD:1
(function (exports, require, module, __filename, __dirname) { @IF EXIST "%~dp0\node.exe" (
                                                              ^
SyntaxError: Invalid or unexpected token

},
functions: {
testFunctionOne: {
name: 'functionOne',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function names are meant to override deployed function name and are not required if you want to have conventional service-stage-functionName format.

@domaslasauskas domaslasauskas force-pushed the feature/use-naming-module branch from c2b5477 to a7cb607 Compare August 24, 2017 17:02
@interisti
Copy link
Contributor

@domaslasauskas

also if function names contain dashes, deploy will fail.
So instead of directly using functionName, there should be this.provider.naming.getNormalizedFunctionName(functionName)

https://github.com/amplify-education/serverless-log-forwarding/pull/7/files#diff-168726dbe96b3ce427e7fedce31bb0bcR81

@interisti
Copy link
Contributor

interisti commented Aug 25, 2017

@domaslasauskas
yup, it's working. 👍

@jconstance-amplify
i hope it will be merged soon, i'm planning to add stage filtering as soon as this is merged.

Copy link
Member

@aoskotsky-amplify aoskotsky-amplify left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great! Thanks for this PR. We can merge this if you could fix those merge conflicts. Thanks!

@alexdebrie
Copy link
Contributor

Hey @domaslasauskas, thanks for doing this as I am running into the same issue 😄.

Any thoughts on fixing these merge conflicts? Let me know if I can help out.

@nikgraf
Copy link

nikgraf commented Sep 17, 2017

nice! looking forward to the release including this one

@nikgraf
Copy link

nikgraf commented Sep 22, 2017

@domaslasauskas do you have time to resolve the conflicts here? If not I'm happy help

This change allows others to change naming convention and keeps naming consistent with Serverless framework. Previously creating subscription filters would fail if log groups naming convention was changed.
@domaslasauskas domaslasauskas force-pushed the feature/use-naming-module branch from acf942b to f65178f Compare September 29, 2017 09:13
@domaslasauskas
Copy link
Contributor Author

I've rebased changes on latest master to keep clean history for this PR. Please review this again @aoskotsky-amplify

@aoskotsky-amplify
Copy link
Member

@domaslasauskas Looks good. Thanks for the PR! Sorry about the delayed review

@aoskotsky-amplify aoskotsky-amplify merged commit 0a90e91 into amplify-education:master Sep 29, 2017
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

Successfully merging this pull request may close these issues.

5 participants