Skip to content

Commit

Permalink
feat: sns support custom arn
Browse files Browse the repository at this point in the history
  • Loading branch information
steve-lemon committed Jul 19, 2019
1 parent 9417527 commit 301152a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"remove.ssocio": "sls remove --profile ssocio --stage prod",
"!test": "----- run self-test with jest -----",
"test": "LS=1 jest",
"!release": "----- release with standard -----",
"release": "standard-version"
},
"dependencies": {
Expand Down
18 changes: 16 additions & 2 deletions src/service/sns-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,24 @@ module.exports = function(_$, name, options) {
};

/**
* get arn string of this
* get/set arn string of this
*
* ```js
* // get default 'arn'
* const = $sns().arn();
*
* // set 'arn' of 'lemon-hello-sns'
* const old = $sns().arn('arn:aws:sns:111223344:lemon-hello-sns');
* ```
*/
const arn = (name = 'lemon-hello-sns') => {
const arn = (_arn = undefined, name = 'lemon-hello-sns') => {
const arn = $arns[name];
//! set if _arn is defined.
if (_arn !== undefined) {
$arns[name] = _arn;
return Promise.resolve(arn); // returns old value.
}
//! return if cached.
if (arn) return Promise.resolve(arn);
return accountID().then(_ => {
_log(NS, '> account-id =', _);
Expand Down

0 comments on commit 301152a

Please sign in to comment.