当私有网络内有多台云服务器实例需要访问公网时,为了节省公网IP且避免在公网上直接暴露云服务器IP,您可以使用公网NAT网关的SNAT规则,安全、便捷、高效地访问公网。SNAT规则支持私有网络、子网、云服务器、自定义网段等四种粒度,您可根据业务需求灵活配置。
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as volcenginecc from "@volcengine/pulumi-volcenginecc";
const natGatewaySnatentryDemo = new volcenginecc.natgateway.Snatentry("NatGatewaySnatentryDemo", {
natGatewayId: "ngw-2pc28yhdpbx8g227qo1xxxxx",
eipId: "eip-iivdtssgbdog74o8cuxxxxx,eip-btbv1pk36g3k5h0b2vxxxxx",
snatEntryName: "私有网络",
sourceCidr: "0.0.0.0/0",
});
import pulumi
import pulumi_volcenginecc as volcenginecc
nat_gateway_snatentry_demo = volcenginecc.natgateway.Snatentry("NatGatewaySnatentryDemo",
nat_gateway_id="ngw-2pc28yhdpbx8g227qo1xxxxx",
eip_id="eip-iivdtssgbdog74o8cuxxxxx,eip-btbv1pk36g3k5h0b2vxxxxx",
snat_entry_name="私有网络",
source_cidr="0.0.0.0/0")
package main
import (
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/volcengine/pulumi-volcenginecc/sdk/go/volcenginecc/natgateway"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_, err := natgateway.NewSnatentry(ctx, "NatGatewaySnatentryDemo", &natgateway.SnatentryArgs{
NatGatewayId: pulumi.String("ngw-2pc28yhdpbx8g227qo1xxxxx"),
EipId: pulumi.String("eip-iivdtssgbdog74o8cuxxxxx,eip-btbv1pk36g3k5h0b2vxxxxx"),
SnatEntryName: pulumi.String("私有网络"),
SourceCidr: pulumi.String("0.0.0.0/0"),
})
if err != nil {
return err
}
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Volcenginecc = Volcengine.Pulumi.Volcenginecc;
return await Deployment.RunAsync(() =>
{
var natGatewaySnatentryDemo = new Volcenginecc.Natgateway.Snatentry("NatGatewaySnatentryDemo", new()
{
NatGatewayId = "ngw-2pc28yhdpbx8g227qo1xxxxx",
EipId = "eip-iivdtssgbdog74o8cuxxxxx,eip-btbv1pk36g3k5h0b2vxxxxx",
SnatEntryName = "私有网络",
SourceCidr = "0.0.0.0/0",
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.volcengine.volcenginecc.natgateway.Snatentry;
import com.volcengine.volcenginecc.natgateway.SnatentryArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
var natGatewaySnatentryDemo = new Snatentry("natGatewaySnatentryDemo", SnatentryArgs.builder()
.natGatewayId("ngw-2pc28yhdpbx8g227qo1xxxxx")
.eipId("eip-iivdtssgbdog74o8cuxxxxx,eip-btbv1pk36g3k5h0b2vxxxxx")
.snatEntryName("私有网络")
.sourceCidr("0.0.0.0/0")
.build());
}
}
resources:
natGatewaySnatentryDemo:
type: volcenginecc:natgateway:Snatentry
name: NatGatewaySnatentryDemo
properties:
natGatewayId: ngw-2pc28yhdpbx8g227qo1xxxxx
eipId: eip-iivdtssgbdog74o8cuxxxxx,eip-btbv1pk36g3k5h0b2vxxxxx
snatEntryName: 私有网络
sourceCidr: 0.0.0.0/0
Create Snatentry Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new Snatentry(name: string, args: SnatentryArgs, opts?: CustomResourceOptions);@overload
def Snatentry(resource_name: str,
args: SnatentryArgs,
opts: Optional[ResourceOptions] = None)
@overload
def Snatentry(resource_name: str,
opts: Optional[ResourceOptions] = None,
nat_gateway_id: Optional[str] = None,
eip_id: Optional[str] = None,
nat_ip_id: Optional[str] = None,
snat_entry_name: Optional[str] = None,
source_cidr: Optional[str] = None,
subnet_id: Optional[str] = None)func NewSnatentry(ctx *Context, name string, args SnatentryArgs, opts ...ResourceOption) (*Snatentry, error)public Snatentry(string name, SnatentryArgs args, CustomResourceOptions? opts = null)
public Snatentry(String name, SnatentryArgs args)
public Snatentry(String name, SnatentryArgs args, CustomResourceOptions options)
type: volcenginecc:natgateway:Snatentry
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
Parameters
- name string
- The unique name of the resource.
- args SnatentryArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args SnatentryArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args SnatentryArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args SnatentryArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args SnatentryArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
Constructor example
The following reference example uses placeholder values for all input properties.
var snatentryResource = new Volcenginecc.Natgateway.Snatentry("snatentryResource", new()
{
NatGatewayId = "string",
EipId = "string",
NatIpId = "string",
SnatEntryName = "string",
SourceCidr = "string",
SubnetId = "string",
});
example, err := natgateway.NewSnatentry(ctx, "snatentryResource", &natgateway.SnatentryArgs{
NatGatewayId: pulumi.String("string"),
EipId: pulumi.String("string"),
NatIpId: pulumi.String("string"),
SnatEntryName: pulumi.String("string"),
SourceCidr: pulumi.String("string"),
SubnetId: pulumi.String("string"),
})
var snatentryResource = new Snatentry("snatentryResource", SnatentryArgs.builder()
.natGatewayId("string")
.eipId("string")
.natIpId("string")
.snatEntryName("string")
.sourceCidr("string")
.subnetId("string")
.build());
snatentry_resource = volcenginecc.natgateway.Snatentry("snatentryResource",
nat_gateway_id="string",
eip_id="string",
nat_ip_id="string",
snat_entry_name="string",
source_cidr="string",
subnet_id="string")
const snatentryResource = new volcenginecc.natgateway.Snatentry("snatentryResource", {
natGatewayId: "string",
eipId: "string",
natIpId: "string",
snatEntryName: "string",
sourceCidr: "string",
subnetId: "string",
});
type: volcenginecc:natgateway:Snatentry
properties:
eipId: string
natGatewayId: string
natIpId: string
snatEntryName: string
sourceCidr: string
subnetId: string
Snatentry Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.
The Snatentry resource accepts the following input properties:
- Nat
Gateway stringId - SNAT规则所属NAT网关的ID。
- Eip
Id string - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- Nat
Ip stringId - 私网NAT网关的中转IP的ID。
- Snat
Entry stringName - SNAT规则的名称。
- Source
Cidr string - SNAT规则对应的网段。
- Subnet
Id string - SNAT规则关联子网的ID。
- Nat
Gateway stringId - SNAT规则所属NAT网关的ID。
- Eip
Id string - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- Nat
Ip stringId - 私网NAT网关的中转IP的ID。
- Snat
Entry stringName - SNAT规则的名称。
- Source
Cidr string - SNAT规则对应的网段。
- Subnet
Id string - SNAT规则关联子网的ID。
- nat
Gateway StringId - SNAT规则所属NAT网关的ID。
- eip
Id String - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- nat
Ip StringId - 私网NAT网关的中转IP的ID。
- snat
Entry StringName - SNAT规则的名称。
- source
Cidr String - SNAT规则对应的网段。
- subnet
Id String - SNAT规则关联子网的ID。
- nat
Gateway stringId - SNAT规则所属NAT网关的ID。
- eip
Id string - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- nat
Ip stringId - 私网NAT网关的中转IP的ID。
- snat
Entry stringName - SNAT规则的名称。
- source
Cidr string - SNAT规则对应的网段。
- subnet
Id string - SNAT规则关联子网的ID。
- nat_
gateway_ strid - SNAT规则所属NAT网关的ID。
- eip_
id str - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- nat_
ip_ strid - 私网NAT网关的中转IP的ID。
- snat_
entry_ strname - SNAT规则的名称。
- source_
cidr str - SNAT规则对应的网段。
- subnet_
id str - SNAT规则关联子网的ID。
- nat
Gateway StringId - SNAT规则所属NAT网关的ID。
- eip
Id String - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- nat
Ip StringId - 私网NAT网关的中转IP的ID。
- snat
Entry StringName - SNAT规则的名称。
- source
Cidr String - SNAT规则对应的网段。
- subnet
Id String - SNAT规则关联子网的ID。
Outputs
All input properties are implicitly available as output properties. Additionally, the Snatentry resource produces the following output properties:
- Eip
Address string - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- Id string
- The provider-assigned unique ID for this managed resource.
- Snat
Entry stringId - SNAT规则的ID。
- Status string
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- Eip
Address string - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- Id string
- The provider-assigned unique ID for this managed resource.
- Snat
Entry stringId - SNAT规则的ID。
- Status string
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- eip
Address String - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- id String
- The provider-assigned unique ID for this managed resource.
- snat
Entry StringId - SNAT规则的ID。
- status String
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- eip
Address string - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- id string
- The provider-assigned unique ID for this managed resource.
- snat
Entry stringId - SNAT规则的ID。
- status string
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- eip_
address str - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- id str
- The provider-assigned unique ID for this managed resource.
- snat_
entry_ strid - SNAT规则的ID。
- status str
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- eip
Address String - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- id String
- The provider-assigned unique ID for this managed resource.
- snat
Entry StringId - SNAT规则的ID。
- status String
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
Look up Existing Snatentry Resource
Get an existing Snatentry resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: SnatentryState, opts?: CustomResourceOptions): Snatentry@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
eip_address: Optional[str] = None,
eip_id: Optional[str] = None,
nat_gateway_id: Optional[str] = None,
nat_ip_id: Optional[str] = None,
snat_entry_id: Optional[str] = None,
snat_entry_name: Optional[str] = None,
source_cidr: Optional[str] = None,
status: Optional[str] = None,
subnet_id: Optional[str] = None) -> Snatentryfunc GetSnatentry(ctx *Context, name string, id IDInput, state *SnatentryState, opts ...ResourceOption) (*Snatentry, error)public static Snatentry Get(string name, Input<string> id, SnatentryState? state, CustomResourceOptions? opts = null)public static Snatentry get(String name, Output<String> id, SnatentryState state, CustomResourceOptions options)resources: _: type: volcenginecc:natgateway:Snatentry get: id: ${id}- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Eip
Address string - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- Eip
Id string - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- Nat
Gateway stringId - SNAT规则所属NAT网关的ID。
- Nat
Ip stringId - 私网NAT网关的中转IP的ID。
- Snat
Entry stringId - SNAT规则的ID。
- Snat
Entry stringName - SNAT规则的名称。
- Source
Cidr string - SNAT规则对应的网段。
- Status string
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- Subnet
Id string - SNAT规则关联子网的ID。
- Eip
Address string - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- Eip
Id string - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- Nat
Gateway stringId - SNAT规则所属NAT网关的ID。
- Nat
Ip stringId - 私网NAT网关的中转IP的ID。
- Snat
Entry stringId - SNAT规则的ID。
- Snat
Entry stringName - SNAT规则的名称。
- Source
Cidr string - SNAT规则对应的网段。
- Status string
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- Subnet
Id string - SNAT规则关联子网的ID。
- eip
Address String - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- eip
Id String - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- nat
Gateway StringId - SNAT规则所属NAT网关的ID。
- nat
Ip StringId - 私网NAT网关的中转IP的ID。
- snat
Entry StringId - SNAT规则的ID。
- snat
Entry StringName - SNAT规则的名称。
- source
Cidr String - SNAT规则对应的网段。
- status String
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- subnet
Id String - SNAT规则关联子网的ID。
- eip
Address string - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- eip
Id string - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- nat
Gateway stringId - SNAT规则所属NAT网关的ID。
- nat
Ip stringId - 私网NAT网关的中转IP的ID。
- snat
Entry stringId - SNAT规则的ID。
- snat
Entry stringName - SNAT规则的名称。
- source
Cidr string - SNAT规则对应的网段。
- status string
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- subnet
Id string - SNAT规则关联子网的ID。
- eip_
address str - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- eip_
id str - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- nat_
gateway_ strid - SNAT规则所属NAT网关的ID。
- nat_
ip_ strid - 私网NAT网关的中转IP的ID。
- snat_
entry_ strid - SNAT规则的ID。
- snat_
entry_ strname - SNAT规则的名称。
- source_
cidr str - SNAT规则对应的网段。
- status str
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- subnet_
id str - SNAT规则关联子网的ID。
- eip
Address String - SNAT规则关联的公网IP的IP地址。返回单个公网IP的IP地址。 返回多个公网IP的IP地址。
- eip
Id String - SNAT规则关联的公网IP的ID。返回单个公网IP的ID。 返回多个公网IP的ID。
- nat
Gateway StringId - SNAT规则所属NAT网关的ID。
- nat
Ip StringId - 私网NAT网关的中转IP的ID。
- snat
Entry StringId - SNAT规则的ID。
- snat
Entry StringName - SNAT规则的名称。
- source
Cidr String - SNAT规则对应的网段。
- status String
- SNAT规则的状态。Creating:创建中。Deleting:删除中。Available:可用。
- subnet
Id String - SNAT规则关联子网的ID。
Import
$ pulumi import volcenginecc:natgateway/snatentry:Snatentry example "snat_entry_id"
To learn more about importing existing cloud resources, see Importing resources.
Package Details
- Repository
- volcenginecc volcengine/pulumi-volcenginecc
- License
- MPL-2.0
- Notes
- This Pulumi package is based on the
volcengineccTerraform Provider.
