check_access_not_granted
¶
check_access_not_granted(
policy_document: AccessCheckPolicyDocument,
access: AccessList,
policy_type: AccessCheckPolicyType,
*,
config_overrides: Optional[AccessAnalyzerClientConfig] = None,
) -> CheckAccessNotGrantedResponse
Checks whether the specified access isn't allowed by a policy.
Parameters:
-
policy_document(AccessCheckPolicyDocument) –The JSON policy document to use as the content for the policy.
-
access(AccessList) –An access object containing the permissions that shouldn't be granted by the specified policy. If only actions are specified, IAM Access Analyzer checks for access to peform at least one of the actions on any resource in the policy. If only resources are specified, then IAM Access Analyzer checks for access to perform any action on at least one of the resources. If both actions and resources are specified, IAM Access Analyzer checks for access to perform at least one of the specified actions on at least one of the specified resources.
-
policy_type(AccessCheckPolicyType) –The type of policy. Identity policies grant permissions to IAM principals. Identity policies include managed and inline policies for IAM roles, users, and groups.
Resource policies grant permissions on Amazon Web Services resources. Resource policies include trust policies for IAM roles and bucket policies for Amazon S3 buckets.
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. Restrictive identity policy.
>>> client.check_access_not_granted(access=[{'actions': ['s3:PutObject']}], policy_document='{"Version":"2012-10-17","Id":"123","Statement":[{"Sid":"AllowJohnDoe","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:user/JohnDoe"},"Action":"s3:GetObject","Resource":"*"}]}', policy_type='RESOURCE_POLICY')
Passing check. Restrictive S3 Bucket resource policy.
>>> client.check_access_not_granted(access=[{'resources': ['arn:aws:s3:::sensitive-bucket/*']}], policy_document='{"Version":"2012-10-17","Id":"123","Statement":[{"Sid":"AllowJohnDoe","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:user/JohnDoe"},"Action":"s3:PutObject","Resource":"arn:aws:s3:::non-sensitive-bucket/*"}]}', policy_type='RESOURCE_POLICY')
Failing check. Permissive S3 Bucket resource policy.
>>> client.check_access_not_granted(access=[{'resources': ['arn:aws:s3:::my-bucket/*']}], policy_document='{"Version":"2012-10-17","Id":"123","Statement":[{"Sid":"AllowJohnDoe","Effect":"Allow","Principal":{"AWS":"arn:aws:iam::123456789012:user/JohnDoe"},"Action":"s3:PutObject","Resource":"arn:aws:s3:::my-bucket/*"}]}', policy_type='RESOURCE_POLICY')
Source code in docs_src/capo_accessanalyzer/_services/access_analyzer.py
353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 | |