From e0d17ed251c8a6d4c73e5a392879b299b2895975 Mon Sep 17 00:00:00 2001 From: yagi_ Date: Sun, 5 Apr 2020 20:49:37 +0900 Subject: [PATCH] Support region and profile Added region and profile support at `runAwsCommand`. User can specify `region` and/or `profile` in the provider section of serverless.yml. --- .../serverless-single-page-app-plugin/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/aws-node-single-page-app-via-cloudfront/serverless-single-page-app-plugin/index.js b/aws-node-single-page-app-via-cloudfront/serverless-single-page-app-plugin/index.js index b861e9d66..dfc3e319b 100644 --- a/aws-node-single-page-app-via-cloudfront/serverless-single-page-app-plugin/index.js +++ b/aws-node-single-page-app-via-cloudfront/serverless-single-page-app-plugin/index.js @@ -37,7 +37,14 @@ class ServerlessPlugin { } runAwsCommand(args) { - const result = spawnSync('aws', args); + let command = 'aws'; + if (this.serverless.variables.service.provider.region) { + command = `${command} --region ${this.serverless.variables.service.provider.region}`; + } + if (this.serverless.variables.service.provider.profile) { + command = `${command} --profile ${this.serverless.variables.service.provider.profile}`; + } + const result = spawnSync(command, args); const stdout = result.stdout.toString(); const sterr = result.stderr.toString(); if (stdout) {