Add detached pipeline and deployment workflow templates
Files
2While GitLab CI documentation confirms that there is no dependency scanner for Terraform, the jobs will be skipped, so I think is safe not to include this line. Trying to be future proof and not modify autodevops when not necessary.
Edited by Dr Abraham Martin
Some SAST needs to be enabled for the deployment repos, reading GitLab documentation we can see that we should be executing at least,
Gitleaks
,TruffleHog
,Kubesec
. As with others, I believe that GitLab SAST Template should be sufficiently clever to skip those that do not apply to the repo, and thus, this line shouldn't be necessary.
I think having all these exceptions is showing that probably we are not doing it properly to make it work with AutoDevOps. I believe this is because we are executing CD jobs in the Infrastructure as code (IAC) repository. IAC still requires Gitlab CI pipelines as our infrastructure is code, so it needs testing, SAST, etc.
If we look at this CI template there is nothing in there is nothing in here that uses any code of the IAC repo. When deploying, it does not even uses the build step, or any terraform code.
The only thing that we use from the repo are the secrets. I wonder then if we are architecting our repos wrong and we need:
- WebApp repo. Webapp code. Normal AutoDevOps but with review apps. Maybe review apps deployment should used the CD repo defined below?
- Infra as code repo. Terraform code for the infrastructure. Normal AutoDevOps for checking dependencies, secrets, test, etc. Deployment happens only once (or rarely when the infra definition changes). No need for auto-deployment of infra.
- CD repo. Will only contain gitlab-ci.yml file as code. That file will only import this template. Deployment secrets will only be stored as CI env vars in this repo. Will have a button to deploy to production, after a a staging deployment has happened DAST and E2E tests have been executed against staging (probably calling the webapp repo which will contain the e2e test code).
How do we deal with projects with multiple webapps? E.g. https://gitlab.developers.cam.ac.uk/uis/devops/uga/deploy/-/merge_requests/19/diffs
As long as all the deployment jobs extend
.cloud-run-deploy
then adding extra jobs for multiple webapps should require minimal configuration. As has been done in uis/devops/uga/deploy!19,SERVICE_PREFIX
should be added as a variable to.cloud-run-deploy
that permits it to be configured for multiple webapps.