Skip to content

Commit 246cbc5

Browse files
authored
Merge pull request #2 from 1stdibs/defnotrobbie/FI-1931
fix: FI-1931 better custom var src name, docs
2 parents d81bdc0 + a6f91d3 commit 246cbc5

File tree

2 files changed

+95
-65
lines changed

2 files changed

+95
-65
lines changed

README.md

Lines changed: 92 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,13 @@ Add the plugin to your package.json's devDependencies and to the plugins array
3131
in your `serverless.yml` file
3232

3333
Terminal:
34+
3435
```
3536
npm install --save-dev serverless-aws-alias
3637
```
3738

3839
serverless.yml:
40+
3941
```
4042
plugins:
4143
- serverless-aws-alias
@@ -58,6 +60,23 @@ be changed for a deployed version by accident, as it can be done with the
5860
`$LATEST` qualifier.This adds an additional level of stability to your deployment
5961
process.
6062

63+
## Custom Variable - pluginDibsAwsAlias:alias
64+
65+
The plugin [registers a custom variable source](https://www.serverless.com/framework/docs/guides/plugins/custom-variables), `pluginDibsAwsAlias`, with a single variable, `alias`, enabling retrieval of the alias in serverless config.
66+
67+
```yaml
68+
# serverless.yml
69+
...
70+
plugins:
71+
- dibs-serverless-aws-alias
72+
...
73+
functions:
74+
imageConvert:
75+
...
76+
description: ${pluginDibsAwsAlias:alias} - convert images to smaller, web-friendly images
77+
...
78+
```
79+
6180
## Deploy a single function
6281

6382
The plugin supports `serverless deploy function` and moves the alias to the
@@ -303,7 +322,7 @@ resources:
303322
ShardCount: 1
304323
```
305324

306-
When a function is deployed to an alias it will now also listen to the *my-kinesis*
325+
When a function is deployed to an alias it will now also listen to the _my-kinesis_
307326
stream events. This is useful, if you want to test new implementations with an
308327
existing resource.
309328

@@ -378,6 +397,7 @@ deployed alias you can combine it with the `--alias` option as usual.
378397
## The alias command
379398

380399
## Subcommands
400+
381401
### alias remove
382402

383403
Removes an alias and all its uniquely referenced functions and function versions.
@@ -437,9 +457,9 @@ If you are not happy with the plugin or just do not like me, you can easily get
437457
of the plugin without doing any harm to the deployed stuff. The plugin is
438458
non-intrusive and does only add some output variables to the main stack:
439459

440-
* Remove all alias stacks via the CloudFormation console or with 'alias remove'
441-
* Remove the plugin from your serverless.yml and your package.json
442-
* Deploy the service again (serverless deploy)
460+
- Remove all alias stacks via the CloudFormation console or with 'alias remove'
461+
- Remove the plugin from your serverless.yml and your package.json
462+
- Deploy the service again (serverless deploy)
443463

444464
You're all set.
445465

@@ -453,26 +473,27 @@ internal networks. This is possible because each deployed AWS lambda version
453473
contains its entire configuration (VPC settings, environment, etc.)
454474

455475
## For developers
476+
456477
### Lifecycle events
457478

458479
_currently the exposed hooks are not available after the change to the new SLS lifecycle model_
459480

460481
The plugin adds the following lifecycle events that can be hooked by other plugins:
461482

462-
* alias:deploy:uploadArtifacts
483+
- alias:deploy:uploadArtifacts
463484

464485
Upload alias dependent CF definitions to S3.
465486

466-
* alias:deploy:updateAliasStack
487+
- alias:deploy:updateAliasStack
467488

468489
Update the alias CF stack.
469490

470-
* alias:deploy:done
491+
- alias:deploy:done
471492

472493
The Alias plugin is successfully finished. Hook this instead of 'after:deploy:deploy'
473494
to make sure that your plugin gets triggered right after the alias plugin is done.
474495

475-
* alias:remove:removeStack
496+
- alias:remove:removeStack
476497

477498
The alias stack is removed from CF.
478499

@@ -485,76 +506,88 @@ and _serverless.service.provider.deployedAliasTemplates[]_.
485506

486507
## Ideas
487508

