I have a submodule in my git repository and my directory structure is like,
app
-- folder1
-- folder2
-- submodule @5855
I have deployed
After banging my head against this all day, I've found a simple solution (for Code Pipeline) that doesn't require any SSH key juggling in the buildspec. I am using Bitbucket but I would think this would work for other providers. I'm also cloning my submodule via https, I'm not sure if that's a requirement or not.
Configure your source to do a full clone of the repository. This will pass along the git metadata that you need.
Configure your build role to add a customer-managed UseConnection permission to give your build action access to the credentials you configured for your source. Documentation from AWS here: https://docs.aws.amazon.com/codepipeline/latest/userguide/troubleshooting.html#codebuild-role-connections
Set up your env to include git-credential-helper: yes and clone the submodule in your buildspec.yml:
And that's it! Submodule will be available for build, and without having to do a bunch of key configuration for every submodule you want to use.
Maybe a good addition to the documentation if this ends up being useful for people.