pip download -r requirements.txt -d wheelhouse `
--only-binary=:all: `
--platform manylinux2014_x86_64 `
--implementation cp `
--python-version 312 `
--abi cp312
#!/usr/bin/env bash
set -eu
APP_DIR="$(cd "$(dirname "$0")" && pwd)"
# vendor を最優先に通す
export PYTHONPATH="${APP_DIR}/vendor:${PYTHONPATH:-}"
export PYTHONNOUSERSITE=1
exec python "${APP_DIR}/main.py" "$@"
import boto3, yaml, sys
print("boto3:", boto3.__version__)
print("yaml:", yaml.__version__ if hasattr(yaml, "__version__") else "ok")
print("sys.path[0:3]:", sys.path[:3])
~/app/test.sh -c "import boto3, logging; logging.basicConfig(level=logging.DEBUG); boto3.set_stream_logger('botocore'); s3=boto3.client('s3'); print(s3.list_buckets())"
# どこで止まっているか詳細表示(ページャ無効&タイムアウト短縮)
aws --debug --no-cli-pager \
--cli-connect-timeout 3 --cli-read-timeout 5 \
iam list-attached-role-policies --role-name MyEC2Role
# 1) DNS 解決できる?
getent hosts iam.amazonaws.com || nslookup iam.amazonaws.com
# 2) 443/TCP に届く?(3秒で諦める)
timeout 3 bash -c 'cat </dev/null >/dev/tcp/iam.amazonaws.com/443' && echo TCP_OK || echo TCP_FAIL
TOKEN=$(curl -sS --connect-timeout 2 --max-time 2 -X PUT -H "X-aws-ec2-metadata-token-ttl-seconds: 21600" http://169.254.169.254/latest/api/token) && echo "TOKEN_LEN=${#TOKEN}" && curl -sS --connect-timeout 2 --max-time 2 -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/iam/info || echo "IMDS_REQ_ERR"
~/app/run.sh -c "import faulthandler,sys,time,boto3; from botocore.config import Config; \
faulthandler.enable(); faulthandler.dump_traceback_later(5, file=sys.stderr); \
s3=boto3.client('s3',config=Config(region_name='ap-northeast-1',connect_timeout=3,read_timeout=10)); \
print(s3.list_buckets()); faulthandler.cancel_dump_traceback_later()"
~/app/test.sh -c "import boto3; from botocore.config import Config; c=boto3.client('s3',config=Config(region_name='ap-northeast-1')); print('endpoint=', c.meta.endpoint_url)"