Data Sources
Data sources allow you to retrieve information about existing resources in ImageFactory. This is useful for referencing built-in distributions, system components, or resources managed outside of your current Terraform state.
Distribution
Look up an OS distribution to use as the base for a template.
data "imagefactory_distribution" "ubuntu" {
name = "Ubuntu 22.04 LTS"
cloud_provider = "AWS"
}
# Use in a template
resource "imagefactory_template" "main" {
distribution_id = data.imagefactory_distribution.ubuntu.id
# ...
}
Argument Reference
| Argument | Type | Required/Optional | Description |
|---|---|---|---|
name | String | Required | The name of the distribution. |
cloud_provider | String | Required | The cloud provider (AWS, AZURE, etc.). |
System Component
Look up built-in system components provided by ImageFactory.
data "imagefactory_system_component" "hardening" {
name = "CIS Level 1 Hardening"
}
Argument Reference
| Argument | Type | Required/Optional | Description |
|---|---|---|---|
name | String | Required | The name of the system component. |
Custom Component
Look up a custom component by its name and properties.
data "imagefactory_custom_component" "my_script" {
name = "my-custom-script"
cloud_provider = "AWS"
stage = "BUILD"
}
Argument Reference
| Argument | Type | Required/Optional | Description |
|---|---|---|---|
name | String | Required | The name of the custom component. |
cloud_provider | String | Required | The cloud provider it supports. |
stage | String | Required | The stage (BUILD or TEST). |
Role
Look up an existing role by its name.
data "imagefactory_role" "admin" {
name = "Admin"
}
Argument Reference
| Argument | Type | Required/Optional | Description |
|---|---|---|---|
name | String | Required | The name of the role. |
API Key
Look up an existing API key by its name.
data "imagefactory_api_key" "existing" {
name = "my-api-key"
}
Argument Reference
| Argument | Type | Required/Optional | Description |
|---|---|---|---|
name | String | Required | The name of the API key. |