forked from k1LoW/serverless-s3-sync
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for bucketNameKey and fetching bucket name from stack o…
…utput
- Loading branch information
1 parent
df955c1
commit 1408513
Showing
3 changed files
with
119 additions
and
71 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
function resolveStackOutput(plugin, outputKey) { | ||
const provider = plugin.serverless.getProvider('aws'); | ||
const awsCredentials = provider.getCredentials(); | ||
const cfn = new provider.sdk.CloudFormation({ | ||
region: awsCredentials.region, | ||
credentials: awsCredentials.credentials | ||
}); | ||
const stackName = provider.naming.getStackName(); | ||
|
||
return cfn | ||
.describeStacks({ StackName: stackName }) | ||
.promise() | ||
.then(data => { | ||
const output = data.Stacks[0].Outputs.find( | ||
e => e.OutputKey === outputKey | ||
); | ||
if (!output) { | ||
throw `Failed to resolve stack Output '${outputKey}' in stack '${stackName}'`; | ||
} | ||
return output.OutputValue; | ||
}); | ||
} | ||
|
||
module.exports = resolveStackOutput; |