An experimental CLI that generates TF files to manage existing Fastly services with Terraform
https://user-images.githubusercontent.com/30490956/169726673-33ecccf7-ae40-4ebd-acf7-e4d457d4f510.mp4
Installation
go install github.com/hrmsk66/terraformify@latest
Configuration
terraformify requires read permissions to the target Fastly resource.
Choose one of the following options to give terraformify access to your API token:
- Include the token explicitly on each command you run using the
--api-key
or -k
flags.
- Set a
FASTLY_API_KEY
environment variable.
Usage
Run the command in an empty directory
mkdir test && cd test
terraformify service <service-id>
terraformify replaces sensitive values in main.tf
, attributes marked as Sensitive in the Fastly provider's schema, with variables and stores them in terraform.tfvars
. The tool generates .gitignore
to prevent terraform.tfvars
from accidentaly bening committed to Git repos.
Interactive mode
By default, terraformify imports all resources associated with the service, such as ACL entries, dictionary items, WAF..etc. To interactively select which resources to import, use the --interactive
or -i
flag.
terraformify service <service-id> -i
Import specific version
By default, either the active version will be imported, or the latest version if no version is active. Alternatively, a specific version of the service can be selected by passing version number to the --version
or -v
flag.
terraformify service <service-id> -v <version-number>
force_destroy
By default, force_destroy
is set to false
. To set them to true
and allow Terraform to destroy resouces, use the --force-destroy
or -f
flag.
terraformify service <service-id> -f
Manage associated resources
By default, the manage_*
attribute is not set so that these resources can be managed externally.
To set the attributes to true and manage the resource with Terraform, use the --manage-all
or -m
flag.
terraformify service <service-id> -m
By default, terraformify updates terraform.tfstate
directly. To disable this behavior and leave the state file untouched, use the --skip-edit-state
or -s
flag.
Note: Terraform detects diffs without this behavior and terraform apply
may result in the destruction and re-creation of associated resources, such as ACL entries and Dictionary items.
terraformify service <service-id> -s
License
MIT License