• Document Up to Date
  • Updated On 4.0.3

Blob Stores Configuration

The Blob Stores configuration file allows you to configure 0 or more stores for assets with the corresponding information required by the store being used. To modify the Blob Stores configuration, click on projectTools from the bottom of the Sidebar, then click on Configuration and select Blob Stores from the list.

Configurations - Open Blob Stores Configuration

Sample

Here’s a sample Blob Stores Configuration file (click on the triangle on the left to expand/collapse):

Sample "blob-stores-config.xml"
CRAFTER_HOME/data/repos/sites/SITENAME/sandbox/config/studio/blob-stores-config.xml
 1<?xml version="1.0" encoding="UTF-8"?>
 2<!--
 3  ~ Copyright (C) 2007-2024 Crafter Software Corporation. All Rights Reserved.
 4  ~
 5  ~ This program is free software: you can redistribute it and/or modify
 6  ~ it under the terms of the GNU General Public License as published by
 7  ~ the Free Software Foundation, either version 3 of the License, or
 8  ~ (at your option) any later version.
 9  ~
10  ~ This program is distributed in the hope that it will be useful,
11  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
12  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  ~ GNU General Public License for more details.
14  ~
15  ~ You should have received a copy of the GNU General Public License
16  ~ along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  -->
18
19<!--
20    Blob stores configuration file.
21
22    For every store you need to specify:
23    <blobStore>
24        <id/>
25        <type/>
26        <pattern/>
27        <mappings>
28            <mapping>
29                <publishingTarget/>
30                <storeTarget/>
31                <prefix/>
32            </mapping>
33        </mappings>
34        <configuration/>
35    </blobStore>
36
37    id:	a unique id for the store
38    type: the type of store to use
39    pattern: the regex to match file paths
40    mappings.mapping.publishingTarget: the name of the publishing storeTarget (preview, staging, live)
41    mappings.mapping.storeTarget: the name of the storeTarget inside the store
42    mappings.mapping.prefix: the prefix to use for all paths (optional)
43    configuration: configuration specific for the store type
44
45   Every store can require additional properties.
46-->
47<blobStores>
48    <!--
49      AWS S3 Store
50
51      Configuration properties:
52
53        <credentials>
54            <accessKey/>
55            <secretKey/>
56        </credentials>
57        <region/>
58        <endpoint/>
59        <pathStyleAccess/>
60
61        credentials.accessKey: AWS access key (optional)
62        credentials.secretKey: AWS secret key (optional)
63        region: AWS region for the service (optional)
64        pathStyleAccess: indicates if path style access should be used for all requests (defaults to false)
65      -->
66
67    <blobStore>
68        <id>s3-store</id>
69        <type>s3BlobStore</type>
70        <pattern>^/static-assets(?!/(app|css|js|fonts|tracking|seo)/)(.*)</pattern>
71        <mappings>
72            <mapping>
73                <publishingTarget>preview</publishingTarget>
74                <storeTarget>${env:PREVIEW_BUCKET_NAME_PATTERN}</storeTarget>
75                <prefix>${env:PREVIEW_BUCKET_PREFIX_PATTERN}</prefix>
76            </mapping>
77            <mapping>
78                <publishingTarget>staging</publishingTarget>
79                <storeTarget>${env:STAGING_BUCKET_NAME_PATTERN}</storeTarget>
80                <prefix>${env:STAGING_BUCKET_PREFIX_PATTERN}</prefix>
81            </mapping>
82            <mapping>
83                <publishingTarget>live</publishingTarget>
84                <storeTarget>${env:LIVE_BUCKET_NAME_PATTERN}</storeTarget>
85                <prefix>${env:LIVE_BUCKET_PREFIX_PATTERN}</prefix>
86            </mapping>
87        </mappings>
88        <configuration>
89            <region>us-east-1</region>
90            <pathStyleAccess>${env:AWS_S3_PATH_STYLE_ACCESS}</pathStyleAccess>
91            <endpoint>${env:AWS_S3_ENDPOINT}</endpoint>
92        </configuration>
93    </blobStore>
94
95</blobStores>


For better security and control, we recommend setting an AWS profile via the crafter-setenv.sh file instead of configuring the encrypted credentials in the blob stores configuration file. This allows you to have an IAM user per developer, which is a better approach than a single user whose credentials are included (encrypted) in the configuration file. In this way, if you need to rotate or remove the credentials of a single user, the access of other users won’t be affected.

To set an AWS profile, using your favorite editor, open CRAFTER_HOME/bin/crafter-setenv.sh and add the following:

export AWS_PROFILE=YOUR_AWS_PROFILE

where YOUR_AWS_PROFILE is the AWS profile you wish to use for the blob store. See here for more information on configuring AWS profiles.

When using an AWS profile, you can now remove the <credentials /> section in your blob stores configuration file.

Remember to restart your CrafterCMS install for the changes you made to take effect.

See Publishing Assets in External Storage for an example of using the blob stores configuration

Using AWS Service Roles

CrafterCMS supports AWS access without using access/secret keys, by setting AWS service roles on your machine

Simply follow the instructions here for attaching an IAM role to your instance: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/iam-roles-for-amazon-ec2.html#attach-iam-role

Remember to remove the <credentials /> section in your blob stores configuration file.