Error uploading scripts and reports when using AWS S3 as STORAGE_BACKEND #8297

Closed
opened 2025-12-29 20:35:01 +01:00 by adam · 3 comments
Owner

Originally created by @richbibby on GitHub (Jul 5, 2023).

NetBox version

v3.5.4

Python version

3.10

Steps to Reproduce

  1. fresh install on Ubuntu 22.04, including the django-storages library
  2. add the following to configuration.py to configure the storage backend
STORAGE_BACKEND = 'storages.backends.s3boto3.S3Boto3Storage'
STORAGE_CONFIG = {
    'AWS_ACCESS_KEY_ID': '{KEY_ID}',
    'AWS_SECRET_ACCESS_KEY': '{SECRET_KEY}',
    'AWS_STORAGE_BUCKET_NAME': '{bucket-name}',
    'AWS_S3_REGION_NAME': '{region}',
}
  1. complete standard installation steps
  2. add a new script by uploading a file, and clicking create
    Screenshot 2023-07-05 at 16 34 51

Expected Behavior

scripts & reports honour the STORAGE_BACKEND engine. The script should be uploaded to the S3 bucket and appear under Customization-> Scripts in the UI.

On this same installation I can attach an image for a device, and it works OK, and the image file appears in a newly created directory called image-attachments in the same S3 bucket.

I would expect the script or a report to upload in the same way.

Observed Behavior

Server Error
A file permission error was detected while processing this request. Common causes include the following:

Insufficient write permission to the media root - The configured media root is . Ensure that the user NetBox runs as has access to write files to all locations within this path.

The complete exception is provided below:

<class 'PermissionError'>

[Errno 13] Permission denied: 'NewBranchScript.py'

Python version: 3.10.6
NetBox version: 3.5.4
Originally created by @richbibby on GitHub (Jul 5, 2023). ### NetBox version v3.5.4 ### Python version 3.10 ### Steps to Reproduce 1. fresh install on Ubuntu 22.04, including the `django-storages` library 2. add the following to `configuration.py` to configure the storage backend ``` STORAGE_BACKEND = 'storages.backends.s3boto3.S3Boto3Storage' STORAGE_CONFIG = { 'AWS_ACCESS_KEY_ID': '{KEY_ID}', 'AWS_SECRET_ACCESS_KEY': '{SECRET_KEY}', 'AWS_STORAGE_BUCKET_NAME': '{bucket-name}', 'AWS_S3_REGION_NAME': '{region}', } ``` 3. complete standard installation steps 4. add a new script by uploading a file, and clicking **create** <img width="991" alt="Screenshot 2023-07-05 at 16 34 51" src="https://github.com/netbox-community/netbox/assets/25981237/e1c0581c-e841-4d40-9856-ca576554f477"> ### Expected Behavior scripts & reports honour the `STORAGE_BACKEND` engine. The script should be uploaded to the S3 bucket and appear under **Customization**-> **Scripts** in the UI. On this same installation I can attach an image for a device, and it works OK, and the image file appears in a newly created directory called `image-attachments` in the same S3 bucket. I would expect the script or a report to upload in the same way. ### Observed Behavior ``` Server Error A file permission error was detected while processing this request. Common causes include the following: Insufficient write permission to the media root - The configured media root is . Ensure that the user NetBox runs as has access to write files to all locations within this path. The complete exception is provided below: <class 'PermissionError'> [Errno 13] Permission denied: 'NewBranchScript.py' Python version: 3.10.6 NetBox version: 3.5.4 ```
adam closed this issue 2025-12-29 20:35:02 +01:00
Author
Owner

@richbibby commented on GitHub (Jul 18, 2023):

@arthanson I have managed to work around this using s3fs: https://github.com/s3fs-fuse/s3fs-fuse on a system running Ubuntu 22.04

These commands will mount the scripts and reports directories to S3 folders and will write uploaded files to the S3 bucket:

s3fs mybucket:/scripts /opt/netbox/netbox/scripts -o passwd_file=${HOME}/.passwd-s3fs -o nonempty -o umask=022 -o uid={netbox_uid} -o allow_other
s3fs mybucket:/reports /opt/netbox/netbox/reports -o passwd_file=${HOME}/.passwd-s3fs -o nonempty -o umask=022- o uid={netbox_uid} -o allow_other

@richbibby commented on GitHub (Jul 18, 2023): @arthanson I have managed to work around this using s3fs: https://github.com/s3fs-fuse/s3fs-fuse on a system running Ubuntu 22.04 These commands will mount the scripts and reports directories to S3 folders and will write uploaded files to the S3 bucket: s3fs mybucket:/scripts /opt/netbox/netbox/scripts -o passwd_file=${HOME}/.passwd-s3fs -o nonempty -o umask=022 -o uid={netbox_uid} -o allow_other s3fs mybucket:/reports /opt/netbox/netbox/reports -o passwd_file=${HOME}/.passwd-s3fs -o nonempty -o umask=022- o uid={netbox_uid} -o allow_other
Author
Owner

@arthanson commented on GitHub (Sep 25, 2023):

@richbibby can this be closed? Or do you consider this a documentation issue?

@arthanson commented on GitHub (Sep 25, 2023): @richbibby can this be closed? Or do you consider this a documentation issue?
Author
Owner

@arthanson commented on GitHub (Sep 26, 2023):

After talking with Rich am closing

@arthanson commented on GitHub (Sep 26, 2023): After talking with Rich am closing
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#8297