UNPKG

@pulumiverse/scaleway

Version:

A Pulumi package for creating and managing Scaleway cloud resources.

182 lines (181 loc) 7.26 kB
import * as pulumi from "@pulumi/pulumi"; import * as inputs from "./types/input"; import * as outputs from "./types/output"; /** * 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", * "4.5.6.7", * "7.8.9.10", * ]; * const mainSecurityGroupRules = new scaleway.instance.SecurityGroupRules("main", { * inboundRules: trusted.map((v, k) => ({key: k, value: v})).map(entry => ({ * action: "accept", * ip: entry.value, * 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 = [ * { * ip: "1.2.3.4", * port: "80", * }, * { * ip: "5.6.7.8", * port: "81", * }, * { * ip: "9.10.11.12", * port: "81", * }, * ]; * const mainSecurityGroupRules = new scaleway.instance.SecurityGroupRules("main", { * inboundRules: trusted.map((v, k) => ({key: k, value: v})).map(entry => ({ * action: "accept", * ip: entry.value.ip, * port: entry.value.port, * })), * securityGroupId: main.id, * }); * ``` * * ## Import * * Instance security group rules can be imported using the `{zone}/{id}`, e.g. * * bash * * ```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 */ export declare 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: string, id: pulumi.Input<pulumi.ID>, state?: InstanceSecurityGroupRulesState, opts?: pulumi.CustomResourceOptions): 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: any): obj is InstanceSecurityGroupRules; /** * A list of inbound rule to add to the security group. (Structure is documented below.) */ readonly inboundRules: pulumi.Output<outputs.InstanceSecurityGroupRulesInboundRule[] | undefined>; /** * A list of outbound rule to add to the security group. (Structure is documented below.) */ readonly outboundRules: pulumi.Output<outputs.InstanceSecurityGroupRulesOutboundRule[] | undefined>; /** * The ID of the security group. */ readonly securityGroupId: pulumi.Output<string>; /** * Create a InstanceSecurityGroupRules resource with the given unique name, arguments, and options. * * @param name The _unique_ name of the resource. * @param args The arguments to use to populate this resource's properties. * @param opts A bag of options that control this resource's behavior. */ /** @deprecated scaleway.index/instancesecuritygrouprules.InstanceSecurityGroupRules has been deprecated in favor of scaleway.instance/securitygrouprules.SecurityGroupRules */ constructor(name: string, args: InstanceSecurityGroupRulesArgs, opts?: pulumi.CustomResourceOptions); } /** * Input properties used for looking up and filtering InstanceSecurityGroupRules resources. */ export interface InstanceSecurityGroupRulesState { /** * A list of inbound rule to add to the security group. (Structure is documented below.) */ inboundRules?: pulumi.Input<pulumi.Input<inputs.InstanceSecurityGroupRulesInboundRule>[]>; /** * A list of outbound rule to add to the security group. (Structure is documented below.) */ outboundRules?: pulumi.Input<pulumi.Input<inputs.InstanceSecurityGroupRulesOutboundRule>[]>; /** * The ID of the security group. */ securityGroupId?: pulumi.Input<string>; } /** * The set of arguments for constructing a InstanceSecurityGroupRules resource. */ export interface InstanceSecurityGroupRulesArgs { /** * A list of inbound rule to add to the security group. (Structure is documented below.) */ inboundRules?: pulumi.Input<pulumi.Input<inputs.InstanceSecurityGroupRulesInboundRule>[]>; /** * A list of outbound rule to add to the security group. (Structure is documented below.) */ outboundRules?: pulumi.Input<pulumi.Input<inputs.InstanceSecurityGroupRulesOutboundRule>[]>; /** * The ID of the security group. */ securityGroupId: pulumi.Input<string>; }