fix: allow backup bucket health probe
Assistant: codex Assistant-Model: gpt-5.6-sol Assistant-Session: 01a02992-fff7-75c3-98ac-ca2afe0f7122
This commit is contained in:
parent
9c6b025226
commit
afed794843
1 changed files with 21 additions and 3 deletions
|
|
@ -84,18 +84,30 @@ policy = {
|
||||||
"Id": "resource-control-scoped-backup",
|
"Id": "resource-control-scoped-backup",
|
||||||
"Statement": [
|
"Statement": [
|
||||||
{
|
{
|
||||||
"Sid": "BackupListPrefix",
|
# HeadBucket is authorized by s3:ListBucket but carries no
|
||||||
|
# s3:prefix condition key. Keep this bucket-level probe explicit
|
||||||
|
# and TLS-only; object access remains restricted below.
|
||||||
|
"Sid": "BackupBucketProbe",
|
||||||
"Effect": "Allow",
|
"Effect": "Allow",
|
||||||
"Principal": {"SCW": f"application_id:{app}"},
|
"Principal": {"SCW": f"application_id:{app}"},
|
||||||
"Action": [
|
"Action": [
|
||||||
"s3:ListBucket",
|
"s3:ListBucket",
|
||||||
"s3:ListBucketMultipartUploads",
|
|
||||||
"s3:ListBucketVersions",
|
|
||||||
"s3:GetBucketLocation",
|
"s3:GetBucketLocation",
|
||||||
"s3:GetBucketVersioning",
|
"s3:GetBucketVersioning",
|
||||||
"s3:GetLifecycleConfiguration",
|
"s3:GetLifecycleConfiguration",
|
||||||
],
|
],
|
||||||
"Resource": [bucket],
|
"Resource": [bucket],
|
||||||
|
"Condition": {"Bool": {"aws:SecureTransport": "true"}},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Sid": "BackupListPrefix",
|
||||||
|
"Effect": "Allow",
|
||||||
|
"Principal": {"SCW": f"application_id:{app}"},
|
||||||
|
"Action": [
|
||||||
|
"s3:ListBucketMultipartUploads",
|
||||||
|
"s3:ListBucketVersions",
|
||||||
|
],
|
||||||
|
"Resource": [bucket],
|
||||||
"Condition": {"StringLike": {"s3:prefix": [prefix, prefix + "*"]}},
|
"Condition": {"StringLike": {"s3:prefix": [prefix, prefix + "*"]}},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
@ -147,6 +159,12 @@ bucket = os.environ["BUCKET"]
|
||||||
prefix = os.environ["PREFIX"]
|
prefix = os.environ["PREFIX"]
|
||||||
ok = prefix + ".policy-probe"
|
ok = prefix + ".policy-probe"
|
||||||
sib = "other-consumer/.policy-probe"
|
sib = "other-consumer/.policy-probe"
|
||||||
|
try:
|
||||||
|
c.head_bucket(Bucket=bucket)
|
||||||
|
print("head_bucket=ok")
|
||||||
|
except ClientError as e:
|
||||||
|
print("head_bucket=fail", e.response.get("Error", {}).get("Code"))
|
||||||
|
raise
|
||||||
try:
|
try:
|
||||||
c.put_object(Bucket=bucket, Key=ok, Body=b"ok")
|
c.put_object(Bucket=bucket, Key=ok, Body=b"ok")
|
||||||
c.delete_object(Bucket=bucket, Key=ok)
|
c.delete_object(Bucket=bucket, Key=ok)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue