@pulumi/gcp
Version:
A Pulumi package for creating and managing Google Cloud Platform resources.
207 lines • 8.4 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! ***
Object.defineProperty(exports, "__esModule", { value: true });
exports.NetworkAttachment = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("../utilities");
/**
* A network attachment is a resource that lets a producer Virtual Private Cloud (VPC) network initiate connections to a consumer VPC network through a Private Service Connect interface.
*
* To get more information about NetworkAttachment, see:
*
* * [API documentation](https://cloud.google.com/compute/docs/reference/rest/v1/networkAttachments)
* * How-to Guides
* * [Official Documentation](https://cloud.google.com/vpc/docs/about-network-attachments)
*
* ## Example Usage
*
* ### Network Attachment Basic
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const defaultNetwork = new gcp.compute.Network("default", {
* name: "basic-network",
* autoCreateSubnetworks: false,
* });
* const defaultSubnetwork = new gcp.compute.Subnetwork("default", {
* name: "basic-subnetwork",
* region: "us-central1",
* network: defaultNetwork.id,
* ipCidrRange: "10.0.0.0/16",
* });
* const rejectedProducerProject = new gcp.organizations.Project("rejected_producer_project", {
* projectId: "prj-rejected",
* name: "prj-rejected",
* orgId: "123456789",
* billingAccount: "000000-0000000-0000000-000000",
* deletionPolicy: "DELETE",
* });
* const acceptedProducerProject = new gcp.organizations.Project("accepted_producer_project", {
* projectId: "prj-accepted",
* name: "prj-accepted",
* orgId: "123456789",
* billingAccount: "000000-0000000-0000000-000000",
* deletionPolicy: "DELETE",
* });
* const _default = new gcp.compute.NetworkAttachment("default", {
* name: "basic-network-attachment",
* region: "us-central1",
* description: "basic network attachment description",
* connectionPreference: "ACCEPT_MANUAL",
* subnetworks: [defaultSubnetwork.selfLink],
* producerAcceptLists: [acceptedProducerProject.projectId],
* producerRejectLists: [rejectedProducerProject.projectId],
* });
* ```
* ### Network Attachment Instance Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as gcp from "@pulumi/gcp";
*
* const _default = new gcp.compute.Network("default", {
* name: "basic-network",
* autoCreateSubnetworks: false,
* });
* const defaultSubnetwork = new gcp.compute.Subnetwork("default", {
* name: "basic-subnetwork",
* region: "us-central1",
* network: _default.id,
* ipCidrRange: "10.0.0.0/16",
* });
* const defaultNetworkAttachment = new gcp.compute.NetworkAttachment("default", {
* name: "basic-network-attachment",
* region: "us-central1",
* description: "my basic network attachment",
* subnetworks: [defaultSubnetwork.id],
* connectionPreference: "ACCEPT_AUTOMATIC",
* });
* const defaultInstance = new gcp.compute.Instance("default", {
* name: "basic-instance",
* zone: "us-central1-a",
* machineType: "e2-micro",
* bootDisk: {
* initializeParams: {
* image: "debian-cloud/debian-11",
* },
* },
* networkInterfaces: [
* {
* network: "default",
* },
* {
* networkAttachment: defaultNetworkAttachment.selfLink,
* },
* ],
* });
* ```
*
* ## Import
*
* NetworkAttachment can be imported using any of these accepted formats:
*
* * `projects/{{project}}/regions/{{region}}/networkAttachments/{{name}}`
*
* * `{{project}}/{{region}}/{{name}}`
*
* * `{{region}}/{{name}}`
*
* * `{{name}}`
*
* When using the `pulumi import` command, NetworkAttachment can be imported using one of the formats above. For example:
*
* ```sh
* $ pulumi import gcp:compute/networkAttachment:NetworkAttachment default projects/{{project}}/regions/{{region}}/networkAttachments/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/networkAttachment:NetworkAttachment default {{project}}/{{region}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/networkAttachment:NetworkAttachment default {{region}}/{{name}}
* ```
*
* ```sh
* $ pulumi import gcp:compute/networkAttachment:NetworkAttachment default {{name}}
* ```
*/
class NetworkAttachment extends pulumi.CustomResource {
/**
* Get an existing NetworkAttachment 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 NetworkAttachment(name, state, { ...opts, id: id });
}
/**
* Returns true if the given object is an instance of NetworkAttachment. 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'] === NetworkAttachment.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["connectionEndpoints"] = state?.connectionEndpoints;
resourceInputs["connectionPreference"] = state?.connectionPreference;
resourceInputs["creationTimestamp"] = state?.creationTimestamp;
resourceInputs["description"] = state?.description;
resourceInputs["fingerprint"] = state?.fingerprint;
resourceInputs["kind"] = state?.kind;
resourceInputs["name"] = state?.name;
resourceInputs["network"] = state?.network;
resourceInputs["producerAcceptLists"] = state?.producerAcceptLists;
resourceInputs["producerRejectLists"] = state?.producerRejectLists;
resourceInputs["project"] = state?.project;
resourceInputs["region"] = state?.region;
resourceInputs["selfLink"] = state?.selfLink;
resourceInputs["selfLinkWithId"] = state?.selfLinkWithId;
resourceInputs["subnetworks"] = state?.subnetworks;
}
else {
const args = argsOrState;
if (args?.connectionPreference === undefined && !opts.urn) {
throw new Error("Missing required property 'connectionPreference'");
}
if (args?.subnetworks === undefined && !opts.urn) {
throw new Error("Missing required property 'subnetworks'");
}
resourceInputs["connectionPreference"] = args?.connectionPreference;
resourceInputs["description"] = args?.description;
resourceInputs["name"] = args?.name;
resourceInputs["producerAcceptLists"] = args?.producerAcceptLists;
resourceInputs["producerRejectLists"] = args?.producerRejectLists;
resourceInputs["project"] = args?.project;
resourceInputs["region"] = args?.region;
resourceInputs["subnetworks"] = args?.subnetworks;
resourceInputs["connectionEndpoints"] = undefined /*out*/;
resourceInputs["creationTimestamp"] = undefined /*out*/;
resourceInputs["fingerprint"] = undefined /*out*/;
resourceInputs["kind"] = undefined /*out*/;
resourceInputs["network"] = undefined /*out*/;
resourceInputs["selfLink"] = undefined /*out*/;
resourceInputs["selfLinkWithId"] = undefined /*out*/;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(NetworkAttachment.__pulumiType, name, resourceInputs, opts);
}
}
exports.NetworkAttachment = NetworkAttachment;
/** @internal */
NetworkAttachment.__pulumiType = 'gcp:compute/networkAttachment:NetworkAttachment';
//# sourceMappingURL=networkAttachment.js.map
;