# swegym / getmoto__moto-7336 - taskset: [swegym](https://harnessreport.com/tasks/swegym.md) - difficulty: hard - category: debugging - language: - runnable from the site: no - agent timeout: 3000s ## Results by harness _none yet_ ## Instruction ``` Default IAM user is not support in AWS China. user/moto I have a code like that, ``` def assume_cross_account_role_via_arn(role_arn, role_session_name=None, region_name=None) -> boto3.Session: _session = boto3.Session(region_name=region_name) session = assume_role(_session, role_arn, RoleSessionName=role_session_name, region_name=region_name) logger.info("Role: %s has been successfully assumed.", role_arn) return session ``` When I use assume_role() in AWS China , the moto default user is `arn:aws:sts::123456789012:user/moto`. So it can not be assumed because of the different partition(aws-cn). And I have seen the code in https://github.com/getmoto/moto/blob/d98972ffc8c0cf67f7572478b722b0b59a446479/moto/sts/models.py#L189 ``` def get_caller_identity(self, access_key_id: str) -> Tuple[str, str, str]: assumed_role = self.get_assumed_role_from_access_key(access_key_id) if assumed_role: return assumed_role.user_id, assumed_role.arn, assumed_role.account_id iam_backend = iam_backends[self.account_id]["global"] user = iam_backend.get_user_from_access_key_id(access_key_id) if user: return user.id, user.arn, user.account_id # Default values in case the request does not use valid credentials generated by moto user_id = "AKIAIOSFODNN7EXAMPLE" arn = f"arn:aws:sts::{self.account_id}:user/moto" return user_id, arn, self.account_id ``` It's hard code. Maybe it's better to use the var in partition. ``` partition = boto3.Session().get_partition_for_region(region_name=region) arn = f"arn:{partition}:sts::{self.account_id}:user/moto" ``` By the way, how can I generate a new user to replace the default moto user ? Thank you ~ ``` --- Harness Report runs agent harnesses from their GitHub repos on Harbor tasks and records every model call. Every page is also `.md` and `.json`; index: https://harnessreport.com/llms.txt · MCP: https://harnessreport.com/mcp