# S3 credentials for putObject

**URL:** https://forum.serverless.com/t/s3-credentials-for-putobject/955
**Category:** Serverless Framework
**Created:** [December 16, 2016, 8:00am UTC](https://forum.serverless.com/t/s3-credentials-for-putobject/955 "2016-12-16T08:00:31Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![funkybob](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/funkybob/32/321_2.png) [@funkybob](https://forum.serverless.com/u/funkybob)
#### Post date: [December 16, 2016, 8:00am UTC](https://forum.serverless.com/t/s3-credentials-for-putobject/955/1 "2016-12-16T08:00:31Z")

</div>

So, I’m trying to write a plugin that will push static assets into my S3 bucket, but i can’t seem to get permissions.

In my constructor, I have:

```
this.provider = this.serverless.getProvider('aws');

```

And in my command action, I use:

```
        this.provider.request('S3', 'putObject', {...}, service.provider.stage, service.provider.region)

```

But I get:

```
ServerlessError: Access Denied
    at Response.<anonymous> (.../server/node_modules/serverless/lib/plugins/aws/provider/awsProvider.js:168:20)
    at Request.<anonymous> (.../server/node_modules/serverless/node_modules/aws-sdk/lib/request.js:355:18)
    at Request.callListeners (.../server/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:105:20)
    at Request.emit (.../server/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (.../server/node_modules/serverless/node_modules/aws-sdk/lib/request.js:668:14)
    at Request.transition (.../server/node_modules/serverless/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (.../server/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at .../server/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (.../server/node_modules/serverless/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (.../server/node_modules/serverless/node_modules/aws-sdk/lib/request.js:670:12)
    at Request.callListeners (.../server/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:115:18)
    at Request.emit (.../server/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:77:10)
    at Request.emit (.../server/node_modules/serverless/node_modules/aws-sdk/lib/request.js:668:14)
    at Request.transition (.../server/node_modules/serverless/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (.../server/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at .../server/node_modules/serverless/node_modules/aws-sdk/lib/state_machine.js:26:10

```

Is there some stages or other things I should be doing to ensure this action works?

---

<div class="post-metadata">

### Author: ![funkybob](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/funkybob/32/321_2.png) [@funkybob](https://forum.serverless.com/u/funkybob)
#### Post date: [December 16, 2016, 8:10am UTC](https://forum.serverless.com/t/s3-credentials-for-putobject/955/2 "2016-12-16T08:10:11Z")

</div>

Your Environment Information -----------------------------  
OS: linux  
Node Version: 4.6.1  
Serverless Version: 1.4.0

---

<div class="post-metadata">

### Author: ![hamish](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/hamish/32/224_2.png) [@hamish](https://forum.serverless.com/u/hamish)
#### Post date: [December 18, 2016, 1:29pm UTC](https://forum.serverless.com/t/s3-credentials-for-putobject/955/3 "2016-12-18T13:29:59Z")

</div>

I’m not sure if this is the same problem you are seeing, but I was getting Access Denied errors when attempting to put files to S3. I traced the error down to not having `s3:PutObjectAcl` permission in my IAM Role. (I did have `s3:PutObject` .)

If that’s not helpful - perhaps enable `s3:*` to see if this is an IAM issue. If enbling \* fixed the problem - use this list to work out what other permisions you may be missing. [http://docs.aws.amazon.com/IAM/latest/UserGuide/list\_s3.html](http://docs.aws.amazon.com/IAM/latest/UserGuide/list_s3.html)

If that dosen’t work, you could try activating CloudTrail - although to be honest I’ve had limited sucess with CT for debugging.

Good Luck

Hamish

---

<div class="post-metadata">

### Author: ![funkybob](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/funkybob/32/321_2.png) [@funkybob](https://forum.serverless.com/u/funkybob)
#### Post date: [December 18, 2016, 9:01pm UTC](https://forum.serverless.com/t/s3-credentials-for-putobject/955/4 "2016-12-18T21:01:13Z")

</div>

Thanks, but I think I’ve narrowed down the cause a little more.

All operations are normally done as the deploy role, whereas the bucket is owned by the “run” role, so I actually don’t have access to the bucket.

So now I need to figure out how to make the same call, but using the created role.

(Or just give my deploy role access to the s3 bucket)

---

<div class="post-metadata">

### Author: ![funkybob](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/funkybob/32/321_2.png) [@funkybob](https://forum.serverless.com/u/funkybob)
#### Post date: [December 18, 2016, 10:34pm UTC](https://forum.serverless.com/t/s3-credentials-for-putobject/955/5 "2016-12-18T22:34:56Z")

</div>

Well, in fact, you were perfectly correct, @hamish

Thanks, again!
