@upcloud/pulumi-upcloud
Version:
A Pulumi package for creating and managing UpCloud resources.
104 lines • 4.34 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.ServerFirewallRules = void 0;
const pulumi = require("@pulumi/pulumi");
const utilities = require("./utilities");
/**
* Firewall rules are used to control network access of UpCloud servers. Each server has its own firewall rules and there should be only one `upcloud.ServerFirewallRules` resource per server.
* The firewall is enabled on public and utility network interfaces.
*
* ## Example Usage
*
* ```typescript
* import * as pulumi from "@pulumi/pulumi";
* import * as upcloud from "@upcloud/pulumi-upcloud";
*
* // The following example defines a server and then links the server to a single firewall rule.
* // The list of firewall rules applied to the server can be expanded by providing additional server_firewall_rules blocks.
* const example = new upcloud.Server("example", {
* firewall: true,
* hostname: "terraform.example.tld",
* zone: "de-fra1",
* plan: "1xCPU-1GB",
* template: {
* storage: "Ubuntu Server 20.04 LTS (Focal Fossa)",
* size: 25,
* },
* networkInterfaces: [{
* type: "utility",
* }],
* });
* const exampleServerFirewallRules = new upcloud.ServerFirewallRules("example", {
* serverId: example.id,
* firewallRules: [{
* action: "accept",
* comment: "Allow SSH from this network",
* destinationPortEnd: "22",
* destinationPortStart: "22",
* direction: "in",
* family: "IPv4",
* protocol: "tcp",
* sourceAddressEnd: "192.168.1.255",
* sourceAddressStart: "192.168.1.1",
* }],
* });
* ```
*
* ## Import
*
* ```sh
* $ pulumi import upcloud:index/serverFirewallRules:ServerFirewallRules my_example_rules 049d7ca2-757e-4fb1-a833-f87ee056547a
* ```
*/
class ServerFirewallRules extends pulumi.CustomResource {
/**
* Get an existing ServerFirewallRules 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 ServerFirewallRules(name, state, Object.assign(Object.assign({}, opts), { id: id }));
}
/**
* Returns true if the given object is an instance of ServerFirewallRules. 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'] === ServerFirewallRules.__pulumiType;
}
constructor(name, argsOrState, opts) {
let resourceInputs = {};
opts = opts || {};
if (opts.id) {
const state = argsOrState;
resourceInputs["firewallRules"] = state ? state.firewallRules : undefined;
resourceInputs["serverId"] = state ? state.serverId : undefined;
}
else {
const args = argsOrState;
if ((!args || args.firewallRules === undefined) && !opts.urn) {
throw new Error("Missing required property 'firewallRules'");
}
if ((!args || args.serverId === undefined) && !opts.urn) {
throw new Error("Missing required property 'serverId'");
}
resourceInputs["firewallRules"] = args ? args.firewallRules : undefined;
resourceInputs["serverId"] = args ? args.serverId : undefined;
}
opts = pulumi.mergeOptions(utilities.resourceOptsDefaults(), opts);
super(ServerFirewallRules.__pulumiType, name, resourceInputs, opts);
}
}
exports.ServerFirewallRules = ServerFirewallRules;
/** @internal */
ServerFirewallRules.__pulumiType = 'upcloud:index/serverFirewallRules:ServerFirewallRules';
//# sourceMappingURL=serverFirewallRules.js.map