Slide 14
Slide 14 text
14
カスタムポリシーチェックにアクセスチェックの更新 (preview)
CheckNoPublicAccess
~$ cat < bucket-policy.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
EOF
~$
~$ aws accessanalyzer check-no-public-access \
--policy-document file://bucket-policy.json \
--resource-type AWS::S3::Bucket --output json
{
"result": "FAIL",
"message": "The resource policy grants public access for the given resource
type.",
"reasons": [
{
"description": "Public access granted in the following statement with
index: 0.",
"statementIndex": 0
}
]
}
~$ cat < bucket-policy-new.json
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::123456789012:root"
},
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::your-bucket-name/*"
}
]
}
EOF
~$
~$ aws accessanalyzer check-no-public-access \
--policy-document file://bucket-policy-new.json \
--resource-type AWS::S3::Bucket --output json
{
"result": "PASS",
"message": "The resource policy does not grant public access for the given
resource type."
}
FAIL
PASS