AWSTemplateFormatVersion: '2010-09-09'
Parameters:
  AccessToAccountId:
    Type: String
    Description: The ID of the second AWS account.
    AllowedPattern: "[0-9]{12}"
    ConstraintDescription: Must be a valid AWS account ID.
    Default: 'ACCOUNT-B-ID'
Resources:
  CrossAccountRole:
    Type: AWS::IAM::Role
    Properties:
      RoleName: CrossAccountAdminRole
      AssumeRolePolicyDocument:
        Version: '2012-10-17'
        Statement:
          - Effect: Allow
            Principal:
              AWS:
              - Fn::Sub: arn:aws:iam::${AccessToAccountId}:root
            Action: sts:AssumeRole
      Policies:
        - PolicyName: AdministratorAccess
          PolicyDocument:
            Version: '2012-10-17'
            Statement:
              - Effect: Allow
                Action: '*'
                Resource: '*'
