Comments (3)
Thanks for the extensive debugging. In the meantime we mainly use staging environments and keep services active all the time. So the issue does not surface any more. But if it happens I can come back to the examples above. Closing the issue now as it's minor and not blocking anything.
from terraform-provider-fastly.
👋🏻 Hi @RmMsr
Thanks for opening this issue!
I've created an internal ticket to track this and will report back once I've had a chance to investigate.
from terraform-provider-fastly.
👋 Hi @RmMsr
Thanks for your patience. I've only just started looking into this and I can replicate the issue (e.g. Terraform state getting out-of-sync with the real-world) and I believe I'm able to resolve the issue and get the state back in-sync.
The summary of the steps I took (and seems I needed to run terraform apply -refresh-only
twice, although at this point in time I'm not entirely sure why) were...
# deactivate service
fastly service-version deactivate --service-id=$(fastly service list --json | jq -r 'map(select(.Name == "testing-tf-provider-reactivation-bug")) | .[].ID') --version latest
# get terraform state in-sync with deactivated service (e.g. active/clone is 0/0)
terraform apply -refresh-only
# get terraform state to track correct clone version (e.g. active/clone is 0/1)
terraform apply -refresh-only
# reactive the service (active version will increase by 1)
fastly service-version activate --service-id=$(fastly service list --json | jq -r 'map(select(.Name == "testing-tf-provider-reactivation-bug")) | .[].ID') --version latest --autoclone
# get terraform state back in-sync (e.g. active/clone is 2/2)
terraform apply -refresh-only
Terraform doesn't like when resources it manages are modified outside of Terraform. So I always like to recommend that customers avoid patterns that require them to modify a resource outside of Terraform.
Below is the complete testing flow I took, and hopefully will give a complete view of what I was seeing and how I reached the final conclusion/resolution...
# create service
terraform apply
# state shows active/clone is 1/1
cat terraform.tfstate | jq '.resources[].instances[].attributes | "active: \(.active_version), clone: \(.cloned_version)"'
# deactivate service
fastly service-version deactivate --service-id=$(fastly service list --json | jq -r 'map(select(.Name == "testing-tf-provider-reactivation-bug")) | .[].ID') --version latest
# show active/clone changing from one to zero
terraform plan -refresh-only
# state shows active/clone is 1/1
cat terraform.tfstate | jq '.resources[].instances[].attributes | "active: \(.active_version), clone: \(.cloned_version)"'
# apply state refresh
terraform apply -refresh-only
# state shows active/clone is 0/0
cat terraform.tfstate | jq '.resources[].instances[].attributes | "active: \(.active_version), clone: \(.cloned_version)"'
# show 'clone version' changing from zero back to one
terraform plan -refresh-only
# apply state refresh
terraform apply -refresh-only
# state shows active/clone is 0/1
cat terraform.tfstate | jq '.resources[].instances[].attributes | "active: \(.active_version), clone: \(.cloned_version)"'
# re-activate the service (active version will become 2)
fastly service-version activate --service-id=$(fastly service list --json | jq -r 'map(select(.Name == "testing-tf-provider-reactivation-bug")) | .[].ID') --version latest --autoclone
# check plan shows no changes
terraform plan
# state shows active/clone is 0/1
cat terraform.tfstate | jq '.resources[].instances[].attributes | "active: \(.active_version), clone: \(.cloned_version)"'
# shows active/clone is 2/2 (i.e. getting back in-sync)
terraform plan -refresh-only
# apply state refresh
terraform apply -refresh-only
# state shows active/clone is 2/2
cat terraform.tfstate | jq '.resources[].instances[].attributes | "active: \(.active_version), clone: \(.cloned_version)"'
# make a config change and apply
terraform apply
# state shows active/clone is 3/3
cat terraform.tfstate | jq '.resources[].instances[].attributes | "active: \(.active_version), clone: \(.cloned_version)"'
# deactivate service
fastly service-version deactivate --service-id=$(fastly service list --json | jq -r 'map(select(.Name == "testing-tf-provider-reactivation-bug")) | .[].ID') --version latest
# reactive the service (active version will become 4)
fastly service-version activate --service-id=$(fastly service list --json | jq -r 'map(select(.Name == "testing-tf-provider-reactivation-bug")) | .[].ID') --version latest --autoclone
# get terraform state back in-sync (shows change from version 3 to 4)
terraform plan -refresh-only
# apply state refresh
terraform apply -refresh-only
# state shows active/clone is 4/4
cat terraform.tfstate | jq '.resources[].instances[].attributes | "active: \(.active_version), clone: \(.cloned_version)"'
from terraform-provider-fastly.
Related Issues (20)
- product_enablement image_optimizer changes not applying. HOT 7
- rate_limiter: uri dictionary must exist bug HOT 3
- package required for compute service HOT 8
- Terraform apply does not report error if snippet VCL is invalid
- fastly_service_acl_entries only save 100 entries in statefile HOT 1
- cannot enable brotli without impacting image optimization HOT 2
- Feature Request - automation token creation HOT 1
- Dynamic snippet breaks versioning
- Fastly TLS Subscription Read doesn't use the Current Value (Uses original)
- Marking vcl backends as sensitive HOT 5
- Terraform plan shows the removal of a backend that doesn't exist in the active version. HOT 3
- fastly_service_vcl.logging_bigquery always shows change HOT 2
- fastly_service_vcl Overly verbose Snippets diff
- Problems modifying stale_if_error HOT 1
- Change engineer to any other role
- gcp project_id change not applying on update to logging_gcs
- Default origin healthcheck timeout seconds is too short
- Provider crash invalid memory address HOT 10
- fastly_tls_activation silently removes mutual_authentication if it is configured elsewhere HOT 6
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from terraform-provider-fastly.