The Config Store (fastly_configstore
) can be seeded with initial key-value pairs using the fastly_configstore_entries
resource.
After the first terraform apply
the default behaviour is to ignore any further configuration changes to those key-value pairs. Terraform will expect modifications to happen outside of Terraform (e.g. new key-value pairs to be managed using the Fastly API or Fastly CLI).
To change the default behaviour (so Terraform continues to manage the key-value pairs within the configuration) set manage_entries = true
.
Basic usage (with seeded values):
# IMPORTANT: Deleting a Config Store requires first deleting its resource_link.
# This requires a two-step `terraform apply` as we can't guarantee deletion order.
# e.g. resource_link deletion within fastly_service_compute might not finish first.
resource "fastly_configstore" "example" {
name = "%s"
}
resource "fastly_configstore_entries" "example" {
store_id = fastly_configstore.example.id
entries = {
key1 : "value1"
key2 : "value2"
}
}
resource "fastly_service_compute" "example" {
name = "my_compute_service"
domain {
name = "demo.example.com"
}
package {
filename = "package.tar.gz"
source_code_hash = data.fastly_package_hash.example.hash
}
resource_link {
name = "my_resource_link"
resource_id = fastly_configstore.example.id
}
force_destroy = true
}
data "fastly_package_hash" "example" {
filename = "package.tar.gz"
}
To have Terraform manage the initially seeded key-value pairs defined in your configuration, then you must set manage_entries = true
(this will cause any key-value pairs added outside of Terraform to be deleted):
# IMPORTANT: Deleting a Config Store requires first deleting its resource_link.
# This requires a two-step `terraform apply` as we can't guarantee deletion order.
# e.g. resource_link deletion within fastly_service_compute might not finish first.
resource "fastly_configstore" "example" {
name = "%s"
}
resource "fastly_configstore_entries" "example" {
store_id = fastly_configstore.example.id
entries = {
key1 : "value1"
key2 : "value2"
}
manage_entries = true
}
resource "fastly_service_compute" "example" {
name = "my_compute_service"
domain {
name = "demo.example.com"
}
package {
filename = "package.tar.gz"
source_code_hash = data.fastly_package_hash.example.hash
}
resource_link {
name = "my_resource_link"
resource_id = fastly_configstore.example.id
}
force_destroy = true
}
data "fastly_package_hash" "example" {
filename = "package.tar.gz"
}
Fastly Config Stores entries can be imported using the corresponding Config Store ID with the /entries
suffix, e.g.
$ terraform import fastly_configstore_entries.example xxxxxxxxxxxxxxxxxxxx/entries
entries
(Map of String) A map representing an entry in the Config Store, (key/value)store_id
(String) An alphanumeric string identifying the Config Store.manage_entries
(Boolean) Have Terraform manage the entries (default: false). If set to true
Terraform will remove any entries that were added externally from the config seeded values.id
(String) The ID of this resource.