From cc9414656d89a7067a64c15ff69c49efb4d4bf49 Mon Sep 17 00:00:00 2001 From: shinsaka Date: Wed, 11 May 2022 18:41:54 +0900 Subject: [PATCH] execution "s3sync" with `--aws-profile` that sls option. --- index.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 24c0e85..6a2eda0 100644 --- a/index.js +++ b/index.js @@ -56,12 +56,14 @@ class ServerlessPlugin { syncDirectory() { this.getDescribeStacksOutput('WebAppS3BucketOutput').then(s3Bucket => { const s3LocalPath = this.serverless.service.custom.s3LocalPath; - const args = [ + const awscliArgs = !this.options['aws-profile'] + ? [] : ['--profile', this.options['aws-profile']]; + const args = awscliArgs.concat([ 's3', 'sync', s3LocalPath, `s3://${s3Bucket}/`, - ]; + ]); this.serverless.cli.log(args); const result = spawnSync('aws', args); const stdout = result && result.stdout && result.stdout.toString();