Mixing custom VCL and Fastly GUI-Based Vcl

Comments

9 comments

  • Rogier Mulhuijzen

    [quote="mpapper, post:1, topic:785"] My understanding on the rules for mixing custom vcl with fastly vcl is that the #Fastly macros in the VCL boilerplate will expand to all of the UI-created rules. Is my understating here correct? [/quote]

    Yes, that is correct.

    [quote="mpapper, post:1, topic:785"] If so, then would the following test be valid:

    1) download the fastly boilerplate2) Add custom VCL into the boilerplate (lets call this document custom VCL)3) create some rules using the fastly UI4) Upload the custom VCL for the service5) View the service's VCL and it should include all the rules for the UI generated code AND the custom VCL....and continuing...6) Add more rules in the UI7) Take the custom VCL and add more code8) Upload the custom VCL again9) View the service's VCL and it should include all the rules for the UI generated code AND the custom VCL including the original custom VCL and the new VCL. [/quote]

    Yup, that's exactly how it works.

    [quote="mpapper, post:1, topic:785"] I think this process should work - does anyone have any other suggestions on mixing custom and UI generated code? [/quote]

    A lot of us Customer Support or Sales Engineers use https://github.com/stephenbasile/vcl_cli to easily edit & upload VCL.

    [quote="mpapper, post:1, topic:785"] Related Question: is it preferable to use the UI to create the backends or code them directly into the custom vcl? [/quote]

    Use the UI or the API, mostly because of shielding, but also because we query our database to check who might be using certain features on backends. In the case of shielding, we generate all the shield server definitions in the VCL, and if there are changes to the datacenter, we will regenerate the VCL to reflect things like extra servers and what not.

  • devforce

    Thanks. I have been playing with vcl_cli and am stuck using it...

    I think I can login: $ vcl login Username: dev@developerforce.com Password:
    Two factor auth is NOT enabled. You should go do that immediately. Login successful! Creating root scoped token...

    400: Bad API request--got bad request response. Sometimes this means what you're looking for doesn't exist. Method: post, Path: /tokens

    The above gave an error but seemed to have logged me in nonetheless. But when I try to download I get this:

    No VCLs on this service, however a folder has been created. Create VCLs in this folder and upload.

    Which I guess is OK. But when I upload I get an error:

    $ vcl upload VCL tracking does not currently exist on the service, would you like to create it? y --- /var/folders/dn/bgsdc52w3b4jr98yb7s2spn9dz5/T/diffy20160829-52046-ceopmn 2016-08-29 16:31:14.000000000 -0700 +++ /var/folders/dn/bgsdc52w3b4jr98yb7s2spn9dz5/T/diffy20160829-52046-1aysfv2 2016-08-29 16:31:14.000000000 -0700 @@ -0,0 +1 @@ +// tracking for all salesforcve VCLs Given the above diff, are you sure you want to upload your changes? y

    403: Access Denied by API. Run login command to authenticate. Method: post, Path: /service/1lDYJRkz1mWMArSjpMJ1FV/version/6/vcl

    I did try to login (again, for a second time) but that did not help.

    Any ideas what Im dong wrong for the upload?

  • Stephen Basile

    Hi @mpapper

    The reason it is giving you a 403 is because the ability to upload VCL is not enabled on your account. I went ahead and enabled it for you.

    I've also made myself a note to display the error message returned by the API. That way the problem would have been more readily identifiable by @drwilco.

    EDIT: I also will investigate why the token creation failed when two factor auth is not enabled. That is either a bug in our API or with the gem, either way I'll get it fixed.

    Thanks, Stephen

  • Stephen Basile

    The token creation issue is fixed as of the latest commit to master. Go ahead and rebuild the gem. That way it won't keep prompting you to login every time your session expires.

  • devforce

    My strategy for managing my fastly services was to keep all files (including the main vcl file) in version control. I was going to put most of my code into various vcl files and include them in the main file. I was going to put the backends into a vcl file and include that too.

    I uploaded a file and called it default.vcl and it looks like it is now treated as the "main" vcl file.

    When I do "show vcl" I see some stuff at the top of the file: some pragma and backend statements. This looks like it was placed in there by fastly and I have no control over it. I want to define the backends myself in VCL not using the GUI. How can I do this?

    A related question is: I think I want to use custom VCL for almost all my code and think that the UI may be suitable just for defining redirects (pattern match the URL path and do a 301 redirect). What are the drawbacks of this strategy?

  • devforce

    I have another issue, when I use "vcl upload" I often get a 409 error.

    For example, I created a new vcl file and edited my default.vcl file. I uploaded and that seemed to work. I noticed I spelled the name wrong so I edited my default.vcl and uploaded again. Now I get a 409 error and the file is not uploaded.

    What do I need to do so it will upload again?

    I think the underlying issue is that it doesnt like to upload twice for the same version. It should allow me to do this.

    Also as far as I can see there is no way to upload to a new version of my choosing. It seems to take the currently activated version and upload to a version that is +1 from that. And as I said onthe second attempt to upload it gives the 409 error.

    I think the tool should allow me to go --version=23 wherre there is NO 23 version at the moment and it will crate that one.

    Another issue here: when uploading the tool seems to make the file with the first lexigraphic ordering by name as the "main" file. IS this by design? Is there a better way to tell the system that file XXX is the main file?

  • devforce

    Yet another issue, when I upload a file using vcl upload the "vcl" extension gets dropped. When I upload using the UI the extension is retained.

    When I upload with the vcl upload program, Im getting an error in theUI saying "vcl file does not exist" and I thonk this is because the extension is being stripped from the filename during upload.

    And when I download it adds a vcl to the filename. Ugh. Why cant it just leave it alone?

    Now also Im totally confused as to the syntax to "include" another file. If the file is named backends.vcl on my hard drive and I use vcl upload it looks like its named "backends" in fastly but it really is backends.vcl. So what is the proper way to include it? Is it include "BACKENDS" include "backends" include "backends.vcl"

    From testing it seems the include must be "backends".

  • Steven Chuob

    Yet another issue, when I upload a file using vcl upload the "vcl" extension gets dropped. When I upload using the UI the extension is retained.

    This looks to be related to how the vcl cli was design to do from looking at the code.

    Now also Im totally confused as to the syntax to "include" another file. If the file is named backends.vcl on my hard drive and I use vcl upload it looks like its named "backends" in fastly but it really is backends.vcl. So what is the proper way to include it? Is it

    The way to reference another vcl file is by the vcl name. So if the vcl configuration is named default.vcl then you would reference. include "default.vcl". If the vcl configuration is named "default" then you would reference it include "default".

    In the case of the vcl tool it removes the .vcl to set the name. So you would reference the includes as you mention by using include "default".

    I also like to add that if you think anything should be done different, issues or feature request for the vcl cli should be posted to the github repo.

  • devforce

    Thanks for clarifying this.

Please sign in to leave a comment.