The MACH composer cloud component registry provides an API where you can register and retrieve components and their versions, so that you can guarantee that a component-version and its accompanying artifact, actually exist. This will make your MACH composer deployment pipelines more stable.
Pushing a new component version can be done by executing the below command from the git clone of your component (or from within a CI/CD pipeline).
$ mach-composer cloud register-component-version
--organization $MCC_ORGANISATION --project $MCC_PROJECT $MCC_COMPONENT --auto
Only register a version, if there is an artifact.
Pushing a new version should only be done after an artifact was actually created and published to your artifact repository.
If your using GitHub Actions, we have created a convenient GitHub Action for registering versions, that you can simply include in an existing component pipeline.
How does it work?¶
We introduce an additional step to the component deployment sequence, by connecting that sequence to MACH composer cloud.
Then when running the
mach-composer update command, instead of fetching the
latest component versions, MACH composer will fetch the latest versions from
MACH composer cloud.
Why do we need a registry?¶
MACH composer is in the business of deploying components as part of a coherent composable architecture. It provides tools to coordinate this and make this easier.
Components are in fact simple Terraform modules that are usually containing a microservice that's deployed in for example AWS Lambda or Fargate.
In your MACH composer configuration you configure the components that you use in you project, as well as the version of components. Just like the example below.
- name: api-service
- name: auth-service
Then, using the
mach-composer update command, MACH composer will check the
source repository for new versions that might be available.
$ mach-composer update
Updates for auth-service (19ffb8b...7e746bb)
7e746bb: Only add *.go source files to archive (Michael van Tellingen email@example.com)
92f14ba: Remove unused function (Michael van Tellingen firstname.lastname@example.org)
Updates for api-service (0771f35...66e74f4)
66e74f4: Only add *.go files to artifact zip (Michael van Tellingen email@example.com)
After updating and running
mach-composer apply, usually some Terraform code
will naively take this version information and use it to deploy either a Lambda
or Docker container by building an artifact name like this:
Usually this works fine, but it occasionally happens that the zip file does not
exist, in case a CI/CD build has failed to produce the artifact. This will cause
mach-composer apply execution to fail - sometimes silently.
Our solution to this is to provide a way to register 'deployable versions' with MACH composer cloud, as part of the component CI/CD workflow: after successfully building and storing the component artifact, it must be registered with the MACH composer API.