S3 File Gatewayを介して作成されたオブジェクトにどのようなメタデータが付与されているのか確認してみた
S3 File Gatewayを介して作成したオブジェクトにどのようなメタデータが付与されるのか気になる
こんにちは、のんピ(@non____97)です。
皆さんはS3 File Gatewayを介して作成したオブジェクトにどのようなメタデータが付与されるのか気になったことはありますか? 私はあります。
以下で紹介されているとおり、ファイルのメタデータはS3オブジェクトのメタデータに保存されます。

抜粋 : AWS Storage Gateway AWS Black Belt Online Seminar P.25
では、どのようなメタデータが存在するのかな? と思いAWS公式ドキュメントを探してみたのですが、当該疑問点について説明したAWS公式ドキュメントはありませんでした。
ということで、実際に試してみます。
やってみた
NFSの場合
まずはNFSの場合です。
以下のようにS3 File GatewayにNFSファイル共有を用意しました。

用意したNFSファイル共有をマウントします。
$ sudo mount -t nfs -o nolock,hard 172.31.33.190:/sgw-2025-08-31-w5b1b /mnt/sgw
$ df -hT -t nfs4
Filesystem                          Type  Size  Used Avail Use% Mounted on
172.31.33.190:/sgw-2025-08-31-w5b1b nfs4  8.0E     0  8.0E   0% /mnt/sgw
マウント後、適当にファイルを作成します。
$ sudo mkdir -p /mnt/sgw/test
$ echo test > /mnt/sgw/test.txt
$ ls -ld /mnt/sgw/test
drwxr-xr-x. 1 nobody nobody 0 Aug 31 14:00 /mnt/sgw/test
$ ls -l /mnt/sgw/test
total 0
$ echo test | sudo tee /mnt/sgw/test/test.txt > /dev/null
$ ls -l /mnt/sgw/test
total 1
-rw-r--r--. 1 nobody nobody 5 Aug 31 14:02 test.txt
$ ls -ln /mnt/sgw/test
total 1
-rw-r--r--. 1 65534 65534 5 Aug 31 14:02 test.txt
作成後、NFSファイル共有と関連付けたS3バケットを確認するとs3://sgw-2025-08-31-w5b1b/test.txtというURIでオブジェクトが作成されていました。
こちらのオブジェクトにはメタデータとして以下が設定されていました。
| タイプ | キー | 値 | 
|---|---|---|
| システム定義 | Content-Type | text/plain | 
| ユーザー定義 | x-amz-meta-aws-sgw | e797c68970068bfd018e76c8d9f731eb13db93f859d2e75a36e0d56081fd400c | 
| ユーザー定義 | x-amz-meta-file-ctime | 1756648863554000000ns | 
| ユーザー定義 | x-amz-meta-file-group | 1000 | 
| ユーザー定義 | x-amz-meta-file-mtime | 1756648863554000000ns | 
| ユーザー定義 | x-amz-meta-file-owner | 1000 | 
| ユーザー定義 | x-amz-meta-file-permissions | 0664 | 
| ユーザー定義 | x-amz-meta-user-agent | aws-storage-gateway | 
| ユーザー定義 | x-amz-meta-user-agent-id | sgw-D5E2A9BC | 
また、s3://sgw-2025-08-31-w5b1b/test/のメタデータは以下のとおりです。
>  aws s3api head-object --bucket sgw-2025-08-31-w5b1b --key test/
{
    "AcceptRanges": "bytes",
    "LastModified": "2025-08-31T14:28:52+00:00",
    "ContentLength": 0,
    "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
    "ContentType": "application/octet-stream",
    "ServerSideEncryption": "AES256",
    "Metadata": {
        "user-agent": "aws-storage-gateway",
        "user-agent-id": "sgw-D5E2A9BC",
        "aws-sgw": "a0ca9a363dec9e2d98d7990abd2bfaefcd38e26fb5130b7c406864ad05519cad",
        "file-ctime": "1756650495599000000ns",
        "file-owner": "65534",
        "file-permissions": "0755",
        "file-group": "65534",
        "file-mtime": "1756648841831800556ns"
    }
}
NFSの世界のメタデータとしては以下が付与されることが分かります。
- ctime
- mtime
- group
- owner
- permission
実際のUIDやGIDと異なるのが気になりますね。
パーミッションと合わせて試しに変更します。
$ sudo chown root:root /mnt/sgw/test/test.txt
$ sudo chmod 400 /mnt/sgw/test/test.txt
$ sudo ls -ln /mnt/sgw/test
total 1
-r--------. 1 65534 65534 5 Aug 31 14:02 test.txt
test.txtオブジェクトのメタデータを確認します。
| タイプ | キー | 値 | 
|---|---|---|
| システム定義 | Content-Type | text/plain | 
| ユーザー定義 | x-amz-meta-aws-sgw | e797c68970068bfd018e76c8d9f731eb13db93f859d2e75a36e0d56081fd400c | 
| ユーザー定義 | x-amz-meta-file-ctime | 1756648863554000000ns | 
| ユーザー定義 | x-amz-meta-file-group | 1000 | 
| ユーザー定義 | x-amz-meta-file-mtime | 1756648863554000000ns | 
| ユーザー定義 | x-amz-meta-file-owner | 1000 | 
| ユーザー定義 | x-amz-meta-file-permissions | 0664 | 
| ユーザー定義 | x-amz-meta-user-agent | aws-storage-gateway | 
| ユーザー定義 | x-amz-meta-user-agent-id | sgw-D5E2A9BC | 
変更後10分ほど放置しましたが、特に変化はありませんでした。
SMBの場合
続いて、SMBの場合です。
以下のようにS3 File GatewayにSMBファイル共有を用意しました。

