Unless you know the root password you won't be able to get root access to fix the /etc/passwd and /etc/group files. What you could do is:
- Stop the instance
- Create a new instance with the same AMI id
- Disconnect the volume from the first instance and connect it to the new instance
- Mount the volume and fix the config files
- Umount and disconnect the original instance's volume
- Connect the volume to the original instance
A more specific guide can be found at http://amazonserver.blogspot.nl/2013/01/recover-broken-amazon-ec2-instance.html