Skip to content
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

Create VCL as main in one API call #112

Closed
miyagawa opened this issue Jan 3, 2019 · 2 comments
Closed

Create VCL as main in one API call #112

miyagawa opened this issue Jan 3, 2019 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@miyagawa
Copy link

miyagawa commented Jan 3, 2019

Hi,

Once fastly/go-fastly#93 is merged, this provider should make use of the Main attribute of the VCL input so that we can avoid creating a VCL as non-main and then promote it to main in a separate API call.

Here's an untested patch:

diff --git a/fastly/resource_fastly_service_v1.go b/fastly/resource_fastly_service_v1.go
index c1a65da..1313bef 100644
--- a/fastly/resource_fastly_service_v1.go
+++ b/fastly/resource_fastly_service_v1.go
@@ -2503,6 +2503,7 @@ func resourceServiceV1Update(d *schema.ResourceData, meta interface{}) error {
 					Version: latestVersion,
 					Name:    df["name"].(string),
 					Content: df["content"].(string),
+					Main:    df["main"].(bool),
 				}
 
 				log.Printf("[DEBUG] Fastly VCL Addition opts: %#v", opts)
@@ -2510,21 +2511,6 @@ func resourceServiceV1Update(d *schema.ResourceData, meta interface{}) error {
 				if err != nil {
 					return err
 				}
-
-				// if this new VCL is the main
-				if df["main"].(bool) {
-					opts := gofastly.ActivateVCLInput{
-						Service: d.Id(),
-						Version: latestVersion,
-						Name:    df["name"].(string),
-					}
-					log.Printf("[DEBUG] Fastly VCL activation opts: %#v", opts)
-					_, err := conn.ActivateVCL(&opts)
-					if err != nil {
-						return err
-					}
-
-				}
 			}
 		}
 
@miyagawa
Copy link
Author

miyagawa commented Jan 4, 2019

the go-fastly PR is merged now.

@smaeda-ks
Copy link
Contributor

Added in v0.33.0:
https://github.com/fastly/terraform-provider-fastly/blob/main/CHANGELOG.md

Thank you for the suggestion! @miyagawa