SMBファイル共有をZドライブにマウントします。
> net use Z: \\172.31.33.190\sgw-2025-08-31-nmk3t
Enter the user name for '172.31.33.190': Enter the password for 172.31.33.190:
The command completed successfully.
> Get-PSDrive Z
Name           Used (GB)     Free (GB) Provider      Root                                               CurrentLocation
----           ---------     --------- --------      ----                                               ---------------
Z                   0.00 8589934592.00 FileSystem    \\172.31.33.190\sgw-2025-08-31-n...
適当にファイルを作成します。
> mkdir z:\test
    Directory: Z:\
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         8/31/2025   2:07 PM                test
> echo test > Z:\test\test.txt
> ls Z:\test
    Directory: Z:\test
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
-a----         8/31/2025   2:07 PM             14 test.txt
作成後、SMBファイル共有と関連付けたS3バケットを確認するとs3://sgw-2025-08-31-nmk3t/test/test.txtというURIでオブジェクトが作成されていました。
こちらのオブジェクトにはメタデータとして以下が設定されていました。
| タイプ | キー | 値 | 
|---|---|---|
| システム定義 | Content-Type | text/plain | 
| ユーザー定義 | x-amz-meta-aws-sgw | 9052d2b33d8494839f873d7eb2388c037b56dbc700ff42a655d5ddfbd7d720fd | 
| ユーザー定義 | x-amz-meta-file-acl | EQUFFZmtvIwP/+b7vg//8MPcCfQDBQUVma28jA//5vu+D//ww9wJgQSEBAEAEPn/AQEA | 
| ユーザー定義 | x-amz-meta-file-ctime | 1756649241729000000ns | 
| ユーザー定義 | x-amz-meta-file-dosattr | 32 | 
| ユーザー定義 | x-amz-meta-file-group | 67179 | 
| ユーザー定義 | x-amz-meta-file-mtime | 1756649241725544398ns | 
| ユーザー定義 | x-amz-meta-file-owner | 67166 | 
| ユーザー定義 | x-amz-meta-file-permissions | 0777 | 
| ユーザー定義 | x-amz-meta-user-agent | aws-storage-gateway | 
| ユーザー定義 | x-amz-meta-user-agent-id | sgw-D5E2A9BC | 
また、s3://sgw-2025-08-31-nmk3t/test/のメタデータは以下のとおりです。
>  aws s3api head-object --bucket sgw-2025-08-31-nmk3t --key test/
{
    "AcceptRanges": "bytes",
    "LastModified": "2025-08-31T14:07:52+00:00",
    "ContentLength": 0,
    "ETag": "\"d41d8cd98f00b204e9800998ecf8427e\"",
    "ContentType": "application/octet-stream",
    "ServerSideEncryption": "AES256",
    "Metadata": {
        "user-agent": "aws-storage-gateway",
        "user-agent-id": "sgw-D5E2A9BC",
        "aws-sgw": "342916150b03d765cda733e8ed05c3b78668af34ec09f75f3095764b04e9173d",
        "file-acl": "EQUFFZmtvIwP/+b7vg//8MPcCfQDBQUVma28jA//5vu+D//ww9wJgQSEBAEAE/n/AQEA",
        "file-ctime": "1756649241689000000ns",
        "file-dosattr": "16",
        "file-owner": "67166",
        "file-permissions": "0777",
        "file-group": "67179",
        "file-mtime": "1756649241689000000ns"
    }
}
SMBの世界のメタデータとしては以下が付与されることが分かります。
- ctime
- mtime
- group
- owner
- permission
- dosattr
- acl
この状態でファイルを隠し属性に変更します。

