# Upload links broken after S3 bucket change

**URL:** https://meta.discourse.org/t/upload-links-broken-after-s3-bucket-change/108351
**Category:** Support
**Created:** [February 5, 2019, 12:24am UTC](https://meta.discourse.org/t/upload-links-broken-after-s3-bucket-change/108351 "2019-02-05T00:24:29Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![jefe42](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jefe42/32/114804_2.png) [@jefe42](https://meta.discourse.org/u/jefe42)
#### Post date: [February 5, 2019, 12:24am UTC](https://meta.discourse.org/t/upload-links-broken-after-s3-bucket-change/108351/1 "2019-02-05T00:24:29Z")

</div>

I recently migrated my AWS organization from one region to another. That forced me to also move my S3 buckets with new names. I updated the settings in my site and did a rebake; however, it seems that when I change the s3 region option from the default (US East) to (US West), all the uploads are still referencing us-east-1.

I know the uploads are making it into the new bucket, as when I manually change any of the previews on the admin page from us-east-1 to us-west-2, the images are properly loading.

`<div class="uploaded-image-preview input-xxlarge" style="background-image: url(//my-new-bucket.s3.dualstack.us-east-1.amazonaws.com/original/1X/8e7492615a827a7e5dc550f8bfdc4854bc8b064d.png)">`

TO

`<div class="uploaded-image-preview input-xxlarge" style="background-image: url(//my-new-bucket.s3.dualstack.us-west-2.amazonaws.com/original/1X/8e7492615a827a7e5dc550f8bfdc4854bc8b064d.png)">`

As far as I can tell, it does not seem to be using my vanity _s3 cdn url_ as configured even after issuing these rebake commands:

```
cd /var/discourse
./launcher enter app
rake posts:rebake

```

Lastly, when I reviewed the error log, there’s still some reference to my old bucket:

> Could not find file in the store located at url: [//my-old-bucket.s3.amazonaws.com/original/1X/ea17a258eff7a95045bda914c10bac5a2de02c62.png](https://my-old-bucket.s3.amazonaws.com/original/1X/ea17a258eff7a95045bda914c10bac5a2de02c62.png)

Any help would be greatly appreciate! I’m currently running [v2.2.0 +4](https://github.com/discourse/discourse/compare/5ef75197da71eee76396479edae50fd2393d3cbe...stable).

 ![s3%20issue](https://global.discourse-cdn.com/meta/original/3X/2/3/2399f01d2b62bcbd3cce7f93c6f35e5a1a8ef43d.png)

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 6, 2019, 2:51pm UTC](https://meta.discourse.org/t/upload-links-broken-after-s3-bucket-change/108351/2 "2019-02-06T14:51:24Z")

</div>

A `rebake` is not enough, you’ll have to [do a `remap`](https://meta.discourse.org/t/replace-a-string-in-all-posts/48729) to change all the existing URLs.

```
discourse remap //my-new-bucket.s3.dualstack.us-east-1.amazonaws.com //my-new-bucket.s3.dualstack.us-west-2.amazonaws.com

```

---

<div class="post-metadata">

### Author: ![balupton](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/balupton/32/255461_2.png) [@balupton](https://meta.discourse.org/u/balupton)
#### Post date: [February 27, 2019, 11:34am UTC](https://meta.discourse.org/t/upload-links-broken-after-s3-bucket-change/108351/3 "2019-02-27T11:34:13Z")

</div>

To be clear, which bucket in that code snippet is the new bucket, and which is the old? As you’ve labelled them both the new bucket.

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 27, 2019, 11:36am UTC](https://meta.discourse.org/t/upload-links-broken-after-s3-bucket-change/108351/4 "2019-02-27T11:36:53Z")

</div>

I used OP’s strings (note the `us-east-1` in the 1st and `us-west-2` in the 2nd).

The remap command replaces the 1st argument by the 2nd 😉

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [March 29, 2019, 11:37am UTC](https://meta.discourse.org/t/upload-links-broken-after-s3-bucket-change/108351/5 "2019-03-29T11:37:02Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
