##### SUMMARY
Example here is AWS account ID, which is clearly an integer-like thing. The keyed_group templating logic will error if it gets a type other than a string... but sometime after Ansible 2.9, it seems that I _can't_ cast it to a string

##### ISSUE TYPE
- Bug Report

##### COMPONENT NAME
lib/ansible/plugins/inventory/__init__.py

##### ANSIBLE VERSION
```
$ ansible --version
[WARNING]: You are running the development version of Ansible. You should only run Ansible from "devel" if you are modifying the Ansible engine, or trying out features under
development. This is a rapidly changing source of code and can become unstable at any point.
ansible 2.11.0.dev0
  config file = None
  configured module search path = ['/Users/alancoding/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /Users/alancoding/Documents/repos/ansible/lib/ansible
  ansible collection location = /Users/alancoding/.ansible/collections:/usr/share/ansible/collections
  executable location = /Users/alancoding/.virtualenvs/awx_collection/bin/ansible
  python version = 3.7.7 (default, Mar 10 2020, 15:43:03) [Clang 11.0.0 (clang-1100.0.33.17)]
```

##### CONFIGURATION
Defaults

##### OS / ENVIRONMENT
N/A


##### STEPS TO REPRODUCE
Inventory file `aws_ec2.yml`

```yaml
compose:
  ec2_account_id: owner_id
keyed_groups:
- key: ec2_account_id | string
  parent_group: accounts
  prefix: ''
  separator: ''
plugin: amazon.aws.aws_ec2
```

Command:

```
AWS_ACCESS_KEY_ID=<redacted> AWS_SECRET_ACCESS_KEY=<redacted> ANSIBLE_JINJA2_NATIVE=True ansible-inventory -i testing/awx_424_0bzcwopc/aws_ec2.yml --list --export -vvv
```

##### EXPECTED RESULTS
Behavior in 2.9 is that it gives JSON data for the inventory.

I think it also needs to be stated that input variables look like this:

```           
                         "ec2_account_id": "123456789",
                "owner_id": "123456789",
```


##### ACTUAL RESULTS

```
[WARNING]:  * Failed to parse /Users/alancoding/Documents/tower/testing/awx_424_0bzcwopc/aws_ec2.yml with auto plugin: Invalid group name format, expected a string or a list
of them or dictionary, got: <class 'int'>
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/inventory/manager.py", line 289, in parse_source
    plugin.parse(self._inventory, self._loader, source, cache=cache)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/plugins/inventory/auto.py", line 58, in parse
    plugin.parse(inventory, loader, path, cache=cache)
  File "/Users/alancoding/.ansible/collections/ansible_collections/amazon/aws/plugins/inventory/aws_ec2.py", line 644, in parse
    self._populate(results, hostnames)
  File "/Users/alancoding/.ansible/collections/ansible_collections/amazon/aws/plugins/inventory/aws_ec2.py", line 534, in _populate
    self._add_hosts(hosts=groups[group], group=group, hostnames=hostnames)
  File "/Users/alancoding/.ansible/collections/ansible_collections/amazon/aws/plugins/inventory/aws_ec2.py", line 569, in _add_hosts
    self._add_host_to_keyed_groups(self.get_option('keyed_groups'), host, hostname, strict=strict)
  File "/Users/alancoding/Documents/repos/ansible/lib/ansible/plugins/inventory/__init__.py", line 431, in _add_host_to_keyed_groups
    raise AnsibleParserError("Invalid group name format, expected a string or a list of them or dictionary, got: %s" % type(key))
```

No matter what I do, it doesn't seem to use this as a string.

Presumably, this may be something that can be reproduced with the constructed inventory plugin by itself, but I have not gotten that far yet.

So something is forcing this into an integer, and it wasn't there is 2.9. That's about the extent of what I know at this point.

__metaclass__ = type
import ast
import datetime
import os
import pkgutil
import pwd
import re
import time
from contextlib import contextmanager
from distutils.version import LooseVersion
from numbers import Number
from traceback import format_exc
try:
    from hashlib import sha1
except ImportError:
    from sha import sha as sha1
from jinja2.exceptions import TemplateSyntaxError, UndefinedError
from jinja2.loaders import FileSystemLoader
from jinja2.runtime import Context, StrictUndefined
from ansible import constants as C
from ansible.errors import AnsibleError, AnsibleFilterError, AnsiblePluginRemovedError, AnsibleUndefinedVariable, AnsibleAssertionError
from ansible.module_utils.six import iteritems, string_types, text_type
from ansible.module_utils.six.moves import range
from ansible.module_utils._text import to_native, to_text, to_bytes
from ansible.module_utils.common._collections_compat import Iterator, Sequence, Mapping, MappingView, MutableMapping
from ansible.module_utils.common.collections import is_sequence
from ansible.module_utils.compat.importlib import import_module
from ansible.plugins.loader import filter_loader, lookup_loader, test_loader
from ansible.template.safe_eval import safe_eval
from ansible.template.template import AnsibleJ2Template