need to make cross account role to verify aws SSM automation

I need to make a simple ssm automation report that lists roles that allow cross access.

this ssm automation definition should do the trick but I am failing to make a role that allows another account to assume it, so that I can test it. it cannot be this hard to make a cross account role.

{
  "schemaVersion": "0.3",
  "description": "Cross account role report. This automation document will list out all roles that allow cross account access.",
  "assumeRole": "arn:aws:iam::###########:role/automation_executor",
  "mainSteps": [
    {
      "name": "RunScript",
      "action": "aws:executeScript",
      "isEnd": true,
      "onCancel": "Abort",
      "onFailure": "Abort",
      "inputs": {
        "Runtime": "python3.11",
        "Handler": "script_handler",
        "Script": "import boto3nimport jsonndef send_email(subject, body, recipient):n    ses = boto3.client('ses')n    ses.send_email(n        Source='[email protected]',n        Destination={'ToAddresses': [recipient]},n        Message={n            'Subject': {'Data': subject},n            'Body': { 'Text': { 'Data': body}}n        }n    )ndef script_handler(event, context):n    cross_account_roles = []n    account_id = context.get('global:ACCOUNT_ID')n    iam = boto3.client('iam')n    roles = iam.list_roles()n    for role in roles['Roles']:n        role_detail = iam.get_role(RoleName=role['RoleName'])n        trust_policy = role_detail['Role']['AssumeRolePolicyDocument']n        for statement in trust_policy['Statement']:n            if 'AWS' in statement['Principal']:n                principal_account_id = statement['Principal']['AWS'].split(':')[4]n                if principal_account_id != account_id:n                    cross_account_roles.append(role['Arn'])n    return {'status': 'success', 'cross_account_roles': cross_account_roles}"
      }
    }
  ]
}

it is made by this terraform that make the automation and a role that should allow access by a role in another account. The problem is AWS validates that the role in the other account exists. so I made the role in the other account but apparently the other account has to allow my account to list roles.

All I want to do is make a role in my account where it thinks a role in another account can assume it

resource "aws_ssm_document" "example" {
  name          = "CrossAccountRoles"
  document_type = "Automation"

  content = <<DOC
{
  "schemaVersion": "0.3",
  "description": "Cross account role report. This automation document will list out all roles that allow cross account access.",
  "assumeRole": "arn:aws:iam::##########:role/automation_executor",
  "mainSteps": [
    {
      "name": "RunScript",
      "action": "aws:executeScript",
      "isEnd": true,
      "onCancel": "Abort",
      "onFailure": "Abort",
      "inputs": {
        "Runtime": "python3.11",
        "Handler": "script_handler",
        "Script": "import boto3nimport jsonndef send_email(subject, body, recipient):n    ses = boto3.client('ses')n    ses.send_email(n        Source='[email protected]',n        Destination={'ToAddresses': [recipient]},n        Message={n            'Subject': {'Data': subject},n            'Body': { 'Text': { 'Data': body}}n        }n    )ndef script_handler(event, context):n    cross_account_roles = []n    account_id = context.get('global:ACCOUNT_ID')n    iam = boto3.client('iam')n    roles = iam.list_roles()n    for role in roles['Roles']:n        role_detail = iam.get_role(RoleName=role['RoleName'])n        trust_policy = role_detail['Role']['AssumeRolePolicyDocument']n        for statement in trust_policy['Statement']:n            if 'AWS' in statement['Principal']:n                principal_account_id = statement['Principal']['AWS'].split(':')[4]n                if principal_account_id != account_id:n                    cross_account_roles.append(role['Arn'])n    return {'status': 'success', 'cross_account_roles': cross_account_roles}"
      }
    }
  ]
}
DOC
}

resource "aws_iam_role" "automation_executor" {
  name = "automation_executor"
  assume_role_policy = jsonencode({
    Version = "2012-10-17",
    Statement = [
      {
        Action = "sts:AssumeRole",
        Principal = {
          Service = "ssm.amazonaws.com"
        }
        Effect = "Allow"
      }
    ]
  })
}

resource "aws_iam_role_policy_attachment" "automation_executor_policy" {
  role       = aws_iam_role.automation_executor.name
  policy_arn = "arn:aws:iam::aws:policy/AdministratorAccess"
}


resource "aws_iam_role" "test_cross_acct_role" {
  name = "test_cross_acct_role"
  assume_role_policy = jsonencode({
    Version = "2012-10-17",
    Statement = [
      {
        Action = "sts:AssumeRole",
        Principal = {
          AWS = "arn:aws:iam::####new account###:role/fake_role"
        },
        Effect = "Allow"
      }
    ]
  })
}

resource "aws_iam_role_policy" "test_cross_acct_role_policy" {
  name = "test_cross_acct_role_policy"
  role = aws_iam_role.test_cross_acct_role.id

  policy = jsonencode({
    Version = "2012-10-17",
    Statement = [
      {
        Action = "s3:ListBucket",
        Resource = "*",
        Effect = "Allow"
      }
    ]
  })
}

any suggestions

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật