@huaweicloudos/pulumi
Version:
A Pulumi package for creating and managing Huaweicloud cloud resources.
181 lines • 7.98 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.SecgroupRule = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* Manages a Security Group Rule resource within HuaweiCloud.
*
* ## Example Usage
* ### Create an ingress rule that opens TCP port 8080 with port range parameters
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const securityGroupId = config.requireObject("securityGroupId");
* const test = new huaweicloud.vpc.SecgroupRule("test", {
* securityGroupId: securityGroupId,
* direction: "ingress",
* ethertype: "IPv4",
* protocol: "tcp",
* portRangeMin: 8080,
* portRangeMax: 8080,
* remoteIpPrefix: "0.0.0.0/0",
* });
* ```
* ### Create an egress rule that opens TCP port 8080 with port range parameters
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const securityGroupId = config.requireObject("securityGroupId");
* const test = new huaweicloud.vpc.SecgroupRule("test", {
* securityGroupId: securityGroupId,
* direction: "egress",
* ethertype: "IPv4",
* protocol: "tcp",
* portRangeMin: 8080,
* portRangeMax: 8080,
* remoteIpPrefix: "0.0.0.0/0",
* });
* ```
* ### Create an ingress rule that enable the remote address group and open some TCP ports
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const groupName = config.requireObject("groupName");
* const securityGroupId = config.requireObject("securityGroupId");
* const testAddressGroup = new huaweicloud.vpc.AddressGroup("testAddressGroup", {addresses: [
* "192.168.10.12",
* "192.168.11.0-192.168.11.240",
* ]});
* const testSecgroupRule = new huaweicloud.vpc.SecgroupRule("testSecgroupRule", {
* securityGroupId: securityGroupId,
* direction: "ingress",
* action: "allow",
* ethertype: "IPv4",
* ports: "80,500,600-800",
* protocol: "tcp",
* priority: 5,
* remoteAddressGroupId: testAddressGroup.id,
* });
* ```
* ### Create an egress rule that enable the remote address group and open some TCP ports
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as pulumi from "@huaweicloudos/pulumi";
*
* const config = new pulumi.Config();
* const groupName = config.requireObject("groupName");
* const securityGroupId = config.requireObject("securityGroupId");
* const testAddressGroup = new huaweicloud.vpc.AddressGroup("testAddressGroup", {addresses: [
* "192.168.10.12",
* "192.168.11.0-192.168.11.240",
* ]});
* const testSecgroupRule = new huaweicloud.vpc.SecgroupRule("testSecgroupRule", {
* securityGroupId: securityGroupId,
* direction: "egress",
* action: "allow",
* ethertype: "IPv4",
* ports: "80,500,600-800",
* protocol: "tcp",
* priority: 5,
* remoteAddressGroupId: testAddressGroup.id,
* });
* ```
*
* ## Import
*
* Security Group Rules can be imported using the `id`, e.g. bash
*
* ```sh
* $ pulumi import huaweicloud:Vpc/secgroupRule:SecgroupRule secgroup_rule_1 aeb68ee3-6e9d-4256-955c-9584a6212745
* ```
*/
class SecgroupRule extends pulumi.CustomResource {
/**
* Get an existing SecgroupRule 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 SecgroupRule(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of SecgroupRule. 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'] === SecgroupRule.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["action"] = state ? state.action : undefined;
resourceInputs["description"] = state ? state.description : undefined;
resourceInputs["direction"] = state ? state.direction : undefined;
resourceInputs["ethertype"] = state ? state.ethertype : undefined;
resourceInputs["portRangeMax"] = state ? state.portRangeMax : undefined;
resourceInputs["portRangeMin"] = state ? state.portRangeMin : undefined;
resourceInputs["ports"] = state ? state.ports : undefined;
resourceInputs["priority"] = state ? state.priority : undefined;
resourceInputs["protocol"] = state ? state.protocol : undefined;
resourceInputs["region"] = state ? state.region : undefined;
resourceInputs["remoteAddressGroupId"] = state ? state.remoteAddressGroupId : undefined;
resourceInputs["remoteGroupId"] = state ? state.remoteGroupId : undefined;
resourceInputs["remoteIpPrefix"] = state ? state.remoteIpPrefix : undefined;
resourceInputs["securityGroupId"] = state ? state.securityGroupId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.direction === undefined) && !opts.urn) {
throw new Error("Missing required property 'direction'");
}
if ((!args || args.ethertype === undefined) && !opts.urn) {
throw new Error("Missing required property 'ethertype'");
}
if ((!args || args.securityGroupId === undefined) && !opts.urn) {
throw new Error("Missing required property 'securityGroupId'");
}
resourceInputs["action"] = args ? args.action : undefined;
resourceInputs["description"] = args ? args.description : undefined;
resourceInputs["direction"] = args ? args.direction : undefined;
resourceInputs["ethertype"] = args ? args.ethertype : undefined;
resourceInputs["portRangeMax"] = args ? args.portRangeMax : undefined;
resourceInputs["portRangeMin"] = args ? args.portRangeMin : undefined;
resourceInputs["ports"] = args ? args.ports : undefined;
resourceInputs["priority"] = args ? args.priority : undefined;
resourceInputs["protocol"] = args ? args.protocol : undefined;
resourceInputs["region"] = args ? args.region : undefined;
resourceInputs["remoteAddressGroupId"] = args ? args.remoteAddressGroupId : undefined;
resourceInputs["remoteGroupId"] = args ? args.remoteGroupId : undefined;
resourceInputs["remoteIpPrefix"] = args ? args.remoteIpPrefix : undefined;
resourceInputs["securityGroupId"] = args ? args.securityGroupId : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(SecgroupRule.__pulumiType, name, resourceInputs, opts);
}
}
exports.SecgroupRule = SecgroupRule;
/** @internal */
SecgroupRule.__pulumiType = 'huaweicloud:Vpc/secgroupRule:SecgroupRule';
//# sourceMappingURL=secgroupRule.js.map