Mixins
The mixins key in component.yaml allows you to download additional files and overlay them on the vendored component. This is useful for adding or replacing files that are not part of the original component source.
Schema
spec:
mixins:
- uri: https://raw.githubusercontent.com/cloudposse/terraform-null-label/0.25.0/exports/context.tf
filename: context.tf
- uri: https://raw.githubusercontent.com/cloudposse/terraform-aws-components/{{.Version}}/modules/datadog-agent/introspection.mixin.tf
version: 1.398.0
filename: introspection.mixin.tf
Attributes
uriThe URL to download the mixin file from. Supports the same protocols as the
source.uriattribute: HTTP, HTTPS, Git, S3, GCP, and OCI.Golang templates are supported in the URI. If
versionis provided,{{.Version}}will be replaced with the version value.versionOptional version to substitute into
{{.Version}}placeholders in theuri. Each mixin can have its own version independent of the main source version.filenameThe filename to save the downloaded file as in the component directory. This allows you to rename files or ensure they have the correct name.
Mixins override files from
sourcewith the samefilename(e.g.context.tfwill overridecontext.tffrom thesource).
How Mixins Work
Mixins are processed after the main source is downloaded. All mixins are processed in the order they are declared in the list.
This means:
- The component source files are downloaded first
- Each mixin file is downloaded and placed in the component directory
- If a mixin has the same filename as a source file, the mixin overwrites the source file
Example: Replacing context.tf
A common use case is to replace the context.tf file from a component with a newer version:
apiVersion: atmos/v1
kind: ComponentVendorConfig
metadata:
name: vpc-flow-logs-bucket-vendor-config
description: Source and mixins config for vendoring of 'vpc-flow-logs-bucket' component
spec:
source:
uri: github.com/cloudposse/terraform-aws-components.git//modules/vpc-flow-logs-bucket?ref={{.Version}}
version: 1.398.0
included_paths:
- "**/*.tf"
- "**/*.tfvars"
- "**/*.md"
# Exclude context.tf since we'll replace it with a mixin
excluded_paths:
- "**/context.tf"
mixins:
# Download a newer version of context.tf
- uri: https://raw.githubusercontent.com/cloudposse/terraform-null-label/0.25.0/exports/context.tf
filename: context.tf
Example: Adding Multiple Mixins
You can add multiple mixin files to a component:
spec:
source:
uri: github.com/cloudposse/terraform-aws-components.git//modules/vpc?ref={{.Version}}
version: 1.398.0
mixins:
# Add context.tf
- uri: https://raw.githubusercontent.com/cloudposse/terraform-null-label/0.25.0/exports/context.tf
filename: context.tf
# Add an introspection mixin from another component
- uri: https://raw.githubusercontent.com/cloudposse/terraform-aws-components/{{.Version}}/modules/datadog-agent/introspection.mixin.tf
version: 1.398.0
filename: introspection.mixin.tf
# Add a custom providers configuration
- uri: https://example.com/terraform/providers.tf
filename: providers.tf
When using mixins, consider excluding the files you intend to replace in the excluded_paths of the source configuration. This makes your intent clear and avoids downloading files that will be overwritten.