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

provider/fastly: add support for custom VCL configuration #6587

Closed
wants to merge 1 commit into from

Conversation

mattmoyer
Copy link
Contributor

This PR adds a new vcl configuration block to support Fastly custom VCL. VCL is the Varnish Configuration Language, which is a compiled C-like DSL.

Fastly's API model for custom VCL is that you have zero or more VCL files associated with your service, with one of them set as the "main" block. The main block needs to define some entrypoints that are invoked directly by the Varnish request handling flow, the other non-main blocks are available to include as libraries in the main block.

Usage

resource "fastly_service_v1" "demo" {
  name = "demofastly"

  domain {
    name    = "demo.notexample.com"
    comment = "demo"
  }

  backend {
    address = "127.0.0.1"
    name    = "localhost"
    port    = 80
  }

  force_destroy = true

  vcl {
    name = "my_custom_main_vcl"
    content = "${file("${path.module}/my_custom_main.vcl")}"
    main = true
  }

  vcl {
    name = "my_custom_library_vcl"
    content = "${file("${path.module}/my_custom_library.vcl")}"
  }
}

Caveats

Fastly does not allow custom VCL by default on new accounts. I think it is only available on paid accounts if you request access and describe your planned use case. I noted this in the documentation, but because of this I didn't (yet) write any acceptance tests for this functionality.

I'm open to any other ideas about how to represent VCL in this provider.

@mattmoyer
Copy link
Contributor Author

I originally had this implemented on top of #6508 (ValidateFunc for lists and sets), but I don't think I have the time to finish implementing that so I went ahead and tweaked this to just validate on apply.


remove := oldVCLSet.Difference(newVCLSet).List()
add := newVCLSet.Difference(oldVCLSet).List()
_ = add
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this leftover from debugging, or doing something I don't yet understand?

Copy link
Contributor Author

@mattmoyer mattmoyer May 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, that was just debugging cruft left over. Assigning to _ lets you get around add declared and not used errors while you're in the middle of things.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yup, thought so, thanks!

@catsby
Copy link
Contributor

catsby commented May 10, 2016

Wonderful! This was on my very short list of things to do, thanks!
As I have not gotten to it myself, I had not yet requested VCL support for our testing account. I've just emailed support to request it, so as soon as I get word I'll probably just merge this and add tests myself later.

The code looks good otherwise so I may just merge today anyway.

Thanks!

@mattmoyer
Copy link
Contributor Author

@catsby sounds great. I just rebased some of those little fixes so I think this should be fine to merge whenever you're ready.

@catsby
Copy link
Contributor

catsby commented May 10, 2016

Fastly already got back to me and enabled VCL support on our test account ❤️

I'll work on some tests and try to get this in today. Thanks again!

@catsby
Copy link
Contributor

catsby commented May 13, 2016

I opened #6662 to continue this work by adding an acceptance test, so I'm going to close this now. Thanks for the contribution! #6662 includes your commits so you'll still get attribution 😄

@catsby catsby closed this May 13, 2016
@mattmoyer mattmoyer deleted the fastly-vcl branch May 13, 2016 17:54
catsby added a commit that referenced this pull request May 17, 2016
…6587) (#6662)

* provider/fastly: add support for custom VCL configuration
ojongerius added a commit to atlassian/terraform that referenced this pull request May 18, 2016
…equire_full_window_and_locked

* upstream/master: (665 commits)
  merged createVirtualMachine and deployVirtualMachine to setupVirtualMachine (hashicorp#6659)
  Update CHANGELOG.md
  provider/fastly: add support for custom VCL configuration (supersedes hashicorp#6587) (hashicorp#6662)
  Remove CHANGELOG entry for backported 0.6.17 feature
  Update CHANGELOG.md
  provider/vsphere: wait for network enhanced (hashicorp#6377)
  Update CHANGELOG.md
  Update CHANGELOG.md
  Update CHANGELOG.md
  docs: clarify an internal-plugins header
  Fixes an vet error.
  Update CHANGELOG.md
  provider/aws: Support for Redshift Cluster encryption using a KMS key (hashicorp#6712)
  provider/aws: Randomize key names in KMS alias test
  Include the list of allowed values for AWS auto scaling group termination policies (hashicorp#6710)
  website: docs for azurerm custom images
  Update CHANGELOG.md
  Godeps: rm dup github.com/ryanuber/columnize
  Add note about paid training
  provider/aws: Fix crash in ElastiCache param group
  ...
cristicalin pushed a commit to cristicalin/terraform that referenced this pull request May 24, 2016
@ghost
Copy link

ghost commented Apr 25, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants