事象
Amazon Linuxにてyum update
を行うと以下のように403のエラーとなる。
# yum update Amazon Linux 2023 repository 1.2 kB/s | 275 B 00:00 Errors during downloading metadata for repository 'amazonlinux': - Status code: 403 for https://al2023-repos-ap-northeast-1-de612dc2.s3.dualstack.ap-northeast-1.amazonaws.com/core/mirrors/2023.7.20250609/x86_64/mirror.list (IP: x.x.x.x) ... Error: Failed to download metadata for repo 'amazonlinux': Cannot prepare internal mirrorlist: Status code: 403 for https://al2023-repos-ap-northeast-1-de612dc2.s3.dualstack.ap-northeast-1.amazonaws.com/core/mirrors/2023.7.20250609/x86_64/mirror.list (IP: x.x.x.x) ... Error encountered while trying to retrieve release update information: Unable to retrieve release info data. Status code: 403 for https://al2023-repos-ap-northeast-1-de612dc2.s3.dualstack.ap-northeast-1.amazonaws.com/core/releasemd.xml (IP: x.x.x.x) Dependencies resolved. Nothing to do. Complete!
環境情報
- Amazon Linux 2023.7.20250609
原因/解決策
S3のVPCエンドポイントで必要なポリシーが入っていない。解消方法として、Resource欄にリポジトリ(S3)の情報を追加する。
{ "Version": "2012-10-17", "Statement": [ { "Sid": "Access-to-specific-bucket", "Effect": "Allow", "Principal": "*", "Action": [ "s3:ListBucket", "s3:GetObject", "s3:PutObject" ], "Resource": [ ... "arn:aws:s3:::al2023-repos-ap-northeast-1-de612dc2/*" ] } ] }
尚、同設定を行うと正常にyumコマンドが実行される。
# yum update Amazon Linux 2023 repository 52 MB/s | 39 MB 00:00 Amazon Linux 2023 Kernel Livepatch repository 105 kB/s | 17 kB 00:00 ... Dependencies resolved. Nothing to do. Complete!
以下、補足です。
補足
S3向けのゲートウェイ型エンドポイントを用意している場合、VPCの通信でリポジトリから情報を取得します。よって、冒頭に記載したエラーと同じメッセージの方は同事象の可能性があります。
ポリシー情報は以下のコマンドで確認ができ
$ aws ec2 describe-vpc-endpoints
PolicyDocumentの欄で許可しているリソースの情報が格納されていいます。
{ "VpcEndpoints": [ { "VpcEndpointId": "vpce-xx", "VpcEndpointType": "Gateway", "VpcId": "vpc-xx", "ServiceName": "com.amazonaws.ap-northeast-1.s3", "State": "available", "PolicyDocument": "{\"Version\":\"2012-10-17\",\"Statement\":...[\"s3:ListBucket\",\"s3:GetObject\",\"s3:PutObject\"],\"Resource\":[\""arn:aws:s3:::al2023-repos-ap-northeast-1-de612dc2/*\"]}]}", ...
以上、ご参考になれば幸いです。