1. Packages
  2. Packages
  3. Newrelic Provider
  4. API Docs
  5. synthetics
  6. MonitorScript
Viewing docs for New Relic v4.20.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi
newrelic logo
Viewing docs for New Relic v4.20.0 (Older version)
published on Monday, Mar 9, 2026 by Pulumi

    Use this resource to update a synthetics monitor script in New Relic.

    Example Usage

    using System.Collections.Generic;
    using System.IO;
    using Pulumi;
    using NewRelic = Pulumi.NewRelic;
    
    return await Deployment.RunAsync(() => 
    {
        var foo = new NewRelic.Synthetics.Monitor("foo", new()
        {
            Type = "SCRIPT_BROWSER",
            Frequency = 5,
            Status = "ENABLED",
            Locations = new[]
            {
                "AWS_US_EAST_1",
            },
        });
    
        var fooScript = new NewRelic.Synthetics.MonitorScript("fooScript", new()
        {
            MonitorId = foo.Id,
            Text = File.ReadAllText($"{path.Module}/foo_script.js"),
            Locations = new[]
            {
                new NewRelic.Synthetics.Inputs.MonitorScriptLocationArgs
                {
                    Name = "YWJjZAo=",
                    Hmac = "ZmFrZWxvY2F0aW9uc2NyaXB0ZmFrZQ==",
                },
            },
        });
    
    });
    
    package main
    
    import (
    	"fmt"
    	"io/ioutil"
    
    	"github.com/pulumi/pulumi-newrelic/sdk/v4/go/newrelic/synthetics"
    	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
    )
    
    func readFileOrPanic(path string) pulumi.StringPtrInput {
    	data, err := ioutil.ReadFile(path)
    	if err != nil {
    		panic(err.Error())
    	}
    	return pulumi.String(string(data))
    }
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		foo, err := synthetics.NewMonitor(ctx, "foo", &synthetics.MonitorArgs{
    			Type:      pulumi.String("SCRIPT_BROWSER"),
    			Frequency: pulumi.Int(5),
    			Status:    pulumi.String("ENABLED"),
    			Locations: pulumi.StringArray{
    				pulumi.String("AWS_US_EAST_1"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = synthetics.NewMonitorScript(ctx, "fooScript", &synthetics.MonitorScriptArgs{
    			MonitorId: foo.ID(),
    			Text:      readFileOrPanic(fmt.Sprintf("%v/foo_script.js", path.Module)),
    			Locations: synthetics.MonitorScriptLocationArray{
    				&synthetics.MonitorScriptLocationArgs{
    					Name: pulumi.String("YWJjZAo="),
    					Hmac: pulumi.String("ZmFrZWxvY2F0aW9uc2NyaXB0ZmFrZQ=="),
    				},
    			},
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.newrelic.synthetics.Monitor;
    import com.pulumi.newrelic.synthetics.MonitorArgs;
    import com.pulumi.newrelic.synthetics.MonitorScript;
    import com.pulumi.newrelic.synthetics.MonitorScriptArgs;
    import com.pulumi.newrelic.synthetics.inputs.MonitorScriptLocationArgs;
    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 foo = new Monitor("foo", MonitorArgs.builder()        
                .type("SCRIPT_BROWSER")
                .frequency(5)
                .status("ENABLED")
                .locations("AWS_US_EAST_1")
                .build());
    
            var fooScript = new MonitorScript("fooScript", MonitorScriptArgs.builder()        
                .monitorId(foo.id())
                .text(Files.readString(Paths.get(String.format("%s/foo_script.js", path.module()))))
                .locations(MonitorScriptLocationArgs.builder()
                    .name("YWJjZAo=")
                    .hmac("ZmFrZWxvY2F0aW9uc2NyaXB0ZmFrZQ==")
                    .build())
                .build());
    
        }
    }
    
    import * as pulumi from "@pulumi/pulumi";
    import * as fs from "fs";
    import * as newrelic from "@pulumi/newrelic";
    
    const foo = new newrelic.synthetics.Monitor("foo", {
        type: "SCRIPT_BROWSER",
        frequency: 5,
        status: "ENABLED",
        locations: ["AWS_US_EAST_1"],
    });
    const fooScript = new newrelic.synthetics.MonitorScript("fooScript", {
        monitorId: foo.id,
        text: fs.readFileSync(`${path.module}/foo_script.js`),
        locations: [{
            name: "YWJjZAo=",
            hmac: "ZmFrZWxvY2F0aW9uc2NyaXB0ZmFrZQ==",
        }],
    });
    
    import pulumi
    import pulumi_newrelic as newrelic
    
    foo = newrelic.synthetics.Monitor("foo",
        type="SCRIPT_BROWSER",
        frequency=5,
        status="ENABLED",
        locations=["AWS_US_EAST_1"])
    foo_script = newrelic.synthetics.MonitorScript("fooScript",
        monitor_id=foo.id,
        text=(lambda path: open(path).read())(f"{path['module']}/foo_script.js"),
        locations=[newrelic.synthetics.MonitorScriptLocationArgs(
            name="YWJjZAo=",
            hmac="ZmFrZWxvY2F0aW9uc2NyaXB0ZmFrZQ==",
        )])
    

    Example coming soon!

    Create MonitorScript Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new MonitorScript(name: string, args: MonitorScriptArgs, opts?: CustomResourceOptions);
    @overload
    def MonitorScript(resource_name: str,
                      args: MonitorScriptArgs,
                      opts: Optional[ResourceOptions] = None)
    
    @overload
    def MonitorScript(resource_name: str,
                      opts: Optional[ResourceOptions] = None,
                      monitor_id: Optional[str] = None,
                      text: Optional[str] = None,
                      locations: Optional[Sequence[MonitorScriptLocationArgs]] = None)
    func NewMonitorScript(ctx *Context, name string, args MonitorScriptArgs, opts ...ResourceOption) (*MonitorScript, error)
    public MonitorScript(string name, MonitorScriptArgs args, CustomResourceOptions? opts = null)
    public MonitorScript(String name, MonitorScriptArgs args)
    public MonitorScript(String name, MonitorScriptArgs args, CustomResourceOptions options)
    
    type: newrelic:synthetics:MonitorScript
    properties: # The arguments to resource properties.
    options: # Bag of options to control resource's behavior.
    
    

    Parameters

    name string
    The unique name of the resource.
    args MonitorScriptArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args MonitorScriptArgs
    The arguments to resource properties.
    opts ResourceOptions
    Bag of options to control resource's behavior.
    ctx Context
    Context object for the current deployment.
    name string
    The unique name of the resource.
    args MonitorScriptArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args MonitorScriptArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args MonitorScriptArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Constructor example

    The following reference example uses placeholder values for all input properties.

    var monitorScriptResource = new NewRelic.Synthetics.MonitorScript("monitorScriptResource", new()
    {
        MonitorId = "string",
        Text = "string",
        Locations = new[]
        {
            new NewRelic.Synthetics.Inputs.MonitorScriptLocationArgs
            {
                Name = "string",
                Hmac = "string",
                VsePassword = "string",
            },
        },
    });
    
    example, err := synthetics.NewMonitorScript(ctx, "monitorScriptResource", &synthetics.MonitorScriptArgs{
    	MonitorId: pulumi.String("string"),
    	Text:      pulumi.String("string"),
    	Locations: synthetics.MonitorScriptLocationArray{
    		&synthetics.MonitorScriptLocationArgs{
    			Name:        pulumi.String("string"),
    			Hmac:        pulumi.String("string"),
    			VsePassword: pulumi.String("string"),
    		},
    	},
    })
    
    var monitorScriptResource = new MonitorScript("monitorScriptResource", MonitorScriptArgs.builder()
        .monitorId("string")
        .text("string")
        .locations(MonitorScriptLocationArgs.builder()
            .name("string")
            .hmac("string")
            .vsePassword("string")
            .build())
        .build());
    
    monitor_script_resource = newrelic.synthetics.MonitorScript("monitorScriptResource",
        monitor_id="string",
        text="string",
        locations=[{
            "name": "string",
            "hmac": "string",
            "vse_password": "string",
        }])
    
    const monitorScriptResource = new newrelic.synthetics.MonitorScript("monitorScriptResource", {
        monitorId: "string",
        text: "string",
        locations: [{
            name: "string",
            hmac: "string",
            vsePassword: "string",
        }],
    });
    
    type: newrelic:synthetics:MonitorScript
    properties:
        locations:
            - hmac: string
              name: string
              vsePassword: string
        monitorId: string
        text: string
    

    MonitorScript Resource Properties

    To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

    Inputs

    In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

    The MonitorScript resource accepts the following input properties:

    MonitorId string
    The ID of the monitor to attach the script to.
    Text string
    The plaintext representing the monitor script.
    Locations List<Pulumi.NewRelic.Synthetics.Inputs.MonitorScriptLocation>
    A nested block that describes a monitor script location. See Nested location blocks below for details
    MonitorId string
    The ID of the monitor to attach the script to.
    Text string
    The plaintext representing the monitor script.
    Locations []MonitorScriptLocationArgs
    A nested block that describes a monitor script location. See Nested location blocks below for details
    monitorId String
    The ID of the monitor to attach the script to.
    text String
    The plaintext representing the monitor script.
    locations List<MonitorScriptLocation>
    A nested block that describes a monitor script location. See Nested location blocks below for details
    monitorId string
    The ID of the monitor to attach the script to.
    text string
    The plaintext representing the monitor script.
    locations MonitorScriptLocation[]
    A nested block that describes a monitor script location. See Nested location blocks below for details
    monitor_id str
    The ID of the monitor to attach the script to.
    text str
    The plaintext representing the monitor script.
    locations Sequence[MonitorScriptLocationArgs]
    A nested block that describes a monitor script location. See Nested location blocks below for details
    monitorId String
    The ID of the monitor to attach the script to.
    text String
    The plaintext representing the monitor script.
    locations List<Property Map>
    A nested block that describes a monitor script location. See Nested location blocks below for details

    Outputs

    All input properties are implicitly available as output properties. Additionally, the MonitorScript resource produces the following output properties:

    Id string
    The provider-assigned unique ID for this managed resource.
    Id string
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.
    id string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing MonitorScript Resource

    Get an existing MonitorScript resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

    public static get(name: string, id: Input<ID>, state?: MonitorScriptState, opts?: CustomResourceOptions): MonitorScript
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            locations: Optional[Sequence[MonitorScriptLocationArgs]] = None,
            monitor_id: Optional[str] = None,
            text: Optional[str] = None) -> MonitorScript
    func GetMonitorScript(ctx *Context, name string, id IDInput, state *MonitorScriptState, opts ...ResourceOption) (*MonitorScript, error)
    public static MonitorScript Get(string name, Input<string> id, MonitorScriptState? state, CustomResourceOptions? opts = null)
    public static MonitorScript get(String name, Output<String> id, MonitorScriptState state, CustomResourceOptions options)
    resources:  _:    type: newrelic:synthetics:MonitorScript    get:      id: ${id}
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    resource_name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    name
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    state
    Any extra arguments used during the lookup.
    opts
    A bag of options that control this resource's behavior.
    The following state arguments are supported:
    Locations List<Pulumi.NewRelic.Synthetics.Inputs.MonitorScriptLocation>
    A nested block that describes a monitor script location. See Nested location blocks below for details
    MonitorId string
    The ID of the monitor to attach the script to.
    Text string
    The plaintext representing the monitor script.
    Locations []MonitorScriptLocationArgs
    A nested block that describes a monitor script location. See Nested location blocks below for details
    MonitorId string
    The ID of the monitor to attach the script to.
    Text string
    The plaintext representing the monitor script.
    locations List<MonitorScriptLocation>
    A nested block that describes a monitor script location. See Nested location blocks below for details
    monitorId String
    The ID of the monitor to attach the script to.
    text String
    The plaintext representing the monitor script.
    locations MonitorScriptLocation[]
    A nested block that describes a monitor script location. See Nested location blocks below for details
    monitorId string
    The ID of the monitor to attach the script to.
    text string
    The plaintext representing the monitor script.
    locations Sequence[MonitorScriptLocationArgs]
    A nested block that describes a monitor script location. See Nested location blocks below for details
    monitor_id str
    The ID of the monitor to attach the script to.
    text str
    The plaintext representing the monitor script.
    locations List<Property Map>
    A nested block that describes a monitor script location. See Nested location blocks below for details
    monitorId String
    The ID of the monitor to attach the script to.
    text String
    The plaintext representing the monitor script.

    Supporting Types

    MonitorScriptLocation, MonitorScriptLocationArgs

    Name string
    The monitor script location name.
    Hmac string
    The monitor script authentication code for the location. Use one of either hmac or vse_password.
    VsePassword string
    The password for the location used to calculate the HMAC. Use one of either hmac or vse_password.
    Name string
    The monitor script location name.
    Hmac string
    The monitor script authentication code for the location. Use one of either hmac or vse_password.
    VsePassword string
    The password for the location used to calculate the HMAC. Use one of either hmac or vse_password.
    name String
    The monitor script location name.
    hmac String
    The monitor script authentication code for the location. Use one of either hmac or vse_password.
    vsePassword String
    The password for the location used to calculate the HMAC. Use one of either hmac or vse_password.
    name string
    The monitor script location name.
    hmac string
    The monitor script authentication code for the location. Use one of either hmac or vse_password.
    vsePassword string
    The password for the location used to calculate the HMAC. Use one of either hmac or vse_password.
    name str
    The monitor script location name.
    hmac str
    The monitor script authentication code for the location. Use one of either hmac or vse_password.
    vse_password str
    The password for the location used to calculate the HMAC. Use one of either hmac or vse_password.
    name String
    The monitor script location name.
    hmac String
    The monitor script authentication code for the location. Use one of either hmac or vse_password.
    vsePassword String
    The password for the location used to calculate the HMAC. Use one of either hmac or vse_password.

    Import

    Synthetics monitor scripts can be imported using the id, e.g. bash

     $ pulumi import newrelic:synthetics/monitorScript:MonitorScript main <id>
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    New Relic pulumi/pulumi-newrelic
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the newrelic Terraform Provider.
    newrelic logo
    Viewing docs for New Relic v4.20.0 (Older version)
    published on Monday, Mar 9, 2026 by Pulumi
      Try Pulumi Cloud free. Your team will thank you.