@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
267 lines • 9.71 kB
JavaScript
;
// *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.Trigger = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages a trigger resource within HuaweiCloud FunctionGraph.\
* It's recommend to use `huaweicloudFgsFunctionTrigger`, which makes a great improvement of managing function triggers.
*
* ## Example Usage
* ### Create a Timing Trigger with rate schedule type
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const functionUrn = config.requireObject("functionUrn");
* const triggerName = config.requireObject("triggerName");
* const test = new huaweicloud.functiongraph.Trigger("test", {
* functionUrn: functionUrn,
* type: "TIMER",
* timer: {
* name: triggerName,
* scheduleType: "Rate",
* schedule: "1d",
* },
* });
* ```
* ### Create a Timing Trigger with cron schedule type
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const functionUrn = config.requireObject("functionUrn");
* const triggerName = config.requireObject("triggerName");
* const test = new huaweicloud.functiongraph.Trigger("test", {
* functionUrn: functionUrn,
* type: "TIMER",
* timer: {
* name: triggerName,
* scheduleType: "Cron",
* schedule: "@every 1h30m",
* },
* });
* ```
* ### Create an OBS trigger
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const functionUrn = config.requireObject("functionUrn");
* const bucketName = config.requireObject("bucketName");
* const triggerName = config.requireObject("triggerName");
* const test = new huaweicloud.functiongraph.Trigger("test", {
* functionUrn: functionUrn,
* type: "OBS",
* status: "ACTIVE",
* obs: {
* bucketName: bucketName,
* eventNotificationName: triggerName,
* suffix: ".json",
* events: ["ObjectCreated"],
* },
* });
* ```
* ### Create an SMN trigger
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const functionUrn = config.requireObject("functionUrn");
* const topicUrn = config.requireObject("topicUrn");
* const test = new huaweicloud.functiongraph.Trigger("test", {
* functionUrn: functionUrn,
* type: "SMN",
* status: "ACTIVE",
* smn: {
* topicUrn: topicUrn,
* },
* });
* ```
* ### Create a DIS trigger
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const functionUrn = config.requireObject("functionUrn");
* const streamName = config.requireObject("streamName");
* const test = new huaweicloud.functiongraph.Trigger("test", {
* functionUrn: functionUrn,
* type: "DIS",
* status: "ACTIVE",
* dis: {
* streamName: streamName,
* startingPosition: "TRIM_HORIZON",
* maxFetchBytes: 2097152,
* pullPeriod: 30000,
* serialEnable: true,
* },
* });
* ```
* ### Create a DMS Kafka trigger
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const functionUrn = config.requireObject("functionUrn");
* const kafkaInstanceId = config.requireObject("kafkaInstanceId");
* const kafkaTopicId = config.requireObject("kafkaTopicId");
* const userPassword = config.requireObject("userPassword");
* const test = new huaweicloud.functiongraph.Trigger("test", {
* functionUrn: functionUrn,
* type: "KAFKA",
* kafka: {
* instanceId: kafkaInstanceId,
* userName: "user",
* password: userPassword,
* batchSize: 100,
* topicIds: [kafkaTopicId],
* },
* });
* ```
* ### Create a Dedicated APIG trigger
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const functionUrn = config.requireObject("functionUrn");
* const instanceId = config.requireObject("instanceId");
* const groupId = config.requireObject("groupId");
* const apiName = config.requireObject("apiName");
* const test = new huaweicloud.functiongraph.Trigger("test", {
* functionUrn: functionUrn,
* type: "DEDICATEDGATEWAY",
* status: "ACTIVE",
* apig: {
* instanceId: instanceId,
* groupId: groupId,
* apiName: apiName,
* envName: "RELEASE",
* },
* });
* ```
* ### Create a Shared APIG trigger
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const functionUrn = config.requireObject("functionUrn");
* const groupId = config.requireObject("groupId");
* const apiName = config.requireObject("apiName");
* const test = new huaweicloud.functiongraph.Trigger("test", {
* functionUrn: functionUrn,
* type: "APIG",
* status: "ACTIVE",
* apig: {
* groupId: groupId,
* apiName: apiName,
* envName: "RELEASE",
* },
* });
* ```
* ### Create a LTS trigger
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const logGroupId = config.requireObject("logGroupId");
* const logTopicId = config.requireObject("logTopicId");
* const test = new huaweicloud.functiongraph.Trigger("test", {
* functionUrn: _var.function_urn,
* type: "LTS",
* status: "ACTIVE",
* lts: {
* logGroupId: logGroupId,
* logTopicId: logTopicId,
* },
* });
* ```
*/
class Trigger extends pulumi.CustomResource {
/**
* Get an existing Trigger 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 Trigger(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of Trigger. 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'] === Trigger.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["apig"] = state ? state.apig : undefined;
resourceInputs["dis"] = state ? state.dis : undefined;
resourceInputs["functionUrn"] = state ? state.functionUrn : undefined;
resourceInputs["kafka"] = state ? state.kafka : undefined;
resourceInputs["lts"] = state ? state.lts : undefined;
resourceInputs["obs"] = state ? state.obs : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["smn"] = state ? state.smn : undefined;
resourceInputs["status"] = state ? state.status : undefined;
resourceInputs["timer"] = state ? state.timer : undefined;
resourceInputs["type"] = state ? state.type : undefined;
}
else {
const args = argsOrState;
if ((!args || args.functionUrn === undefined) && !opts.urn) {
throw new Error("Missing required property 'functionUrn'");
}
if ((!args || args.type === undefined) && !opts.urn) {
throw new Error("Missing required property 'type'");
}
resourceInputs["apig"] = args ? args.apig : undefined;
resourceInputs["dis"] = args ? args.dis : undefined;
resourceInputs["functionUrn"] = args ? args.functionUrn : undefined;
resourceInputs["kafka"] = args ? args.kafka : undefined;
resourceInputs["lts"] = args ? args.lts : undefined;
resourceInputs["obs"] = args ? args.obs : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["smn"] = args ? args.smn : undefined;
resourceInputs["status"] = args ? args.status : undefined;
resourceInputs["timer"] = args ? args.timer : undefined;
resourceInputs["type"] = args ? args.type : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(Trigger.__pulumiType, name, resourceInputs, opts);
}
}
exports.Trigger = Trigger;
/** @internal */
Trigger.__pulumiType = 'huaweicloud:FunctionGraph/trigger:Trigger';
//# sourceMappingURL=trigger.js.map