# Unable to deploy Lambda with S3 trigger

**URL:** <https://forum.serverless.com/t/unable-to-deploy-lambda-with-s3-trigger/12339>\
**Category:** Serverless Framework\
**Tags:** aws, lambda\
**Created:** [August 20, 2020, 5:09pm UTC](https://forum.serverless.com/t/unable-to-deploy-lambda-with-s3-trigger/12339 "2020-08-20T17:09:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![neguinjeff](https://avatars.discourse-cdn.com/v4/letter/n/c5a1d2/32.png) [@neguinjeff](https://forum.serverless.com/u/neguinjeff)\
**Post date:** [August 20, 2020, 5:09pm UTC](https://forum.serverless.com/t/unable-to-deploy-lambda-with-s3-trigger/12339/1 "2020-08-20T17:09:29Z")

</div>

## Issue

When trying to deploy a Lambda function with an S3 trigge, the deployment reports an error and the lambda is created without the desired trigger

## Environment

- Operational System: macOS Catalina
- Node version: v10.16.3
- Framework Core: 1.79.0
- Plugin: 3.7.1
- SDK: 2.3.1
- Components: 2.34.6

\*_No plugins installed_

## YML with Lambda definition

```auto
name: nu-kami-${self:provider.stage}-invalidateCache
handler: dist/invalidateCache.default
description: Invalidates CloudFront cache once the json file with the banner communication is published
timeout: 5
memorySize: 128
vpc: ${self:custom.vpc}
tags:
  functionName: invalidateCache

environment:
  AWS_ACCOUNT_ID: ${self:custom.awsAccountId}
  STAGE: ${self:provider.stage}
  FUNCTION_NAME: invalidateCache
  STATSD_HOST: ${self:custom.statsdHost}
  STATSD_PORT: ${self:custom.statsdPort}
  LOGSTASH_HOST: ${self:custom.logstashHost}
  LOGSTASH_PORT: ${self:custom.logstashPort}
  LOGSTASH_NAME: ${self:custom.logstashName}
  CLOUDFRONT_ID: ${self:custom.cloudfrontId}

events:
  - s3:
    bucket: nu-preprod
    event: s3:ObjectCreated:*
    rules:
      - prefix: banner/
    existing: true

```

## Deployment error

```auto
$ serverless deploy --stage preprod --verbose
Serverless: Configuration warning:
Serverless: at 'functions.invalidateCache.events[0]': unrecognized property 'bucket'
Serverless: at 'functions.invalidateCache.events[0]': unrecognized property 'event'
Serverless: at 'functions.invalidateCache.events[0]': unrecognized property 'rules'
Serverless: at 'functions.invalidateCache.events[0]': unrecognized property 'existing'
Serverless:
Serverless: If you prefer to not continue ensure "configValidationMode: error" in your config
Serverless: If errors are influenced by an external plugin, enquiry at plugin repository so schema extensions are added (https://www.serverless.com/framework/docs/providers/aws/guide/plugins#extending-validation-schema)
Serverless: If errors seem invalid, please report at https://github.com/serverless/serverless/issues/new?template=bug_report.md
Serverless: If you find this functionality problematic, you may turn it off with "configValidationMode: off" setting
Serverless:
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service nu-kami.zip file to S3 (1.25 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
...

```

Although the serverless version I’m using is updated and the function trigger is as stated in the [documentation](https://www.serverless.com/framework/docs/providers/aws/events/s3/), I’m having this error during deployment and I don’t know how to proceed.

As you may notice the stack goes on and a deployment is made but no S3 trigger is configured.

---

<div class="post-metadata">

**Author:** ![goulartgabriel](https://avatars.discourse-cdn.com/v4/letter/g/f07891/32.png) [@goulartgabriel](https://forum.serverless.com/u/goulartgabriel)\
**Post date:** [August 24, 2020, 4:58pm UTC](https://forum.serverless.com/t/unable-to-deploy-lambda-with-s3-trigger/12339/2 "2020-08-24T16:58:12Z")

</div>

The identation of your s3 events configuration is wrong. It should be:

```auto
  - s3:
      bucket: nu-preprod
      event: s3:ObjectCreated:*
      rules:
        - prefix: banner/
      existing: true

```

---

<div class="post-metadata">

**Author:** ![bhoopalkiran](https://avatars.discourse-cdn.com/v4/letter/b/ce73a5/32.png) [@bhoopalkiran](https://forum.serverless.com/u/bhoopalkiran)\
**Post date:** [September 24, 2020, 3:06pm UTC](https://forum.serverless.com/t/unable-to-deploy-lambda-with-s3-trigger/12339/3 "2020-09-24T15:06:44Z")

</div>

Generally, this error means that your S3 bucket doesn’t have permission to invoke a [Lambda function](https://mindmajix.com/aws-lambda-training). The required permissions are automatically added to a resource-based policy for your function when you use the Amazon S3 console to configure an event notification for Lambda
