-
-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from mpvosseller/mpv/add-bucketNameKey-support
Adds support for fetching the bucket name from the stack output
- Loading branch information
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; |