Step 5. Create your MACH composer stack¶
MACH composer is undergoing a major, backwards compatible overhaul
MACH composer has been rewritten in Golang, coming from a Python version.We've done this because the Golang ecosystem is more suitable for a toollike this, as it is also the language in which Hashicorp builds Terraformitself.
Because of this, some commands might not be available yet in the Golang version; particularly themach-composer bootstrap
command is not available, which makes it a bit harder to start up. However, based on theexamples in the GitHub repository,you should be able to get started without thebootstrap
command.
For creating components, please instead ofmach-composer bootstrap component
, usemach-composer-cookiecutter.
We do currently recommend to use the latest version (2.14.x).
If you are still on the Python version, thebootstrap
command will still work.
To create a new MACH composer configuration file, run
mach-composerbootstrapconfig
A configuration will be created and can be used as input for MACH composer.
An example:
---mach_composer:version:1.0.0global:environment:testcloud:azureterraform_config:azure_remote_state:resource_group:my-shared-rgstorage_account:mysharedsaterracontainer_name:tfstatestate_folder:testazure:tenant_id:e180345a-b3e1-421f-b448-672ab50d8502subscription_id:086bd7e7-0755-44ab-a730-7a0b8ad4883fregion:westeuropesites:-identifier:my-siteendpoints:main:api.tst.mach-example.netcommercetools:project_key:my-site-tstclient_id:...client_secret:...scopes:manage_project:my-site-tst manage_api_clients:my-site-tst view_api_clients:my-site-tstlanguages:-en-GB-nl-NLcurrencies:-GBP-EURcountries:-GB-NLcomponents:-name:paymentvariables:STRIPE_ACCOUNT_ID:0123456789secrets:STRIPE_SECRET_KEY:secret-valuecomponents:-name:paymentsource:git::ssh://git@github.com/your-project/components/payment-component.git//terraformendpoints:main:mainversion:e638e57
SeeSyntax for all configuration options.
6. Deploy¶
You can deploy your current configuration by running
$mach-composerapply
If you wish to review the changes before applying them, run
$mach-composerplan
Using Docker image
You can invoke MACH by running the Docker image:$ docker run --rm --volume $(pwd):/code docker.pkg.github.com/mach-composer/mach-composer-cli/mach apply
You do need to provide the docker container with the necessary environment variables to be able to authenticate with the cloud provider. More info on that in thedeployment section
Example files¶
You can find example files needed for preparing the infrastructure and a configuration fileon GitHub in the/examples directory
Further reading¶
- See theCLI reference for more deployment options.
- Set up your CI/CD pipeline onGitLab,GitHub orAzure DevOps
- Encrypting your configuration with SOPS
- How to create anew MACH component
- Architectural Guidance