Exporting service config to terraform



Does anyone know if it’s possible to export a service configuration to a terraform file? I’d like to start automating my Fastly config changes via terraform, but I currently have defined all configuration via the web console.

I’d like to be able to export the configuration I currently have to a terraform file, instead of having to start from scratch and write the file based upon the values I put in the console.




Unfortunately there does not seem to be tool to export to teraform format. You need to create configuration based on API response of Fastly configuration.
In the future, teraform import supports to generate configuration.



you can use the import function to import services into your terraform state file, however, you must still define the items in your xxx.tf files. it does make it somewhat easier having them opened side by side instead of trying to create from the webui.

set up your provider, and create an empty resource block:

resource "fastly_service_v1" "service_name" {

then run

terraform import fastly_service_v1.service_name SERVICEID

where SERVICEID is the service ID from your service.

now you can write out your service in a tf file.


Thanks, this was super helpful!