DeMAF Transformations¶
This documentation describes in detail the transformations carried out by the DeMAF for each supported deployment technology. Technology-specific deployment models of these deployment technologies are transformed into a unified, technology-agnostic deployment model based on the Essential Deployment Metamodel (EDMM).
We currently support the transformation of the following deployment technologies, explained in detail in separate files:
| Deployment Technology | Transformation Documentation | Dev Version |
|---|---|---|
| Ansible | Ansible | Ansible-DEV |
| Bash | Bash | Bash-DEV |
| Docker | Docker | - |
| Helm | Helm | Helm-DEV |
| Kubernetes | Kubernetes | Kubernetes-DEV |
| Terraform | Terraform | Terraform-DEV |
| AWS Cloud Development Kit (CDK) | AWS CDK | AWSCDK-DEV |
For some deployment technologies, we provide a dev-version that reflects the current implementation state including where features are unfinished or need improvement.
Each file describes the technology-specific metamodel of the deployment technology, the mappings and transformation rules from this technology-specific metamodel to the EDMM, and which and how embedded deployment models are detected. In addition, it gives details on how this transformation is carried out. The transformation of most deployment technologies is carried out in 4 general steps:
- Step 1: Deployment Model Parser
- Step 2: Main M2M Transformation
- Step 3: Model Merger
- Step 4: Post M2M Transformation
EDMM¶
Here, we describe how the DeMAF implements the Essential Deployment Metamodel (EDMM). The DeMAF uses a general type system for Component and Relation types that we document in DeMAF Type Definitions.
Embedded Deployment Models¶
Often, a mix of deployment technologies are used to deploy software systems. To this end, deployment technologies provide means to embed the deployment models of other deployment technologies, leading to what we call heterogenuously nested deployment models. Moreover, we refer to the overall deployment model of the software system that contains all embedded deployment mdoels as the system deployment model. We distinguish between two different methods by which one deployment model can embed another deployment model:
Reference Embedding: The embedding deployment model references an external location where the embedded deployment model is defined (for example, a file).
Containment Embedding: The embedded deployment model is specified directly in the embedding deployment model.
A deployment technology can provide means to embed deployment models using either one or both of these methods. The following table shows the methods provided by the deployment technologies to embed deployment models and which of them are currently detected by the DeMAF.
| embeds → | Ansible | AWS CDK | Bash | Docker | Helm | Kubernetes | Terraform |
|---|---|---|---|---|---|---|---|
| Ansible | R | R, C | R | R | R, C | R | |
| AWS CDK | R, C | R | R | C | |||
| Bash | R | R | R | R | R | R | R |
| Docker | C | R | |||||
| Helm | R | C | |||||
| Kubernetes | R | ||||||
| Terraform | R | R, C | R | R | C | R |
R = reference embedding, C = containment embedding, bold = detected by the DeMAF
The following subsections explain each embedding in more detail, including technical means and constructs the embedding deployment technology provides to achieve it and how the DeMAF detects this embedding, if applicable.
Ansible¶
Documentation: Ansible Documentation
Ansible mostly embeds deployment models through dedicated modules provided in official or community collections.
Ansible → Ansible¶
Reference embedding: A playbook can include playbooks, task files, and roles that are defined in separate files and are executed as part of the playbook.
ansible.builtin.import_playbookimports another playbook file.ansible.builtin.import_tasksandansible.builtin.include_tasksimport task files statically or dynamically.- The
roleskeyword of a play,ansible.builtin.import_role, andansible.builtin.include_roleexecute roles, which are stored in separate directories or installed from Ansible Galaxy.
Ansible → Bash¶
Reference embedding: A task executes a shell script that is stored in a separate file.
ansible.builtin.scripttransfers a local script to the managed host and executes it there.
Containment embedding: A task contains shell commands that are executed on the managed host.
ansible.builtin.shellexecutes a command through a shell (/bin/shby default, configurable withexecutable), including pipes, redirects, and multi-line scripts.ansible.builtin.commandexecutes a command without a shell, i.e., without shell features such as pipes or environment variable expansion.
Ansible → Docker¶
Reference embedding: A task runs containers from or builds Docker images, which are defined by a Dockerfile in a separate file or are published in a registry.
community.docker.docker_containerruns a container from the image given byimage.community.docker.docker_imagepulls an image (source: pull) or builds it from a Dockerfile in the directory given bybuild.path(source: build).
Detection: For roles and hosts of plays with docker_container tasks, the DeMAF requests the analysis of the referenced image by the Docker plugin.
Ansible → Helm¶
Reference embedding: A task installs a Helm chart that is stored in a chart repository or in a local directory.
kubernetes.core.helminstalls a release of the chart given bychart_ref(a chart in an added repository, a local path, or a URL), optionally withchart_repo_urlandchart_version. Values can be contained in the task (release_values,set_values) or referenced (values_files).kubernetes.core.helm_repositoryadds a chart repository.
Ansible → Kubernetes¶
Reference embedding: A task applies Kubernetes manifests that are stored in separate files.
kubernetes.core.k8swithsrcapplies the manifest file at the given path.kubernetes.core.k8swithtemplaterenders a Jinja2 template of a manifest and applies it.
Containment embedding: A task contains Kubernetes objects directly in the playbook.
kubernetes.core.k8swithresource_definition(aliasdefinition) applies the Kubernetes objects specified inline in YAML.
Ansible → Terraform¶
Reference embedding: A task applies a Terraform configuration that is stored in a separate directory.
community.general.terraformrunsterraform apply(ordestroy) for the configuration inproject_path, with input variables given byvariablesorvariables_files.
AWS CDK¶
Documentation: AWS CDK Developer Guide, AWS CDK API Reference
The AWS CDK plugin analyzes the synthesized cloud assembly (cdk.out) instead of the CDK source code.
Thus, an embedding becomes visible only if the CDK constructs leave a trace in the synthesized CloudFormation templates or asset manifests.
This is the case for all embeddings described below.
AWS CDK → Bash¶
Reference embedding: An EC2 instance executes a shell script that is stored in a separate file when it boots.
UserData.addS3DownloadCommand(...)downloads a script file, e.g., uploaded as an S3 asset (aws_s3_assets.Asset), andUserData.addExecuteFileCommand(...)executes it.CloudFormationInitwithInitFile.fromAsset(...)andInitCommand.argvCommand(...)provisions and executes a script file via cfn-init.
Containment embedding: An EC2 instance executes shell commands that are contained in the CDK app when it boots.
UserData.forLinux().addCommands(...)andUserData.custom(...)add shell commands to the user data of anec2.Instanceor a launch template. They are synthesized into theUserDataproperty (Base64-encoded) ofAWS::EC2::InstanceorAWS::EC2::LaunchTemplateresources.CloudFormationInitwithInitCommand.shellCommand(...)executes a shell command via cfn-init.
AWS CDK → Docker¶
Reference embedding: A container or a Lambda function runs a Docker image that is published in a registry or built from a Dockerfile in a separate directory.
ecs.ContainerImage.fromRegistry(...)andecs.ContainerImage.fromEcrRepository(...)reference an existing image. The image is synthesized into theImageproperty of the container definitions ofAWS::ECS::TaskDefinitionresources.ecs.ContainerImage.fromAsset(...),lambda.DockerImageCode.fromImageAsset(...), andecr_assets.DockerImageAssetbuild an image from a Dockerfile in a local directory during deployment and push it to Amazon ECR. The directory is listed in the asset manifest (<stack>.assets.json) of the cloud assembly (see Assets and the AWS CDK).
AWS CDK → Helm¶
Reference embedding: A Helm chart that is stored in a chart repository or in a local directory is installed on an EKS cluster.
cluster.addHelmChart(...)andeks.HelmChart(options) install a release of the chart given bychart,repository, andversion, or of a local chart uploaded as an S3 asset (chartAsset). Values can be contained in the CDK app (values). They are synthesized into a custom resource of typeCustom::AWSCDK-EKS-HelmChart.
AWS CDK → Kubernetes¶
Containment embedding: Kubernetes objects applied on an EKS cluster that are specified in the CDK app.
cluster.addManifest(...)andeks.KubernetesManifestapply Kubernetes objects specified as objects in the programming language of the CDK app. They are synthesized into a custom resource of typeCustom::AWSCDK-EKS-KubernetesResource, which contains the objects as JSON in itsManifestproperty.cluster.addCdk8sChart(...)applies a chart defined with cdk8s.
These are containment embeddings because the Kubernetes objects are meant to be defined directly in the CDK app, not in an external file. Even if the objects are read from an external manifest file in the CDK app, they are contained in the synthesized custom resource.
Bash¶
Documentation: GNU Bash Reference Manual
Bash scripts embed deployment models of other deployment technologies by calling their command line interfaces with the location of the deployment model.
Bash → Ansible¶
Reference embedding:
ansible-playbook <playbook>executes a playbook.ansible-pull -U <repository> <playbook>checks out a repository and executes a playbook on the local host.
Bash → AWS CDK¶
Reference embedding:
cdk deploysynthesizes and deploys the CDK app in the current directory (or given by--app).cdk synthsynthesizes the cloud assembly without deploying it.
Bash → Bash¶
Reference embedding:
source <script>or. <script>executes another script in the current shell.bash <script>or./<script>executes another script in a new shell.
Bash → Docker¶
Reference embedding:
docker build -f <Dockerfile> <context>builds an image from a Dockerfile.docker run <image>anddocker pull <image>run or pull an image from a registry.
Bash → Helm¶
Reference embedding:
helm install <release> <chart>andhelm upgrade --install <release> <chart>install a release of a chart from a repository added byhelm repo addor from a local directory. Values can be passed by--setor referenced by-f <values file>.
Detection: The DeMAF detects helm install commands and passes the complete command line, including values given by --set or -f, on to the Helm plugin together with all previous helm repo commands of the script.
The Helm plugin executes the helm repo commands and renders the chart by executing the command with install replaced by template, so that the values are considered.
Values files given by -f with a relative path are resolved against the working directory of the Helm plugin instead of the directory of the script.
helm upgrade --install commands are not detected.
Bash → Kubernetes¶
Reference embedding:
kubectl apply -f <path>andkubectl create -f <path>apply the manifests in the given file or directory.kubectl apply -k <directory>applies a Kustomize configuration.
Detection: The DeMAF detects kubectl commands and requests the analysis of the manifests at the path given by -f.
Bash → Terraform¶
Reference embedding:
terraform applyandterraform -chdir=<dir> applyapply the configuration in the current or given directory.
Detection: The DeMAF detects terraform commands and requests the analysis of the configuration in the given directory.
Docker¶
Documentation: Docker Documentation, Dockerfile reference
Docker → Bash¶
Containment embedding: A Dockerfile contains shell commands that are executed when the image is built.
RUN <command>(shell form) executes the command with/bin/sh -c(configurable withSHELL).RUN <<EOF ... EOFexecutes a multi-line script (heredoc, requires BuildKit).
Docker → Docker¶
Reference embedding: An image is built on top of other images that are defined by separate Dockerfiles and published in a registry.
FROM <image>sets the base image.COPY --from=<image>copies files from another image.
This embedding can only be detected from the Dockerfile, not from the built image: an image does not record which images it was built upon.
Although its layers and its history (docker history) include those of its base images, they do not contain their names.
Only optional metadata, such as provenance attestations or the OCI annotations org.opencontainers.image.base.name and org.opencontainers.image.base.digest, can reference the base images.
Helm¶
Documentation: Helm Documentation
Helm → Helm¶
Reference embedding: A chart depends on other charts (subcharts), which are installed together with it.
dependenciesinChart.yamlreference charts byname,version, andrepository, optionally withcondition,tags, andalias.helm dependency updatedownloads them into thecharts/directory of the chart.- Charts can also contain their subcharts directly in the
charts/directory (see Subcharts and Global Values).
Detection: Subcharts are not analyzed as separate embedded deployment models.
However, helm template renders the manifests of the subcharts together with the manifests of the chart, so they are part of the Kubernetes deployment model analyzed by the Kubernetes plugin (see Helm → Kubernetes).
This requires the subcharts to be present in the charts/ directory, which is the case for packaged charts from a chart repository; the Helm plugin does not download missing dependencies.
Helm → Kubernetes¶
Containment embedding: A chart contains Kubernetes manifests, which are rendered and applied when the chart is installed.
- The files in
templates/are Kubernetes manifests with Go template directives that are rendered with the values of the chart. - The files in
crds/are plain manifests of custom resource definitions.
Detection: The DeMAF renders the chart with helm template, including the given values and the subcharts, and requests the analysis of the resulting Kubernetes deployment model by the Kubernetes plugin.
Kubernetes¶
Documentation: Kubernetes Documentation
Kubernetes → Docker¶
Reference embedding: Containers run Docker images that are published in a registry.
imageofcontainersandinitContainersin the Pod specification of Pods and of the Pod templates of Deployments, StatefulSets, DaemonSets, ReplicaSets, Jobs, and CronJobs.
Detection: For Deployments, StatefulSets, and ReplicaSets, the DeMAF requests the analysis of the referenced images by the Docker plugin.
Terraform¶
Documentation: Terraform Documentation, Terraform Registry
Terraform → Ansible¶
Reference embedding: A Terraform configuration executes a playbook that is stored in a separate file.
- The
ansible_playbookresource of theansible/ansibleprovider executes the playbook given byplaybookon the host given byname, with variables given byextra_vars. - The
ansible_hostandansible_groupresources define the inventory.
Terraform → Bash¶
Reference embedding: A Terraform configuration executes shell scripts that are stored in separate files.
- The
remote-execprovisioner withscriptorscriptscopies scripts to the created resource and executes them there.
Containment embedding: A Terraform configuration contains shell commands.
- The
local-execprovisioner executescommandon the machine running Terraform, with/bin/sh -cby default (configurable withinterpreter). - The
remote-execprovisioner withinlineexecutes commands on the created resource.
Provisioners can be attached to any resource, or to a terraform_data (formerly null_resource) resource if they are not related to a specific resource.
Terraform → Docker¶
Reference embedding: A Terraform configuration runs containers from or builds Docker images, which are defined by a Dockerfile in a separate file or are published in a registry.
- The
docker_containerresource of thekreuzwerker/dockerprovider runs a container from the image given byimage. - The
docker_imageresource pulls an image or builds it from a Dockerfile (buildblock withcontextanddockerfile). - Resources of cloud providers reference images, e.g., the container definitions of
aws_ecs_task_definition.
Detection: For docker_container resources, the DeMAF requests the analysis of the referenced image by the Docker plugin.
Terraform → Helm¶
Reference embedding: A Terraform configuration installs a Helm chart that is stored in a chart repository or in a local directory.
- The
helm_releaseresource of thehashicorp/helmprovider installs a release of the chart given bychart,repository, andversion, or of a local chart given by its path inchart. The chart can also be given as a local path, as a URL of a packaged chart, or from an OCI registry (repository = "oci://..."). Values can be contained in the configuration (set,set_list,set_sensitive,values) or referenced (values = [file("values.yaml")]).
Detection: For each helm_release resource, the DeMAF creates the following Helm commands and requests their analysis by the Helm plugin:
- If the
repositoryis a URL:helm repo add <chart> <repository> helm install <name> <repository or chart>/<chart>, extended by--set <name>=<value>for eachsetentry and by--version <version>
Only values given by set are considered; values given by values, set_list, or set_sensitive are not.
Resources without name or chart, or with a set entry without name or value, are skipped.
Note
The --version option is appended to the helm install command without a separating space.
Terraform → Kubernetes¶
Containment embedding: A Terraform configuration contains Kubernetes objects, specified in HCL.
- The resources of the
hashicorp/kubernetesprovider represent Kubernetes objects, e.g.,kubernetes_deployment_v1,kubernetes_stateful_set_v1,kubernetes_service_v1, orkubernetes_persistent_volume_claim_v1. - The
kubernetes_manifestresource contains any Kubernetes object as an HCL object inmanifest.
Even if the objects are read from a manifest file, e.g., with yamldecode(file(...)), they are contained in the configuration as HCL objects.
Detection: The DeMAF extracts a Kubernetes deployment model from the following resources, stores it in the models service, and requests its analysis by the Kubernetes plugin. Before, references to variables and other resources in the arguments of the resources are resolved.
| Resource type | Kubernetes object |
|---|---|
kubernetes_deployment, kubernetes_deployment_v1, kubernetes_stateful_set, kubernetes_stateful_set_v1 |
Deployment |
kubernetes_service |
Service |
kubernetes_persistence_volume_claim, kubernetes_persistence_volume_claim_v1 |
Persistent Volume Claim |
Note
The resource types for persistent volume claims are misspelled: the Terraform Kubernetes provider names them kubernetes_persistent_volume_claim(_v1), so persistent volume claims are currently not extracted. kubernetes_service_v1 is not extracted either.
Terraform → Terraform¶
Reference embedding: A Terraform configuration calls modules, which are Terraform configurations stored in a separate directory or published in a registry.
- The
moduleblock references the module bysource(a local path, a Terraform registry address, a Git repository, an HTTP URL, or an S3 bucket), optionally withversion, and passes input variables.
Diagram Overview¶
The following diagram shows an overview of the methods provided by the deployment technologies to embed deployment models (reference embeddings are denoted as aggregations, and containment embeddings are denoted as compositions).
Deployment technologies that can embed deployment models of the same technology by reference (e.g., Terraform modules or Docker base images) are marked with the stereotype <<selfEmbedding>>:
classDiagram
class Ansible
class Bash
class Docker
class Helm
class Kubernetes
class Terraform
class AWSCDK["AWS CDK"]
<<selfEmbedding>> Ansible
<<selfEmbedding>> Bash
<<selfEmbedding>> Docker
<<selfEmbedding>> Helm
<<selfEmbedding>> Terraform
Ansible o-- Bash
Ansible *-- Bash
Ansible o-- Docker
Ansible o-- Helm
Ansible o-- Kubernetes
Ansible *-- Kubernetes
Ansible o-- Terraform
AWSCDK o-- Bash
AWSCDK *-- Bash
AWSCDK o-- Docker
AWSCDK o-- Helm
AWSCDK *-- Kubernetes
Bash o-- Ansible
Bash o-- AWSCDK
Bash o-- Docker
Bash o-- Helm
Bash o-- Kubernetes
Bash o-- Terraform
Docker *-- Bash
Helm *-- Kubernetes
Kubernetes o-- Docker
Terraform o-- Ansible
Terraform o-- Bash
Terraform *-- Bash
Terraform o-- Docker
Terraform o-- Helm
Terraform *-- Kubernetes