@pulumiverse/scaleway
Version:
A Pulumi package for creating and managing Scaleway cloud resources.
186 lines • 7.97 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! ***
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.InstanceSecurityGroupRules = void 0;
const pulumi = __importStar(require("@pulumi/pulumi"));
const utilities = __importStar(require("./utilities"));
/**
* Creates and manages Scaleway compute Instance security group rules. For more information, see the [API documentation](https://www.scaleway.com/en/developers/api/instance/#path-security-groups-list-security-groups).
*
* This resource can be used to externalize rules from a `scaleway.instance.SecurityGroup` to solve circular dependency problems. When using this resource do not forget to set `externalRules = true` on the security group.
*
* > **Warning:** In order to guaranty rules order in a given security group only one scaleway.instance.SecurityGroupRules is allowed per security group.
*
* ## Example Usage
*
* ### Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const sg01 = new scaleway.instance.SecurityGroup("sg01", {externalRules: true});
* const sgrs01 = new scaleway.instance.SecurityGroupRules("sgrs01", {
* securityGroupId: sg01.id,
* inboundRules: [{
* action: "accept",
* port: 80,
* ipRange: "0.0.0.0/0",
* }],
* });
* ```
*
* ### Simplify your rules using dynamic block and `forEach` loop
*
* You can use `forEach` syntax to simplify the definition of your rules.
* Let's suppose that your inbound default policy is to drop, but you want to build a list of exceptions to accept.
* Create a local containing your exceptions (`locals.trusted`) and use the `forEach` syntax in a dynamic block:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const main = new scaleway.instance.SecurityGroup("main", {
* description: "test",
* name: "terraform test",
* inboundDefaultPolicy: "drop",
* outboundDefaultPolicy: "accept",
* });
* const trusted = [
* "1.2.3.4/32",
* "4.5.6.7/32",
* "7.8.9.10/24",
* ];
* const mainSecurityGroupRules = new scaleway.instance.SecurityGroupRules("main", {
* inboundRules: trusted.map(entry => ({
* action: "accept",
* ipRange: entry,
* port: 80,
* })),
* securityGroupId: main.id,
* });
* ```
*
* You can also use object to assign IP and port in the same time.
* In your locals, you can use objects to encapsulate several values that will be used later on in the loop:
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as scaleway from "@pulumiverse/scaleway";
*
* const main = new scaleway.instance.SecurityGroup("main", {
* description: "test",
* name: "terraform test",
* inboundDefaultPolicy: "drop",
* outboundDefaultPolicy: "accept",
* });
* const trusted = [
* {
* ipRange: "1.2.3.4/32",
* port: "80",
* },
* {
* ipRange: "5.6.7.8/32",
* port: "81",
* },
* {
* ipRange: "9.10.11.12/32",
* port: "81",
* },
* ];
* const mainSecurityGroupRules = new scaleway.instance.SecurityGroupRules("main", {
* inboundRules: trusted.map(entry => ({
* action: "accept",
* ipRange: entry.ipRange,
* port: Number(entry.port),
* })),
* securityGroupId: main.id,
* });
* ```
*
* ## Import
*
* Instance security group rules can be imported using the `{zone}/{id}`, e.g.
*
* ```sh
* $ pulumi import scaleway:index/instanceSecurityGroupRules:InstanceSecurityGroupRules web fr-par-1/11111111-1111-1111-1111-111111111111
* ```
*
* @deprecated scaleway.index/instancesecuritygrouprules.InstanceSecurityGroupRules has been deprecated in favor of scaleway.instance/securitygrouprules.SecurityGroupRules
*/
class InstanceSecurityGroupRules extends pulumi.CustomResource {
/**
* Get an existing InstanceSecurityGroupRules 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) {
pulumi.log.warn("InstanceSecurityGroupRules is deprecated: scaleway.index/instancesecuritygrouprules.InstanceSecurityGroupRules has been deprecated in favor of scaleway.instance/securitygrouprules.SecurityGroupRules");
return new InstanceSecurityGroupRules(name, state, { ...opts, id: id });
}
/** @internal */
static __pulumiType = 'scaleway:index/instanceSecurityGroupRules:InstanceSecurityGroupRules';
/**
* Returns true if the given object is an instance of InstanceSecurityGroupRules. 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'] === InstanceSecurityGroupRules.__pulumiType;
}
/** @deprecated scaleway.index/instancesecuritygrouprules.InstanceSecurityGroupRules has been deprecated in favor of scaleway.instance/securitygrouprules.SecurityGroupRules */
constructor(name, argsOrState, opts) {
pulumi.log.warn("InstanceSecurityGroupRules is deprecated: scaleway.index/instancesecuritygrouprules.InstanceSecurityGroupRules has been deprecated in favor of scaleway.instance/securitygrouprules.SecurityGroupRules");
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["inboundRules"] = state?.inboundRules;
resourceInputs["outboundRules"] = state?.outboundRules;
resourceInputs["securityGroupId"] = state?.securityGroupId;
}
else {
const args = argsOrState;
if (args?.securityGroupId === undefined && !opts.urn) {
throw new Error("Missing required property 'securityGroupId'");
}
resourceInputs["inboundRules"] = args?.inboundRules;
resourceInputs["outboundRules"] = args?.outboundRules;
resourceInputs["securityGroupId"] = args?.securityGroupId;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(InstanceSecurityGroupRules.__pulumiType, name, resourceInputs, opts);
}
}
exports.InstanceSecurityGroupRules = InstanceSecurityGroupRules;
//# sourceMappingURL=instanceSecurityGroupRules.js.map