488-
* The master alias for a stage could be protected by a separate stack policy that
509+
- The master alias for a stage could be protected by a separate stack policy that
489510
only allows admin users to deploy or change it. The stage stack does not have
490511
to be protected individually because the stack cross references prohibit changes
491512
naturally. It might be possible to introduce some kind of per alias policy.
492513

493514
## Version history
494515

495-
* 1.8.0
496-
* Option to retain lambda function versions [#160][link-160]
497-
* **Breaking** drop Node.js 6 support [#161][link-161]
516+
- 1.8.0
517+
518+
- Option to retain lambda function versions [#160][link-160]
519+
- **Breaking** drop Node.js 6 support [#161][link-161]
520+
521+
- 1.7.2
522+
523+
- Added support for Lambda custom roles [#87][link-87] [#88][link-88]
524+
- Added support for dash in alias name when creating api gateway authorizers [#140][link-140]
525+
- Configurable master alias [#127][link-127]
526+
- Fix for "functionnames" where "functionname" A starts with function name B [#159][link-159]
527+
- Dependencies updated
498528

499-
* 1.7.2
500-
* Added support for Lambda custom roles [#87][link-87] [#88][link-88]
501-
* Added support for dash in alias name when creating api gateway authorizers [#140][link-140]
502-
* Configurable master alias [#127][link-127]
503-
* Fix for "functionnames" where "functionname" A starts with function name B [#159][link-159]
504-
* Dependencies updated
529+
- 1.7.1
505530

506-
* 1.7.1
507-
* Restore compatibility with Serverless 1.27 [#120][link-120]
531+
- Restore compatibility with Serverless 1.27 [#120][link-120]
508532

509-
* 1.7.0
510-
* Support existing custom authorizers [#101][link-101]
511-
* Support domain-manager plugin [#110][link-110]
512-
* Support pseudo-parameter plugin [#112][link-112]
513-
* Show logs from arbitrary versions [#62][link-62], [#89][link-89]
533+
- 1.7.0
514534

515-
* 1.6.1
516-
* Fixed custom authorizer references [#102][link-102]
517-
* Fixed broken DynamoDB stream deployments [#85][link-85]
518-
* Security: Updated moment
535+
- Support existing custom authorizers [#101][link-101]
536+
- Support domain-manager plugin [#110][link-110]
537+
- Support pseudo-parameter plugin [#112][link-112]
538+
- Show logs from arbitrary versions [#62][link-62], [#89][link-89]
519539

520-
* 1.6.0
521-
* Fixed issue with request authorizers [#96][link-96]
522-
* Support subscription to existing SNS topic [#94][link-94]
540+
- 1.6.1
541+
- Fixed custom authorizer references [#102][link-102]
542+
- Fixed broken DynamoDB stream deployments [#85][link-85]
543+
- Security: Updated moment
523544

524-
* 1.5.1
525-
* Support prewarmup with the warmup plugin [#72][link-72]
526-
* Support `_ - +` in alias names [#68][link-68]
527-
* Support ANY method type with stage configuration [#80][link-80]
545+
- 1.6.0
546+
- Fixed issue with request authorizers [#96][link-96]
547+
- Support subscription to existing SNS topic [#94][link-94]
528548

529-
* 1.5.0
530-
* Support `serverless deploy function` [#29][link-29]
549+
- 1.5.1
531550

532-
* 1.4.1
533-
* Fixed crash when using logs --tail
551+
- Support prewarmup with the warmup plugin [#72][link-72]
552+
- Support `_ - +` in alias names [#68][link-68]
553+
- Support ANY method type with stage configuration [#80][link-80]
534554

535-
* 1.4.0
536-
* Add support for S3 server side encryption [#63][link-63]
537-
* Add `serverless logs api` command to watch API logs [#60][link-60]
555+
- 1.5.0
538556

539-
* 1.3.0
540-
* Support full stage configuration at multiple levels [#57][link-57]
541-
* Fix issue when trying to remove a stage completely [#56][link-56]
557+
- Support `serverless deploy function` [#29][link-29]
542558

543-
* 1.2.1
544-
* Fix issue when using a Cognito User Pools authorizer [#51][link-51]
545-
* IAM roles of removed aliases are not deleted [#50][link-50]
546-
* Added note to README to state that per-alias resources do not work until fixed/added in Serverless
559+
- 1.4.1
547560

548-
* 1.2.0
549-
* Fix issue when stage is specified as Serverless variable [#45][link-45]
550-
* Add support for SNS Lambda subscriptions [#43][link-43]
551-
* Add support for custom authorizers [#22][link-22]
561+
- Fixed crash when using logs --tail
552562

553-
* 1.1.0
554-
* Use stage variable in APIG [#40][link-40]
555-
* Fix tail logging [#42][link-42]
563+
- 1.4.0
556564

557-
* 1.0.0 Support "serverless logs" with aliases. First non-alpha!
565+
- Add support for S3 server side encryption [#63][link-63]
566+
- Add `serverless logs api` command to watch API logs [#60][link-60]
567+
568+
- 1.3.0
569+
570+
- Support full stage configuration at multiple levels [#57][link-57]
571+
- Fix issue when trying to remove a stage completely [#56][link-56]
572+
573+
- 1.2.1
574+
575+
- Fix issue when using a Cognito User Pools authorizer [#51][link-51]
576+
- IAM roles of removed aliases are not deleted [#50][link-50]
577+
- Added note to README to state that per-alias resources do not work until fixed/added in Serverless
578+
579+
- 1.2.0
580+
581+
- Fix issue when stage is specified as Serverless variable [#45][link-45]
582+
- Add support for SNS Lambda subscriptions [#43][link-43]
583+
- Add support for custom authorizers [#22][link-22]
584+
585+
- 1.1.0
586+
587+
- Use stage variable in APIG [#40][link-40]
588+
- Fix tail logging [#42][link-42]
589+
590+
- 1.0.0 Support "serverless logs" with aliases. First non-alpha!
558591

559592
[ico-serverless]: http://public.serverless.com/badges/v3.svg
560593
[ico-license]: https://img.shields.io/github/license/serverless-heaven/serverless-webpack.svg
@@ -563,16 +596,13 @@ and _serverless.service.provider.deployedAliasTemplates[]_.
563596
[ico-coverage]: https://coveralls.io/repos/github/serverless-heaven/serverless-aws-alias/badge.svg?branch=master
564597
[ico-contributors]: https://img.shields.io/github/contributors/serverless-heaven/serverless-aws-alias.svg
565598
[ico-npm-downloads]: https://img.shields.io/npm/dt/serverless-aws-alias.svg
566-
567599
[link-serverless]: http://www.serverless.com/
568600
[link-license]: ./blob/master/LICENSE
569601
[link-npm]: https://www.npmjs.com/package/serverless-aws-alias
570602
[link-build]: https://travis-ci.org/serverless-heaven/serverless-aws-alias
571603
[link-coverage]: https://coveralls.io/github/serverless-heaven/serverless-aws-alias?branch=master
572604
[link-contributors]: https://github.com/serverless-heaven/serverless-aws-alias/graphs/contributors
573-
574-
[comment]: # (Referenced issues)
575-
605+
[comment]: # "Referenced issues"
576606
[link-22]: https://github.com/serverless-heaven/serverless-aws-alias/issues/22
577607
[link-29]: https://github.com/serverless-heaven/serverless-aws-alias/issues/29
578608
[link-40]: https://github.com/serverless-heaven/serverless-aws-alias/issues/40

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class AwsAlias {
4242
* @see https://www.serverless.com/framework/docs/guides/plugins/custom-variables
4343
*/
4444
this.configurationVariablesSources = {
45-
awsAlias: {
45+
pluginDibsAwsAlias: {
4646
resolve: async ({ address }) =>
4747
address === 'alias' ? { value: this._alias } : null,
4848
},
@@ -197,11 +197,11 @@ class AwsAlias {
197197
// Patch hooks to override our event replacements
198198
const pluginManager = this.serverless.pluginManager;
199199
const logHooks = pluginManager.hooks['logs:logs'];
200-
_.pullAllWith(logHooks, [ 'AwsLogs' ], (a, b) => a.pluginName === b);
200+
_.pullAllWith(logHooks, ['AwsLogs'], (a, b) => a.pluginName === b);
201201

202202
// Extend the logs command if available
203203
try {
204-
const logCommand = pluginManager.getCommand([ 'logs' ]);
204+
const logCommand = pluginManager.getCommand(['logs']);
205205
logCommand.options.alias = {
206206
usage: 'Alias'
207207
};

0 commit comments

Comments
 (0)