Fastly offers a huge opportunity of customizing user journeys using the VCL conditionals/flows. More details here - https://abiydv.github.io/posts/fastly-bdd/
- terraform - Terraform configs to create a sample Fastly service
- vcl - The VCL snippets
- tests - Feature files and tests implementation
- Sign-up for a limited free Fastly account
- Terraform 12 or above
-
Export
FASTLY_API_KEY
export FASTLY_API_KEY=aabbccdd_01234
-
Switch to
terraform
directory, initializeterraform
and check plancd terraform terraform plan
-
Apply plan to create the Fastly service
terraform apply $ Apply complete! Resources: 3 added, 0 changed, 0 destroyed.
-
Switch to
tests
directory and create a virtual py environmentcd tests python3 -m venv env
-
Activate the py virtual environment and install dependencies
source env/bin/activate (env) pip3 install -r requirements.txt
-
Execute
behave
testsbehave . . 1 feature passed, 0 failed, 0 skipped 1 scenario passed, 0 failed, 0 skipped 6 steps passed, 0 failed, 0 skipped, 0 undefined Took 0m0.051s
-
Export
FASTLY_API_KEY
export FASTLY_API_KEY=aabbccdd_01234
-
Switch to
terraform
directorycd terraform terraform plan
-
Delete the Fastly service
terraform destroy $ Apply complete! Resources: 0 added, 0 changed, 3 destroyed.
This is a test/proof-of-concept. There are some configs to make it quick, which should be removed before actual implementation.
-
verify=False
flag inrequests.get()
call. File steps.py.
This is necessary because the Fastly shared certs will not have the test domain created (fastly-bdd-example.com) as part of this example. Without this flag the call will fail. -
Adding the Fastly shared domain fastly-bdd-example.com.global.prod.fastly.net in feature files.