I encoutered a similar issue. In my case, the reason was that mylocal repo was too large.
So I integrated the old history into a single commit using https://stackoverflow.com/a/50996201/22434761 .
Then, I succeeded in pushing my local repo to CodeCommit.