UNPKG

@huaweicloudos/pulumi

Version:

A Pulumi package for creating and managing Huaweicloud cloud resources.

146 lines 6.46 kB
"use strict"; // *** 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.InterfaceAttach = void 0; const pulumi = require("@pulumi/pulumi"); const utilities = require("../utilities"); /** * Attaches a Network Interface to an Instance. * * ## Example Usage * ### Attach a port (under the specified network) to the ECS instance and generate a random IP address * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const instanceId = config.requireObject("instanceId"); * const networkId = config.requireObject("networkId"); * const test = new huaweicloud.ecs.InterfaceAttach("test", { * instanceId: instanceId, * networkId: networkId, * }); * ``` * ### Attach a port (under the specified network) to the ECS instance and use the custom security groups * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const instanceId = config.requireObject("instanceId"); * const networkId = config.requireObject("networkId"); * const securityGroupIds = config.requireObject("securityGroupIds"); * const test = new huaweicloud.ecs.InterfaceAttach("test", { * instanceId: instanceId, * networkId: networkId, * securityGroupIds: securityGroupIds, * }); * ``` * ### Attach a custom port to the ECS instance * * ```typescript * import * as pulumi from "@pulumi/pulumi"; * import * as huaweicloud from "@pulumi/huaweicloud"; * import * as pulumi from "@huaweicloudos/pulumi"; * * const config = new pulumi.Config(); * const securityGroupId = config.requireObject("securityGroupId"); * const mynet = huaweicloud.Vpc.getSubnet({ * name: "subnet-default", * }); * const myport = mynet.then(mynet => huaweicloud.Vpc.getPort({ * networkId: mynet.id, * fixedIp: "192.168.0.100", * })); * const myinstance = new huaweicloud.ecs.Instance("myinstance", { * imageId: "ad091b52-742f-469e-8f3c-fd81cadf0743", * flavorId: "s6.small.1", * keyPair: "my_key_pair_name", * securityGroupIds: [securityGroupId], * availabilityZone: "cn-north-4a", * networks: [{ * uuid: "55534eaa-533a-419d-9b40-ec427ea7195a", * }], * }); * const attached = new huaweicloud.ecs.InterfaceAttach("attached", { * instanceId: myinstance.id, * portId: myport.then(myport => myport.id), * }); * ``` * * ## Import * * Interface Attachments can be imported using the Instance ID and Port ID separated by a slash, e.g. * * ```sh * $ pulumi import huaweicloud:Ecs/interfaceAttach:InterfaceAttach ai_1 89c60255-9bd6-460c-822a-e2b959ede9d2/45670584-225f-46c3-b33e-6707b589b666 * ``` */ class InterfaceAttach extends pulumi.CustomResource { /** * Get an existing InterfaceAttach 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 InterfaceAttach(name, state, Object.assign(Object.assign({}, opts), { id: id })); } /** * Returns true if the given object is an instance of InterfaceAttach. 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'] === InterfaceAttach.__pulumiType; } constructor(name, argsOrState, opts) { let resourceInputs = {}; opts = opts || {}; if (opts.id) { const state = argsOrState; resourceInputs["fixedIp"] = state ? state.fixedIp : undefined; resourceInputs["fixedIpv6"] = state ? state.fixedIpv6 : undefined; resourceInputs["instanceId"] = state ? state.instanceId : undefined; resourceInputs["ipv6BandwidthId"] = state ? state.ipv6BandwidthId : undefined; resourceInputs["ipv6Enable"] = state ? state.ipv6Enable : undefined; resourceInputs["mac"] = state ? state.mac : undefined; resourceInputs["networkId"] = state ? state.networkId : undefined; resourceInputs["portId"] = state ? state.portId : undefined; resourceInputs["region"] = state ? state.region : undefined; resourceInputs["securityGroupIds"] = state ? state.securityGroupIds : undefined; resourceInputs["sourceDestCheck"] = state ? state.sourceDestCheck : undefined; } else { const args = argsOrState; if ((!args || args.instanceId === undefined) && !opts.urn) { throw new Error("Missing required property 'instanceId'"); } resourceInputs["fixedIp"] = args ? args.fixedIp : undefined; resourceInputs["instanceId"] = args ? args.instanceId : undefined; resourceInputs["ipv6BandwidthId"] = args ? args.ipv6BandwidthId : undefined; resourceInputs["ipv6Enable"] = args ? args.ipv6Enable : undefined; resourceInputs["networkId"] = args ? args.networkId : undefined; resourceInputs["portId"] = args ? args.portId : undefined; resourceInputs["region"] = args ? args.region : undefined; resourceInputs["securityGroupIds"] = args ? args.securityGroupIds : undefined; resourceInputs["sourceDestCheck"] = args ? args.sourceDestCheck : undefined; resourceInputs["fixedIpv6"] = undefined /*out*/; resourceInputs["mac"] = undefined /*out*/; } opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts); super(InterfaceAttach.__pulumiType, name, resourceInputs, opts); } } exports.InterfaceAttach = InterfaceAttach; /** @internal */ InterfaceAttach.__pulumiType = 'huaweicloud:Ecs/interfaceAttach:InterfaceAttach'; //# sourceMappingURL=interfaceAttach.js.map