Integralist pushed a commit that referenced this issue Jan 27, 2022
* V1 versionless deletion protection (#110)

* Add DiffSuppressFunc to optionally suppress all diffs on ACL entries

Adds a manage_entries attribute which defaults to false. Then a
DiffSuppressFunc reads this and decides whether to suppress the diff on
the entries set. By default this then only applies the changes on create
and does nothing the rest of the time, unless the user sets
manage_entries to true manually, then it behaves as usual. This is to
make the resource safer by default in the event that entries are added
to the ACL outside of Terraform, so that they aren't accidentally
deleted.

* Add acceptance tests for manage_entries attribute

* Add DiffSuppressFunc manage_entries to dictionary items as well

Same change as for the ACL entries resource, but for the dictionary
items.

* Run make generate-docs

* add a missing argument

* re-generate docs

Co-authored-by: Ben Gesoff <[email protected]>
Co-authored-by: Hieu Doan <[email protected]>

* Make backend `auto_loadbalance` default to false (#111)

The Fastly web interface defaults "Auto load balance" to "No". The most
common reason for having multiple backends in a single service is to
route different paths to different backends, rather than load balance
between different origins. Currently, this provider defaults
`auto_loadbalance` to true, which is surprising and confusing. This
commit makes `auto_loadbalance` default to false to reduce confusion.

Co-authored-by: Ben Gesoff <[email protected]>
Co-authored-by: Hieu Doan <[email protected]>

* V1 update default format and format version (#112)

* Update default values for format & format_version

* Update format & format_version in docs and doc strings

* Cosmetic change: capitilise Default

* Update format & format_version in tests

* Fix 'format' for papertail

* add FormatVersion for the GCS struct

* update gcslogging doc with format_version

* change double quotes to backticks

Co-authored-by: Hieu Doan <[email protected]>

* V1 change email to user in gcslogging (#113)

* Change the email field to user to align with the API docs.

* fix TestGcsloggingEnvDefaultFuncAttributes by using the user attribute

* fix TestResourceFastlyFlattenGCS

* go fmt

Co-authored-by: Hieu Doan <[email protected]>

* use `TypeList` schema for `gzip` nested block attributes (#114)

Co-authored-by: Shohei Maeda <[email protected]>
Co-authored-by: Hieu Doan <[email protected]>

* Consistent resource naming (#115)

Consistent resource naming:
- change `v1` to `vcl`
- remove `v1` 
- add `logging` prefix
- update docs and examples

Other changes:
- fix acl manage entries test
- fix `user` attribute in gcs

Co-authored-by: Hieu Doan <[email protected]>

Co-authored-by: Ben Gesoff <[email protected]>
Co-authored-by: Hieu Doan <[email protected]>
Co-authored-by: Shohei Maeda <[email protected]>
Integralist added a commit that referenced this issue Feb 8, 2022
* Changes for v1.0.0 (#532)

* V1 versionless deletion protection (#110)

* Add DiffSuppressFunc to optionally suppress all diffs on ACL entries

Adds a manage_entries attribute which defaults to false. Then a
DiffSuppressFunc reads this and decides whether to suppress the diff on
the entries set. By default this then only applies the changes on create
and does nothing the rest of the time, unless the user sets
manage_entries to true manually, then it behaves as usual. This is to
make the resource safer by default in the event that entries are added
to the ACL outside of Terraform, so that they aren't accidentally
deleted.

* Add acceptance tests for manage_entries attribute

* Add DiffSuppressFunc manage_entries to dictionary items as well

Same change as for the ACL entries resource, but for the dictionary
items.

* Run make generate-docs

* add a missing argument

* re-generate docs

Co-authored-by: Ben Gesoff <[email protected]>
Co-authored-by: Hieu Doan <[email protected]>

* Make backend `auto_loadbalance` default to false (#111)

The Fastly web interface defaults "Auto load balance" to "No". The most
common reason for having multiple backends in a single service is to
route different paths to different backends, rather than load balance
between different origins. Currently, this provider defaults
`auto_loadbalance` to true, which is surprising and confusing. This
commit makes `auto_loadbalance` default to false to reduce confusion.

Co-authored-by: Ben Gesoff <[email protected]>
Co-authored-by: Hieu Doan <[email protected]>

* V1 update default format and format version (#112)

* Update default values for format & format_version

* Update format & format_version in docs and doc strings

* Cosmetic change: capitilise Default

* Update format & format_version in tests

* Fix 'format' for papertail

* add FormatVersion for the GCS struct

* update gcslogging doc with format_version

* change double quotes to backticks

Co-authored-by: Hieu Doan <[email protected]>

* V1 change email to user in gcslogging (#113)

* Change the email field to user to align with the API docs.

* fix TestGcsloggingEnvDefaultFuncAttributes by using the user attribute

* fix TestResourceFastlyFlattenGCS

* go fmt

Co-authored-by: Hieu Doan <[email protected]>

* use `TypeList` schema for `gzip` nested block attributes (#114)

Co-authored-by: Shohei Maeda <[email protected]>
Co-authored-by: Hieu Doan <[email protected]>

* Consistent resource naming (#115)

Consistent resource naming:
- change `v1` to `vcl`
- remove `v1` 
- add `logging` prefix
- update docs and examples

Other changes:
- fix acl manage entries test
- fix `user` attribute in gcs

Co-authored-by: Hieu Doan <[email protected]>

Co-authored-by: Ben Gesoff <[email protected]>
Co-authored-by: Hieu Doan <[email protected]>
Co-authored-by: Shohei Maeda <[email protected]>

* make fmt

* fix broken merge

* make generate-docs

* Remove Director `capacity` field as it's unused (#535)

* remove director capacity

* Fix the example usage in docs/index.md (#533)

* Fix the example usage in docs/index.md

* Fix templates/index.md.tmpl

* run make generate-docs

* Remove extraneous line

* Remove extraneous line

Co-authored-by: Mark McDonnell <[email protected]>

* Support Terraform CLI 1.1.4 (#536)

* fix director tests

* update docs

Co-authored-by: Hiromasa Kakehashi <[email protected]>

* Add missing docs and attributes in versionless resources (#537)

* add the 'manage_snippets' attribute into 'fastly_service_dynamic_snippet_content'
update 'fastly_service_dictionary_items'

* delete a typo in manage_snippets

* domestic change: format hcl in the test

* Remove 'ignore_changes' from the docs and examples

Co-authored-by: Hieu Doan <[email protected]>

* Bump terraform-plugin-sdk (#538)

* remove terraform json from go.mod

* format example

* regenerate docs after typo

Co-authored-by: Hiieu <[email protected]>
Co-authored-by: Ben Gesoff <[email protected]>
Co-authored-by: Hieu Doan <[email protected]>
Co-authored-by: Shohei Maeda <[email protected]>
Co-authored-by: Hiromasa Kakehashi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants