# Updating S3 bucket deletes bucket contents

**URL:** <https://forum.serverless.com/t/updating-s3-bucket-deletes-bucket-contents/6997>\
**Category:** Serverless Framework\
**Tags:** aws\
**Created:** [January 14, 2019, 12:04pm UTC](https://forum.serverless.com/t/updating-s3-bucket-deletes-bucket-contents/6997 "2019-01-14T12:04:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![annedroiid](https://avatars.discourse-cdn.com/v4/letter/a/6bbea6/32.png) [@annedroiid](https://forum.serverless.com/u/annedroiid)\
**Post date:** [January 14, 2019, 12:04pm UTC](https://forum.serverless.com/t/updating-s3-bucket-deletes-bucket-contents/6997/1 "2019-01-14T12:04:25Z")

</div>

I have a lambda that gets input from an S3 bucket. I’ve created the bucket and an attached bucket policy in my Resources section, however whenever I deploy it deletes the existing contents of my bucket. Is this intentional? Does anyone know if there is a work-around for this?

```
S3BucketMyBucket: 
   Type: AWS::S3::Bucket
   Properties:
     BucketName: my-bucket
devMyBucketPolicy:
  Type: AWS::S3::BucketPolicy
  Properties:
    Bucket: my-bucket
    PolicyDocument:
      Version: "2012-10-17"
      Statement:
        -
          Effect: Allow
          Principal:
            Service:
              - ses.amazonaws.com
          Action: s3:PutObject
          Resource:
            - arn:aws:s3:::my-bucket/*
          Condition:
            StringEquals:
              aws:Referer:
                - 1111111111111
```

---

<div class="post-metadata">

**Author:** ![buggy](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/buggy/32/177_2.png) [@buggy](https://forum.serverless.com/u/buggy)\
**Post date:** [January 15, 2019, 10:23am UTC](https://forum.serverless.com/t/updating-s3-bucket-deletes-bucket-contents/6997/2 "2019-01-15T10:23:32Z")

</div>

It depends what you changed. Serverless uses CloudFormation so you can always look at the CloudFormation documents to see if changing a property will require the bucket to be replaced.
