Sets the specified version of the specified policy as the policy's default (operative) version.
This operation affects all users, groups, and roles that the policy is attached to. To list the users, groups, and roles that the policy is attached to, use ListEntitiesForPolicy.
For information about managed policies, see Managed policies and inline policies in the IAM User Guide.
Parameters:
-
policy_arn
(arnType)
–
The Amazon Resource Name (ARN) of the IAM policy whose default version you want to set.
For more information about ARNs, see Amazon Resource Names (ARNs) in the Amazon Web Services General Reference.
-
version_id
(policyVersionIdType)
–
The version of the policy to set as the default (operative) version.
For more information about managed policy versions, see Versioning for managed policies in the IAM User Guide.
Raises:
-
InvalidInputException
–
The request was rejected because an invalid or out-of-range value was supplied for an input parameter.
-
LimitExceededException
–
The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.
-
NoSuchEntityException
–
The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.
-
ServiceFailureException
–
The request processing has failed because of an unknown error, exception or failure.
-
UnknownServiceError
–
The service returned an error code this client does not model.
Source code in docs_src/capo_iam/_services/async_iam.py
| async def set_default_policy_version(
self,
policy_arn: "capo_iam.types.arn_type.arnType",
version_id: "capo_iam.types.policy_version_id_type.policyVersionIdType",
*,
config_overrides: Optional[AsyncIAMClientConfig] = None,
) -> None:
"""<p>Sets the specified version of the specified policy as the policy's default (operative) version.</p> <p>This operation affects all users, groups, and roles that the policy is attached to. To list the users, groups, and roles that the policy is attached to, use <a href="https://docs.aws.amazon.com/IAM/latest/APIReference/API_ListEntitiesForPolicy.html">ListEntitiesForPolicy</a>.</p> <p>For information about managed policies, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-vs-inline.html">Managed policies and inline policies</a> in the <i>IAM User Guide</i>.</p>
Args:
policy_arn: <p>The Amazon Resource Name (ARN) of the IAM policy whose default version you want to set.</p> <p>For more information about ARNs, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html">Amazon Resource Names (ARNs)</a> in the <i>Amazon Web Services General Reference</i>.</p>
version_id: <p>The version of the policy to set as the default (operative) version.</p> <p>For more information about managed policy versions, see <a href="https://docs.aws.amazon.com/IAM/latest/UserGuide/policies-managed-versions.html">Versioning for managed policies</a> in the <i>IAM User Guide</i>.</p>
Raises:
capo_iam.errors.invalid_input_exception.InvalidInputException: <p>The request was rejected because an invalid or out-of-range value was supplied for an input parameter.</p>
capo_iam.errors.limit_exceeded_exception.LimitExceededException: <p>The request was rejected because it attempted to create resources beyond the current Amazon Web Services account limits. The error message describes the limit exceeded.</p>
capo_iam.errors.no_such_entity_exception.NoSuchEntityException: <p>The request was rejected because it referenced a resource entity that does not exist. The error message describes the resource.</p>
capo_iam.errors.service_failure_exception.ServiceFailureException: <p>The request processing has failed because of an unknown error, exception or failure.</p>
capo_iam.errors.UnknownServiceError: The service returned an error code this client does not model.
"""
async def _handler(
req: "AsyncOperationRequest[capo_iam.types.set_default_policy_version_request.SetDefaultPolicyVersionRequest]",
) -> AsyncOperationResponse[None]:
import capo_iam._operations.aws_identity_management_v20100508.set_default_policy_version
(
output,
http_response,
) = await capo_iam._operations.aws_identity_management_v20100508.set_default_policy_version.async_set_default_policy_version(
req.options, req.input
)
return AsyncOperationResponse(output=output, response=http_response)
interceptors_, options_ = self.operation_options(
config_overrides, OperationLogging("SetDefaultPolicyVersion")
)
input_: capo_iam.types.set_default_policy_version_request.SetDefaultPolicyVersionRequest = {
"policy_arn": policy_arn,
"version_id": version_id,
}
response = await aexecute_pipeline(
AsyncOperationRequest(input=input_, options=options_),
handler=_handler,
interceptors=list(interceptors_),
)
await response.response.aclose()
return response.output
|