1. Packages
  2. Fastly Provider
Fastly v9.0.0 published on Tuesday, Apr 8, 2025 by Pulumi

Fastly Provider

Installation

The Fastly provider is available as a package in all Pulumi languages:

Overview

The Fastly provider is used to interact with the content delivery network (CDN) provided by Fastly.

In order to use this Provider, you must have an active account with Fastly. Pricing and signup information can be found at https://www.fastly.com/signup

Use the navigation to the left to read about the available resources.

Example Usage

# Pulumi.yaml provider configuration file
name: configuration-example
runtime: nodejs
config:
    fastly:apiKey:
        value: test
Copy
import * as pulumi from "@pulumi/pulumi";
import * as fastly from "@pulumi/fastly";

// Create a Service
const myservice = new fastly.ServiceVcl("myservice", {name: "myawesometestservice"});
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: python
config:
    fastly:apiKey:
        value: test
Copy
import pulumi
import pulumi_fastly as fastly

# Create a Service
myservice = fastly.ServiceVcl("myservice", name="myawesometestservice")
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: dotnet
config:
    fastly:apiKey:
        value: test
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Fastly = Pulumi.Fastly;

return await Deployment.RunAsync(() =>
{
    // Create a Service
    var myservice = new Fastly.ServiceVcl("myservice", new()
    {
        Name = "myawesometestservice",
    });

});
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: go
config:
    fastly:apiKey:
        value: test
Copy
package main

import (
	"github.com/pulumi/pulumi-fastly/sdk/v8/go/fastly"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// Create a Service
		_, err := fastly.NewServiceVcl(ctx, "myservice", &fastly.ServiceVclArgs{
			Name: pulumi.String("myawesometestservice"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: yaml
config:
    fastly:apiKey:
        value: test
Copy
resources:
  # Create a Service
  myservice:
    type: fastly:ServiceVcl
    properties:
      name: myawesometestservice
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: java
config:
    fastly:apiKey:
        value: test
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.fastly.ServiceVcl;
import com.pulumi.fastly.ServiceVclArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        // Create a Service
        var myservice = new ServiceVcl("myservice", ServiceVclArgs.builder()
            .name("myawesometestservice")
            .build());

    }
}
Copy

Authentication

The Fastly provider offers an API key based method of providing credentials for authentication. The following methods are supported, in this order, and explained below:

  • Static API key
  • Environment variables

Static API Key

Static credentials can be provided by adding a apiKey in-line:

Usage:

# Pulumi.yaml provider configuration file
name: configuration-example
runtime: nodejs
config:
    fastly:apiKey:
        value: test
Copy
import * as pulumi from "@pulumi/pulumi";
import * as fastly from "@pulumi/fastly";

const myservice = new fastly.ServiceVcl("myservice", {});
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: python
config:
    fastly:apiKey:
        value: test
Copy
import pulumi
import pulumi_fastly as fastly

myservice = fastly.ServiceVcl("myservice")
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: dotnet
config:
    fastly:apiKey:
        value: test
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Fastly = Pulumi.Fastly;

return await Deployment.RunAsync(() =>
{
    var myservice = new Fastly.ServiceVcl("myservice");

});
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: go
config:
    fastly:apiKey:
        value: test
Copy
package main

import (
	"github.com/pulumi/pulumi-fastly/sdk/v8/go/fastly"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := fastly.NewServiceVcl(ctx, "myservice", nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: yaml
config:
    fastly:apiKey:
        value: test
Copy
resources:
  myservice:
    type: fastly:ServiceVcl
Copy
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: java
config:
    fastly:apiKey:
        value: test
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.fastly.ServiceVcl;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var myservice = new ServiceVcl("myservice");

    }
}
Copy

You can create a credential on the Personal API Tokens page: https://manage.fastly.com/account/personal/tokens

Environment variables

You can provide your API key via FASTLY_API_KEY environment variable, representing your Fastly API key.

import * as pulumi from "@pulumi/pulumi";
import * as fastly from "@pulumi/fastly";

const myservice = new fastly.ServiceVcl("myservice", {});
Copy
import pulumi
import pulumi_fastly as fastly

myservice = fastly.ServiceVcl("myservice")
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Fastly = Pulumi.Fastly;

return await Deployment.RunAsync(() =>
{
    var myservice = new Fastly.ServiceVcl("myservice");

});
Copy
package main

import (
	"github.com/pulumi/pulumi-fastly/sdk/v8/go/fastly"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		_, err := fastly.NewServiceVcl(ctx, "myservice", nil)
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
resources:
  myservice:
    type: fastly:ServiceVcl
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.fastly.ServiceVcl;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        var myservice = new ServiceVcl("myservice");

    }
}
Copy

Usage:

$ export FASTLY_API_KEY="afastlyapikey"
$ pulumi preview
Copy

Configuration Reference

  • apiKey (String) Fastly API Key from https://app.fastly.com/#account
  • baseUrl (String) Fastly API URL
  • forceHttp2 (Boolean) Set this to true to disable HTTP/1.x fallback mechanism that the underlying Go library will attempt upon connection to api.fastly.com:443 by default. This may slightly improve the provider’s performance and reduce unnecessary TLS handshakes. Default: false
  • noAuth (Boolean) Set to true if your configuration only consumes functions that do not require authentication, such as fastly.getFastlyIpRanges