Skip to content

Add support for non-default profiles #5

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ class fetchDynamoDBStreamsPlugin {
serverless.cli.log(
`Fetching Streams of [ Table : ${tableName} ] in region ${region}`
);
const profile = (options && options['aws-profile']) ||
(serverless.service && serverless.service.provider && serverless.service.provider.profile) ||
process.env.AWS_PROFILE;
const data = await getDynamoDBStreams(
region,
tableName
tableName,
buildCredentials(profile)
);

myStreamArn = extractStreamARNFromStreamData(data, tableName);
Expand Down Expand Up @@ -71,9 +75,12 @@ const extractStreamARNFromStreamData = (data, tableName) => {
return streamArn;
};

const getDynamoDBStreams = async (region, tableName) => {
const buildCredentials = (profile) => profile ? new AWS.SharedIniFileCredentials({ profile }) : undefined;

const getDynamoDBStreams = async (region, tableName, credentials) => {
const dynamoStreams = new AWS.DynamoDBStreams({
region: region,
region,
credentials,
});
const params = {
TableName: tableName,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "serverless-dynamodb-stream-arn-plugin",
"version": "0.0.7",
"version": "0.0.8",
"description": "Fetches and then adds existing DynamoDB Table streams to serverless.yml file using table name for serverless framework",
"main": "index.js",
"keywords": [
Expand Down