@pulumi/yandex
Version:
A Pulumi package for creating and managing yandex cloud resources.
120 lines • 5.99 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.VpcSecurityGroupRule = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Manages a single Secuirity Group Rule within the Yandex.Cloud. For more information, see the official documentation
* of [security groups](https://cloud.yandex.com/docs/vpc/concepts/security-groups)
* and [security group rules](https://cloud.yandex.com/docs/vpc/concepts/security-groups#rules).
*
* > **NOTE:** There is another way to manage security group rules by `ingress` and `egress` arguments in yandex_vpc_security_group. Both ways are equivalent but not compatible now. Using in-line rules of yandex.VpcSecurityGroup with Security Group Rule resource at the same time will cause a conflict of rules configuration.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as yandex from "@pulumi/yandex";
*
* const lab_net = new yandex.VpcNetwork("lab-net", {});
* const group1 = new yandex.VpcSecurityGroup("group1", {
* description: "description for my security group",
* networkId: lab_net.id,
* labels: {
* "my-label": "my-label-value",
* },
* });
* const rule1 = new yandex.VpcSecurityGroupRule("rule1", {
* securityGroupBinding: group1.id,
* direction: "ingress",
* description: "rule1 description",
* v4CidrBlocks: [
* "10.0.1.0/24",
* "10.0.2.0/24",
* ],
* port: 8080,
* protocol: "TCP",
* });
* const rule2 = new yandex.VpcSecurityGroupRule("rule2", {
* securityGroupBinding: group1.id,
* direction: "egress",
* description: "rule2 description",
* v4CidrBlocks: ["10.0.1.0/24"],
* fromPort: 8090,
* toPort: 8099,
* protocol: "UDP",
* });
* ```
*/
class VpcSecurityGroupRule extends pulumi.CustomResource {
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["direction"] = state ? state.direction : undefined;
resourceInputs["fromPort"] = state ? state.fromPort : undefined;
resourceInputs["labels"] = state ? state.labels : undefined;
resourceInputs["port"] = state ? state.port : undefined;
resourceInputs["predefinedTarget"] = state ? state.predefinedTarget : undefined;
resourceInputs["protocol"] = state ? state.protocol : undefined;
resourceInputs["securityGroupBinding"] = state ? state.securityGroupBinding : undefined;
resourceInputs["securityGroupId"] = state ? state.securityGroupId : undefined;
resourceInputs["toPort"] = state ? state.toPort : undefined;
resourceInputs["v4CidrBlocks"] = state ? state.v4CidrBlocks : undefined;
resourceInputs["v6CidrBlocks"] = state ? state.v6CidrBlocks : undefined;
}
else {
const args = argsOrState;
if ((!args || args.direction === undefined) && !opts.urn) {
throw new Error("Missing required property 'direction'");
}
if ((!args || args.securityGroupBinding === undefined) && !opts.urn) {
throw new Error("Missing required property 'securityGroupBinding'");
}
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["direction"] = args ? args.direction : undefined;
resourceInputs["fromPort"] = args ? args.fromPort : undefined;
resourceInputs["labels"] = args ? args.labels : undefined;
resourceInputs["port"] = args ? args.port : undefined;
resourceInputs["predefinedTarget"] = args ? args.predefinedTarget : undefined;
resourceInputs["protocol"] = args ? args.protocol : undefined;
resourceInputs["securityGroupBinding"] = args ? args.securityGroupBinding : undefined;
resourceInputs["securityGroupId"] = args ? args.securityGroupId : undefined;
resourceInputs["toPort"] = args ? args.toPort : undefined;
resourceInputs["v4CidrBlocks"] = args ? args.v4CidrBlocks : undefined;
resourceInputs["v6CidrBlocks"] = args ? args.v6CidrBlocks : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(VpcSecurityGroupRule.__pulumiType, name, resourceInputs, opts);
}
/**
* Get an existing VpcSecurityGroupRule 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 VpcSecurityGroupRule(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of VpcSecurityGroupRule. 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'] === VpcSecurityGroupRule.__pulumiType;
}
}
exports.VpcSecurityGroupRule = VpcSecurityGroupRule;
/** @internal */
VpcSecurityGroupRule.__pulumiType = 'yandex:index/vpcSecurityGroupRule:VpcSecurityGroupRule';
//# sourceMappingURL=vpcSecurityGroupRule.js.map