check_no_public_access
¶
check_no_public_access(
policy_document: AccessCheckPolicyDocument,
resource_type: AccessCheckResourceType,
*,
config_overrides: Optional[AccessAnalyzerClientConfig] = None,
) -> CheckNoPublicAccessResponse
Checks whether a resource policy can grant public access to the specified resource type.
Parameters:
-
policy_document(AccessCheckPolicyDocument) –The JSON policy document to evaluate for public access.
-
resource_type(AccessCheckResourceType) –The type of resource to evaluate for public access. For example, to check for public access to Amazon S3 buckets, you can choose
AWS::S3::Bucketfor the resource type.For resource types not supported as valid values, IAM Access Analyzer will return an error.
Raises:
-
AccessDeniedException–You do not have sufficient access to perform this action.
-
InternalServerException–Internal server error.
-
InvalidParameterException–The specified parameter is invalid.
-
ThrottlingException–Throttling limit exceeded error.
-
UnprocessableEntityException–The specified entity could not be processed.
-
ValidationException–Validation exception error.
-
UnknownServiceError–The service returned an error code this client does not model.
Examples:
Passing check. S3 Bucket policy without public access.
>>> client.check_no_public_access(policy_document='{"Version":"2012-10-17","Statement":[{"Sid":"Bob","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::111122223333:user/JohnDoe"},"Action":["s3:GetObject"]}]}', resource_type='AWS::S3::Bucket')
Failing check. S3 Bucket policy with public access.
>>> client.check_no_public_access(policy_document='{"Version":"2012-10-17","Statement":[{"Sid":"Bob","Effect":"Allow","Principal":"*","Action":["s3:GetObject"]}]}', resource_type='AWS::S3::Bucket')