@pulumi/fastly
Version:
A Pulumi package for creating and managing fastly cloud resources.. Based on terraform-provider-fastly: version v4
101 lines • 3.85 kB
JavaScript
;
// *** WARNING: this file was generated by pulumi-language-nodejs. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.ServiceAuthorization = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Configures authorization with granular permissions to services. Users can be granted rights for services on different levels.
*
* The Service Authorization resource requires a user id, service id and an optional permission.
*
* ## Example Usage
*
* Basic usage:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as fastly from "@pulumi/fastly";
*
* const demo = new fastly.ServiceVcl("demo", {
* name: "demofastly",
* domains: [{
* name: "demo.notexample.com",
* comment: "demo",
* }],
* });
* const user = new fastly.User("user", {
* login: "demo@example.com",
* name: "Demo User",
* });
* const auth = new fastly.ServiceAuthorization("auth", {
* serviceId: demo.id,
* userId: user.id,
* permission: "purge_all",
* });
* ```
*
* ## Import
*
* A Fastly Service Authorization can be imported using their user ID, e.g.
*
* ```sh
* $ pulumi import fastly:index/serviceAuthorization:ServiceAuthorization demo xxxxxxxxxxxxxxxxxxxx
* ```
*/
class ServiceAuthorization extends pulumi.CustomResource {
/**
* Get an existing ServiceAuthorization resource's state with the given name, ID, and optional extra
* properties used to qualify the lookup.
*
* @param name The _unique_ name of the resulting resource.
* @param id The _unique_ provider ID of the resource to lookup.
* @param state Any extra arguments used during the lookup.
* @param opts Optional settings to control the behavior of the CustomResource.
*/
static get(name, id, state, opts) {
return new ServiceAuthorization(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of ServiceAuthorization. This is designed to work even
* when multiple copies of the Pulumi SDK have been loaded into the same process.
*/
static isInstance(obj) {
if (obj === undefined || obj === null) {
return false;
}
return obj['__pulumiType'] === ServiceAuthorization.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["permission"] = state?.permission;
resourceInputs["serviceId"] = state?.serviceId;
resourceInputs["userId"] = state?.userId;
}
else {
const args = argsOrState;
if (args?.permission === undefined && !opts.urn) {
throw new Error("Missing required property 'permission'");
}
if (args?.serviceId === undefined && !opts.urn) {
throw new Error("Missing required property 'serviceId'");
}
if (args?.userId === undefined && !opts.urn) {
throw new Error("Missing required property 'userId'");
}
resourceInputs["permission"] = args?.permission;
resourceInputs["serviceId"] = args?.serviceId;
resourceInputs["userId"] = args?.userId;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ServiceAuthorization.__pulumiType, name, resourceInputs, opts);
}
}
exports.ServiceAuthorization = ServiceAuthorization;
/** @internal */
ServiceAuthorization.__pulumiType = 'fastly:index/serviceAuthorization:ServiceAuthorization';
//# sourceMappingURL=serviceAuthorization.js.map