MCPcopy Create free account
hub / github.com/awsdocs/aws-doc-sdk-examples / update_user

Function update_user

python/example_code/iam/user_wrapper.py:86–101  ·  view source on GitHub ↗

Updates a user's name. :param user_name: The current name of the user to update. :param new_user_name: The new name to assign to the user. :return: The updated user.

(user_name, new_user_name)

Source from the content-addressed store, hash-verified

84
85# snippet-start:[python.example_code.iam.UpdateUser]
86def update_user(user_name, new_user_name):
87 """
88 Updates a user's name.
89
90 :param user_name: The current name of the user to update.
91 :param new_user_name: The new name to assign to the user.
92 :return: The updated user.
93 """
94 try:
95 user = iam.User(user_name)
96 user.update(NewUserName=new_user_name)
97 logger.info("Renamed %s to %s.", user_name, new_user_name)
98 except ClientError:
99 logger.exception("Couldn't update name for user %s.", user_name)
100 raise
101 return user
102
103
104# snippet-end:[python.example_code.iam.UpdateUser]

Callers 1

usage_demoFunction · 0.85

Calls 1

updateMethod · 0.45

Tested by

no test coverage detected