Artifacts in Infrahub are generated outputs created by applying transformations to data retrieved from GraphQL queries. They represent the final deliverable of the data transformation process, such as device configurations, documentation, or data exports.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/OpsMill/infrahub/llms.txt
Use this file to discover all available pages before exploring further.
What are Artifacts?
An artifact is a stored output generated by:- Executing a GraphQL query to retrieve data
- Applying a transformation (Jinja2 or Python) to that data
- Storing the result with metadata and versioning
Artifact Definitions
Artifact definitions specify how artifacts should be generated. They are configured in your repository’s.infrahub.yml file:
Configuration Options
Required Fields
- name: Human-readable name describing the artifact
- artifact_name: Unique identifier for the artifact type
- transformation: Name of the Jinja2 or Python transformation to use
- targets: Group or kind of objects to generate artifacts for
- content_type: MIME type of the generated content
Content Types
Supported content types:text/plain- Plain text files (configurations, scripts)application/json- JSON dataapplication/yaml- YAML datatext/markdown- Markdown documentationapplication/xml- XML data- Custom content types for specific use cases
Parameters
Parameters define how to extract variables from target objects for the GraphQL query:Artifact Generation Process
Artifact Generation Workflow
- Target Selection: Identify objects matching the
targetsgroup - Parameter Extraction: Extract query variables from each target
- Query Execution: Run the GraphQL query with variables
- Transformation: Apply the Jinja2 template or Python transform
- Content Processing: Format content based on
content_type - Checksum Calculation: Generate MD5 checksum of content
- Change Detection: Compare with existing artifact checksum
- Storage: Store new artifact or reference existing one
Artifact Storage
Artifacts are stored with comprehensive metadata:Storage Properties
- Immutable: Once created, artifact content never changes
- Versioned: Each change creates a new artifact version
- Checksummed: MD5 hash ensures content integrity
- Linked: Artifacts track their definition, transformation, and query
Example: Network Device Configuration
Complete example generating device startup configurations:1. Define GraphQL Query
2. Create Jinja2 Template
3. Configure in .infrahub.yml
4. Generated Artifact
Artifact Validation
Artifacts can be validated before creation using artifact checks:- Template syntax errors
- Transformation execution failures
- Content type mismatches
- Timeout violations
Artifact Status
Artifacts track their generation status:- Success: Artifact generated successfully
- Error: Generation failed (with error message)
- Pending: Generation in progress
Working with Artifacts
Triggering Artifact Generation
Artifacts can be generated:- Automatically: When target objects change
- On-demand: Via UI or API
- In branches: Generate artifacts in proposed changes
- After merge: Regenerate after branch merge
Accessing Artifacts
Retrieve artifacts via the SDK:Comparing Artifacts
Infrahub automatically detects changes:Python Transform Artifacts
Using Python transforms for complex artifact generation:Content Type Handling
Infrahub automatically formats output based oncontent_type:
Best Practices
- Use descriptive names: Make artifact names clear and specific
- Target appropriately: Use groups or filters to select correct objects
- Set correct content types: Ensures proper formatting and handling
- Version control: Keep transformation code in Git repositories
- Test thoroughly: Validate artifacts before production use
- Monitor generation: Track artifact generation success/failure
- Handle errors: Implement error handling in transformations
- Optimize queries: Retrieve only needed data to improve performance
Related Topics
- Transformations Overview - Understanding transformation concepts
- Jinja2 Templates - Creating template-based artifacts
- Python Transforms - Building Python-based artifacts
- GraphQL Queries - Writing efficient data queries
Next Steps
- Create your first Jinja2 template artifact
- Build a Python transform for complex artifacts
- Learn about repository configuration