# AWS S3 filesystem CDN

**URL:** <https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941>\
**Category:** General Questions (EN)\
**Created:** [13. August 2020 um 10:24 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941 "2020-08-13T10:24:30Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yafar\_iSi](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/yafar_isi/32/10765_2.png) [@Yafar\_iSi](https://forum.shopware.com/u/Yafar_iSi)\
**Post date:** [13. August 2020 um 10:24 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/1 "2020-08-13T10:24:30Z")

</div>

I followed the S3 documentation ([https://docs.shopware.com/en/shopware-platform-dev-en/how-to/use-s3-datastorage](https://docs.shopware.com/en/shopware-platform-dev-en/how-to/use-s3-datastorage)) but is not very complete  
I manage to store the resources in the AWS bucket but it has some performance issues  
It does not compress the files

This is without the CDN

![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/3/3b6f11b9c5b8c56255c3ba88325dd4c744c3885d.png)

And this is with the CDN active

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/a/a9e793123c921a4d595a0afc54f78115b6113345.png)

&nbsp;

This is my code in config/packages/shopware.yml:

```
shopware:
    filesystem:
      public:
        url: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private
      theme:
        url: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private
      asset:
        url: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private
      sitemap:
        url: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private

```

&nbsp;

Do I miss something?

It pushes my site performance (lighthouse) like 20points down

---

<div class="post-metadata">

**Author:** ![musikdiscount24](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@musikdiscount24](https://forum.shopware.com/u/musikdiscount24)\
**Post date:** [19. Oktober 2020 um 14:43 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/2 "2020-10-19T14:43:48Z")

</div>

Hello,

have you found a solution for your problem?

Would be glad to know.

Greetings

---

<div class="post-metadata">

**Author:** ![Yafar\_iSi](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/yafar_isi/32/10765_2.png) [@Yafar\_iSi](https://forum.shopware.com/u/Yafar_iSi)\
**Post date:** [23. Oktober 2020 um 08:06 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/3 "2020-10-23T08:06:23Z")

</div>

Yes, I found the reason and the solution

_Feel free to find me in Slack „[shopwarecommunity.slack.com](http://shopwarecommunity.slack.com)“ @ TaiKamilla_

The problem was that my SW config file config/packages/shopware.yml&nbsp;for the CDN and the CDN was incomplete.

The problem is that I was using the ‚url: „[https://s3.eu-central-1.amazonaws.com/%env](https://s3.eu-central-1.amazonaws.com/%25env)(AWS\_BUCKET)%“‘

and that address is direct&nbsp;to the bucket and does not accept headers, you need to do it to the cloudfront service instead&nbsp;

**SOLUTION** &nbsp;

For this, you need an AWS bucket and an AWS cloudfront to the bucket, make sure you can access the files from the bucket from the cloudfront provided URL

Then

1. Go to the .env file on your SW installation and add this

2 Then go to&nbsp;config/packages/shopware.yml and replace the content with this (feel free to modify „region“,&nbsp; „endpoint“ and „endpoint“ or anything else)

```
shopware:
    filesystem:
      public:
        url: "https://%env(AWS_DOMAIN)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private
      private:
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "private" # On private adapters need this to be private
      theme:
        url: "https://%env(AWS_DOMAIN)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private
      asset:
        url: "https://%env(AWS_DOMAIN)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private
      sitemap:
        url: "https://%env(AWS_DOMAIN)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private

```

&nbsp;

---

<div class="post-metadata">

**Author:** ![musikdiscount24](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@musikdiscount24](https://forum.shopware.com/u/musikdiscount24)\
**Post date:** [26. Oktober 2020 um 13:12 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/4 "2020-10-26T13:12:19Z")

</div>

Hello,

ah, i see. Thank you!

But as far as i can see there are no variables for „AWS\_SECRET\_ACCESS\_KEY“ and „AWS\_ACCESS\_KEY\_ID“ in the shopware.yml file. Or is it not necessary to set these at options or wherever?

Is it not possible like this?!

```
shopware:
    filesystem:
      public:
        url: "https://%env(AWS_DOMAIN)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private
              credentials:
                key: "%env(AWS_ACCESS_KEY_ID)%"
                secret: "%env(AWS_SECRET_ACCESS_KEY)%"

```

Thank you for your answers!!!

---

<div class="post-metadata">

**Author:** ![Yafar\_iSi](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/yafar_isi/32/10765_2.png) [@Yafar\_iSi](https://forum.shopware.com/u/Yafar_iSi)\
**Post date:** [26. Oktober 2020 um 13:49 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/5 "2020-10-26T13:49:32Z")

</div>

Hey, did you try my solution anyway?

“AWS\_SECRET\_ACCESS\_KEY” and “AWS\_ACCESS\_KEY\_ID”&nbsp;it does not show in&nbsp;shopware.yml  
but is an SW naming for the bucket credentials in /vendor/aws/aws-sdk-php/src/Credentials/CredentialProvider.php

 ![](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/9/9194173c49e4fe8fb7102363b2b45ef8deb08202.png)

---

<div class="post-metadata">

**Author:** ![musikdiscount24](https://avatars.discourse-cdn.com/v4/letter/m/ac8455/32.png) [@musikdiscount24](https://forum.shopware.com/u/musikdiscount24)\
**Post date:** [26. Oktober 2020 um 14:54 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/6 "2020-10-26T14:54:46Z")

</div>

Hello,

yes, i tried it and it works. I was just wondering about the fact, that i don’t need the Access-Key.

Thank you! You helped me a lot! 🙂

> _Feel free to find me in Slack „[shopwarecommunity.slack.com](http://shopwarecommunity.slack.com)“&nbsp;@&nbsp;TaiKamilla_

Btw. i am not invited 😉

Best regards!&nbsp;

---

<div class="post-metadata">

**Author:** ![shyim](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/shyim/32/7681_2.png) [@shyim](https://forum.shopware.com/u/shyim)\
**Post date:** [26. Oktober 2020 um 14:57 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/7 "2020-10-26T14:57:25Z")

</div>

@musikdiscount24‍ You can join with [https://slack.shopware.com](https://slack.shopware.com)

---

<div class="post-metadata">

**Author:** ![Yafar\_iSi](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/yafar_isi/32/10765_2.png) [@Yafar\_iSi](https://forum.shopware.com/u/Yafar_iSi)\
**Post date:** [26. Oktober 2020 um 14:58 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/8 "2020-10-26T14:58:23Z")

</div>

You don’t need to be invited  
Just go here&nbsp;[https://slack.shopware.com](https://slack.shopware.com/)  
and create an account

Also would be great if you can mark the&nbsp;answer as solved&nbsp; ![Wink](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/b3785da0cbf2c8566cb535dcf55b2730b5224899.png "Wink")

---

<div class="post-metadata">

**Author:** ![Yafar\_iSi](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/yafar_isi/32/10765_2.png) [@Yafar\_iSi](https://forum.shopware.com/u/Yafar_iSi)\
**Post date:** [28. Oktober 2020 um 09:06 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/9 "2020-10-28T09:06:52Z")

</div>

Hi&nbsp;@musikdiscount24‍

I have a question since you use an AWS CDN

I am experiencing slow down on theme and plugin installation

without the CDN the theme compilation takes around 30-40 seconds

but with the CDN is like 180 seconds (3min)

are you experiencing a slow down in this?

---

<div class="post-metadata">

**Author:** ![klug](https://avatars.discourse-cdn.com/v4/letter/k/dc4da7/32.png) [@klug](https://forum.shopware.com/u/klug)\
**Post date:** [11. August 2021 um 09:10 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/10 "2021-08-11T09:10:58Z")

</div>

Hi Yafar\_iSi,

i have tried your solution but it doesn’t work.

In the .env file:  
Should the parameter be inside ‚xxx‘ or without ‚‘?

like:  
AWS\_DOMAIN=‚XXX‘  
AWS\_ACCESS\_KEY\_ID=‚XXX‘  
AWS\_SECRET\_ACCESS\_KEY=‚xxx‘  
AWS\_BUCKET=‚xxx‘

are these parameters correct?

```auto
public:
        url: "https://%env(AWS_DOMAIN)%"
        type: "amazon-s3"
        config:
            bucket: "%env(AWS_BUCKET)%"
            region: "eu-central-1"
            endpoint: "https://s3.eu-central-1.amazonaws.com/%env(AWS_BUCKET)%"
            root: "/"
            options:
              visibility: "public" # On private adapters need this to be private

```

Best regards!

---

<div class="post-metadata">

**Author:** ![toco3](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@toco3](https://forum.shopware.com/u/toco3)\
**Post date:** [5. November 2023 um 13:04 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/11 "2023-11-05T13:04:18Z")

</div>

Thank you for all your hints.  
I’d had also some Issues connecting a Shopware 6.5.6.1 to AWS S3 / CloudFront

I need the following adaptions to config/packages/z-shopware.yml in comparison to the one of @Yafar_iSi :

```auto
endpoint: "https://s3.eu-central-1.amazonaws.com"

```

if I add the bucket as proposed the bucket name is twice in the url and does not work

```auto
           root: ""

```

If I add „/“ for root I get a directory with the name „/“ in the root of my s3 bucket with all stuff inside…

Beside configuring the CNAMES for S3 and CloudFront I had some CORS issues.

For CloudFront I use this settings for the behaivor:

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/3X/7/d/7d5610f6fdefe2dec2e7d54cb38e0cfb861a1150.png)

and added a custom Header to the S3 origin:

```auto
[
    {
        "AllowedHeaders": [
            "Authorization"
        ],
        "AllowedMethods": [
            "GET",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 3000
    }
]

```

For the S3 Bucket I have this access policies:

```auto
{
    "Version": "2012-10-17",
    "Statement": [
        {
            "Effect": "Allow",
            "Principal": "*",
            "Action": [
                "s3:GetObjectVersionAcl",
                "s3:GetObjectVersionTorrent",
                "s3:GetObject",
                "s3:GetObjectAcl",
                "s3:GetObjectTorrent",
                "s3:GetObjectVersion"
            ],
            "Resource": "arn:aws:s3:::static.shirt-helden.shop/*"
        }
    ]
}

```

and this CORS settings:

```auto
[
    {
        "AllowedHeaders": [
            "Authorization"
        ],
        "AllowedMethods": [
            "GET",
            "HEAD"
        ],
        "AllowedOrigins": [
            "*"
        ],
        "ExposeHeaders": [],
        "MaxAgeSeconds": 3000
    }
]

```

With all my tests, sometimes the directories and their content like bundles, theme, thumbnail got created - some times not.

These commands helped to get everything up and running:  
./bin/console cache:clear  
./bin/console theme:compile  
./bin/console media:generate-thumbnails --strict -v  
./bin/console system:update:finish

Perhaps this can help someone having the same issues as me - took me about an day to figure this all out 😮

---

<div class="post-metadata">

**Author:** ![toco3](https://avatars.discourse-cdn.com/v4/letter/t/6a8cbe/32.png) [@toco3](https://forum.shopware.com/u/toco3)\
**Post date:** [22. Dezember 2023 um 16:51 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/12 "2023-12-22T16:51:32Z")

</div>

one additional information:

for everyone who can open the backend only in Firefox:

make sure that you disabled the Admin Worker in config/packages/z-shopware.yaml:  
shopware:  
admin\_worker:  
enable\_admin\_worker: false

(Admin worker should be disabled on production server anyway)

---

<div class="post-metadata">

**Author:** ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)\
**Post date:** [6. März 2024 um 07:05 UTC](https://forum.shopware.com/t/aws-s3-filesystem-cdn/68941/13 "2024-03-06T07:05:44Z")

</div>

I have the same issue – some thumbnails just do not get generated.

When I run `media:generate-thumbnails --strict -v`, I get the following output for a lot of files:

```plaintext
  Cannot process file 2505600920-06 (id: f57c3d5ae20d4b208a111cc90d71d7fe) due error: The file for media object with id f57c3d5ae20d4b208a111cc90d71d7fe is not supported for creating thumbnails.

```

It sounds like there is something wrong with the original image, which I doubt, because its just too many and they are good enough for Shopware 5. Now I have to figure out, whats wrong with these images or why sw6 does not like them.

Did you found out already, @toco3 ?
