-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(kv_store): support KV Store #691
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dennismartensson
approved these changes
May 3, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good to me, but I have never built anything for terraform, so can't really review that part.
3c5ab42
to
84e6bdf
Compare
razaj92
reviewed
May 30, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces a new
fastly_kvstore
resource and aresource_link
block within thefastly_service_compute
resource.This PR does NOT introduce any additional 'resource' for managing the contents of the KV Store as each key value can potentially be up to 25MB in size and that's not feasible for Terraform to manage (refer to Configuration not data).
✅ The full integration test suite has been run locally and is passing.
The files of interest are...
docs/resources/kvstore.md
fastly/block_fastly_service_resource_link.go
fastly/provider.go
fastly/resource_fastly_kvstore.go
Example config...
Notes
This PR went through multiple design changes, and we ended up having to have
resource_link
as a block inside thefastly_service_compute
resource (rather than as a separate resource) because we needed it to have access to the service version and this isn't something that could just be passed in as a 'expression reference' as the service itself needs to clone its currently tracked version.Yes, it is possible to clone a service from within a separate resource just by calling the relevant API endpoint, but we then can't update the Terraform state to reflect the newly tracked version. I'm sure there would be some kind of workaround where we track this information via the file-system or some other external data store, but we can't know if the user has set
activate = false
in their service config (hence we can't trust just looking at the API response for currently active service as the user might be working on a draft).The reason a deletion is a two-step apply is because you can't delete a KV Store until you delete any resource links associated with it. Meaning if we tried to delete both the
fastly_kvstore
resource and theresource_link
block then there would be an error iffastly_kvstore
's DELETE operation was executed first (as it would find a still active resource link associated with it). The reason this is even more likely to happen is because in our example theresource_link
block references thefastly_kvstore
and so that builds an implicit dependency graph and so Terraform will naturally try to delete thefastly_kvstore
first.