Fastly Provider
Installation
The fastly provider is available as a package in all Pulumi languages:
- JavaScript/TypeScript:
@pulumi/fastly
- Python:
pulumi-fastly
- Go:
github.com/pulumi/pulumi-fastly/sdk/v8/go/fastly
- .NET:
Pulumi.Fastly
- Java:
com.pulumi/fastly
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
import * as pulumi from "@pulumi/pulumi";
import * as fastly from "@pulumi/fastly";
// Create a Service
const myservice = new fastly.ServiceVcl("myservice", {name: "myawesometestservice"});
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: python
config:
fastly:apiKey:
value: test
import pulumi
import pulumi_fastly as fastly
# Create a Service
myservice = fastly.ServiceVcl("myservice", name="myawesometestservice")
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: dotnet
config:
fastly:apiKey:
value: test
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",
});
});
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: go
config:
fastly:apiKey:
value: test
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
})
}
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: yaml
config:
fastly:apiKey:
value: test
resources:
# Create a Service
myservice:
type: fastly:ServiceVcl
properties:
name: myawesometestservice
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: java
config:
fastly:apiKey:
value: test
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());
}
}
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
import * as pulumi from "@pulumi/pulumi";
import * as fastly from "@pulumi/fastly";
const myservice = new fastly.ServiceVcl("myservice", {});
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: python
config:
fastly:apiKey:
value: test
import pulumi
import pulumi_fastly as fastly
myservice = fastly.ServiceVcl("myservice")
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: dotnet
config:
fastly:apiKey:
value: test
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Fastly = Pulumi.Fastly;
return await Deployment.RunAsync(() =>
{
var myservice = new Fastly.ServiceVcl("myservice");
});
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: go
config:
fastly:apiKey:
value: test
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
})
}
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: yaml
config:
fastly:apiKey:
value: test
resources:
myservice:
type: fastly:ServiceVcl
# Pulumi.yaml provider configuration file
name: configuration-example
runtime: java
config:
fastly:apiKey:
value: test
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");
}
}
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", {});
import pulumi
import pulumi_fastly as fastly
myservice = fastly.ServiceVcl("myservice")
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Fastly = Pulumi.Fastly;
return await Deployment.RunAsync(() =>
{
var myservice = new Fastly.ServiceVcl("myservice");
});
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
})
}
resources:
myservice:
type: fastly:ServiceVcl
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");
}
}
Usage:
$ export FASTLY_API_KEY="afastlyapikey"
$ pulumi preview
Configuration Reference
apiKey
(String) Fastly API Key from https://app.fastly.com/#accountbaseUrl
(String) Fastly API URLforceHttp2
(Boolean) Set this totrue
to disable HTTP/1.x fallback mechanism that the underlying Go library will attempt upon connection toapi.fastly.com:443
by default. This may slightly improve the provider’s performance and reduce unnecessary TLS handshakes. Default:false
noAuth
(Boolean) Set totrue
if your configuration only consumes functions that do not require authentication, such asfastly.getFastlyIpRanges