すると、先ほどのオブジェクトのメタデータが以下のようになっていました。
| タイプ | キー | 値 | 
|---|---|---|
| システム定義 | Content-Type | text/plain | 
| ユーザー定義 | x-amz-meta-aws-sgw | ad5ff6b39d8413052160ceae0204a2e1d523da7a28aaba97ddcb0f6804ebec57 | 
| ユーザー定義 | x-amz-meta-file-acl | EQUFFZmtvIwP/+b7vg//8MPcCfQDBQUVma28jA//5vu+D//ww9wJgQSEBAEAEPn/AQEA | 
| ユーザー定義 | x-amz-meta-file-ctime | 1756649577391000000ns | 
| ユーザー定義 | x-amz-meta-file-dosattr | 34 | 
| ユーザー定義 | x-amz-meta-file-group | 67179 | 
| ユーザー定義 | x-amz-meta-file-mtime | 1756649241725544398ns | 
| ユーザー定義 | x-amz-meta-file-owner | 67166 | 
| ユーザー定義 | x-amz-meta-file-permissions | 0777 | 
| ユーザー定義 | x-amz-meta-user-agent | aws-storage-gateway | 
| ユーザー定義 | x-amz-meta-user-agent-id | sgw-D5E2A9BC | 
ctimeとmtimeが変わっている以外に、x-amz-meta-file-dosattrが32から34に変更していました。こちらがファイルの属性を指し示しているようですね。
続いてファイルをRead onlyに変更して、さらにAdministratorユーザーへの明示的なFull controlを与えます。

すると、test.txtオブジェクトのメタデータが以下のようにx-amz-meta-file-aclとx-amz-meta-file-dosattrの値が変わっていました。
| タイプ | キー | 値 | 
|---|---|---|
| システム定義 | Content-Type | text/plain | 
| ユーザー定義 | x-amz-meta-aws-sgw | f53331e21ecfe6c4239bb25dfa8002e5c7deaef2645501552df1e76a3ece8062 | 
| ユーザー定義 | x-amz-meta-file-acl | EQUFFZmtvIwP/+b7vg//8MPcCfQDBQUVma28jA//5vu+D//ww9wJgQSMBAIAAPn/BQUVma28jA//5vu+D//ww9wJ9AMAEPn/AQEA | 
| ユーザー定義 | x-amz-meta-file-ctime | 1756651438861000000ns | 
| ユーザー定義 | x-amz-meta-file-dosattr | 35 | 
| ユーザー定義 | x-amz-meta-file-group | 67179 | 
| ユーザー定義 | x-amz-meta-file-mtime | 1756649241725544398ns | 
| ユーザー定義 | x-amz-meta-file-owner | 67166 | 
| ユーザー定義 | x-amz-meta-file-permissions | 0777 | 
| ユーザー定義 | x-amz-meta-user-agent | aws-storage-gateway | 
| ユーザー定義 | x-amz-meta-user-agent-id | sgw-D5E2A9BC | 
なかなか良いですね。
どのようなメタデータを保持できるのかは事前に検証しよう
S3 File Gatewayを介して作成されたオブジェクトにどのようなメタデータが付与されているのか確認してみました。
ファイルのメタデータがそれぞれ分かりやすくオブジェクトのメタデータとして付与されていることが分かりました。特にSMBはリアルタイムに変動して分かりやすいですね。
とはいえ、この記事で扱ったファイルの属性が全てのメタデータではありません。メタデータについて細かい要件がある場合は事前に確認をしておくと安心でしょう。
この記事が誰かの助けになれば幸いです。
以上、クラウド事業本部 コンサルティング部の のんピ(@non____97)でした!











