Alibaba Cloud v3.62.1 published on Monday, Sep 16, 2024 by Pulumi
alicloud.vpc.getSnatEntries
Explore with Pulumi AI
This data source provides a list of Snat Entries owned by an Alibaba Cloud account.
NOTE: Available in 1.37.0+.
Example Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "snat-entry-example-name";
const default = alicloud.getZones({
availableResourceCreation: "VSwitch",
});
const fooNetwork = new alicloud.vpc.Network("foo", {
name: name,
cidrBlock: "172.16.0.0/12",
});
const fooSwitch = new alicloud.vpc.Switch("foo", {
vpcId: fooNetwork.id,
cidrBlock: "172.16.0.0/21",
availabilityZone: _default.then(_default => _default.zones?.[0]?.id),
vswitchName: name,
});
const fooNatGateway = new alicloud.vpc.NatGateway("foo", {
vpcId: fooNetwork.id,
specification: "Small",
name: name,
});
const fooEipAddress = new alicloud.ecs.EipAddress("foo", {addressName: name});
const fooEipAssociation = new alicloud.ecs.EipAssociation("foo", {
allocationId: fooEipAddress.id,
instanceId: fooNatGateway.id,
});
const fooSnatEntry = new alicloud.vpc.SnatEntry("foo", {
snatTableId: fooNatGateway.snatTableIds,
sourceVswitchId: fooSwitch.id,
snatIp: fooEipAddress.ipAddress,
});
const foo = alicloud.vpc.getSnatEntriesOutput({
snatTableId: fooSnatEntry.snatTableId,
});
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "snat-entry-example-name"
default = alicloud.get_zones(available_resource_creation="VSwitch")
foo_network = alicloud.vpc.Network("foo",
name=name,
cidr_block="172.16.0.0/12")
foo_switch = alicloud.vpc.Switch("foo",
vpc_id=foo_network.id,
cidr_block="172.16.0.0/21",
availability_zone=default.zones[0].id,
vswitch_name=name)
foo_nat_gateway = alicloud.vpc.NatGateway("foo",
vpc_id=foo_network.id,
specification="Small",
name=name)
foo_eip_address = alicloud.ecs.EipAddress("foo", address_name=name)
foo_eip_association = alicloud.ecs.EipAssociation("foo",
allocation_id=foo_eip_address.id,
instance_id=foo_nat_gateway.id)
foo_snat_entry = alicloud.vpc.SnatEntry("foo",
snat_table_id=foo_nat_gateway.snat_table_ids,
source_vswitch_id=foo_switch.id,
snat_ip=foo_eip_address.ip_address)
foo = alicloud.vpc.get_snat_entries_output(snat_table_id=foo_snat_entry.snat_table_id)
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/ecs"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
name := "snat-entry-example-name"
if param := cfg.Get("name"); param != "" {
name = param
}
_default, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
AvailableResourceCreation: pulumi.StringRef("VSwitch"),
}, nil)
if err != nil {
return err
}
fooNetwork, err := vpc.NewNetwork(ctx, "foo", &vpc.NetworkArgs{
Name: pulumi.String(name),
CidrBlock: pulumi.String("172.16.0.0/12"),
})
if err != nil {
return err
}
fooSwitch, err := vpc.NewSwitch(ctx, "foo", &vpc.SwitchArgs{
VpcId: fooNetwork.ID(),
CidrBlock: pulumi.String("172.16.0.0/21"),
AvailabilityZone: pulumi.String(_default.Zones[0].Id),
VswitchName: pulumi.String(name),
})
if err != nil {
return err
}
fooNatGateway, err := vpc.NewNatGateway(ctx, "foo", &vpc.NatGatewayArgs{
VpcId: fooNetwork.ID(),
Specification: pulumi.String("Small"),
Name: pulumi.String(name),
})
if err != nil {
return err
}
fooEipAddress, err := ecs.NewEipAddress(ctx, "foo", &ecs.EipAddressArgs{
AddressName: pulumi.String(name),
})
if err != nil {
return err
}
_, err = ecs.NewEipAssociation(ctx, "foo", &ecs.EipAssociationArgs{
AllocationId: fooEipAddress.ID(),
InstanceId: fooNatGateway.ID(),
})
if err != nil {
return err
}
fooSnatEntry, err := vpc.NewSnatEntry(ctx, "foo", &vpc.SnatEntryArgs{
SnatTableId: fooNatGateway.SnatTableIds,
SourceVswitchId: fooSwitch.ID(),
SnatIp: fooEipAddress.IpAddress,
})
if err != nil {
return err
}
_ = vpc.GetSnatEntriesOutput(ctx, vpc.GetSnatEntriesOutputArgs{
SnatTableId: fooSnatEntry.SnatTableId,
}, nil)
return nil
})
}
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var name = config.Get("name") ?? "snat-entry-example-name";
var @default = AliCloud.GetZones.Invoke(new()
{
AvailableResourceCreation = "VSwitch",
});
var fooNetwork = new AliCloud.Vpc.Network("foo", new()
{
Name = name,
CidrBlock = "172.16.0.0/12",
});
var fooSwitch = new AliCloud.Vpc.Switch("foo", new()
{
VpcId = fooNetwork.Id,
CidrBlock = "172.16.0.0/21",
AvailabilityZone = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
VswitchName = name,
});
var fooNatGateway = new AliCloud.Vpc.NatGateway("foo", new()
{
VpcId = fooNetwork.Id,
Specification = "Small",
Name = name,
});
var fooEipAddress = new AliCloud.Ecs.EipAddress("foo", new()
{
AddressName = name,
});
var fooEipAssociation = new AliCloud.Ecs.EipAssociation("foo", new()
{
AllocationId = fooEipAddress.Id,
InstanceId = fooNatGateway.Id,
});
var fooSnatEntry = new AliCloud.Vpc.SnatEntry("foo", new()
{
SnatTableId = fooNatGateway.SnatTableIds,
SourceVswitchId = fooSwitch.Id,
SnatIp = fooEipAddress.IpAddress,
});
var foo = AliCloud.Vpc.GetSnatEntries.Invoke(new()
{
SnatTableId = fooSnatEntry.SnatTableId,
});
});
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.inputs.GetZonesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.vpc.NatGateway;
import com.pulumi.alicloud.vpc.NatGatewayArgs;
import com.pulumi.alicloud.ecs.EipAddress;
import com.pulumi.alicloud.ecs.EipAddressArgs;
import com.pulumi.alicloud.ecs.EipAssociation;
import com.pulumi.alicloud.ecs.EipAssociationArgs;
import com.pulumi.alicloud.vpc.SnatEntry;
import com.pulumi.alicloud.vpc.SnatEntryArgs;
import com.pulumi.alicloud.vpc.VpcFunctions;
import com.pulumi.alicloud.vpc.inputs.GetSnatEntriesArgs;
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) {
final var config = ctx.config();
final var name = config.get("name").orElse("snat-entry-example-name");
final var default = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableResourceCreation("VSwitch")
.build());
var fooNetwork = new Network("fooNetwork", NetworkArgs.builder()
.name(name)
.cidrBlock("172.16.0.0/12")
.build());
var fooSwitch = new Switch("fooSwitch", SwitchArgs.builder()
.vpcId(fooNetwork.id())
.cidrBlock("172.16.0.0/21")
.availabilityZone(default_.zones()[0].id())
.vswitchName(name)
.build());
var fooNatGateway = new NatGateway("fooNatGateway", NatGatewayArgs.builder()
.vpcId(fooNetwork.id())
.specification("Small")
.name(name)
.build());
var fooEipAddress = new EipAddress("fooEipAddress", EipAddressArgs.builder()
.addressName(name)
.build());
var fooEipAssociation = new EipAssociation("fooEipAssociation", EipAssociationArgs.builder()
.allocationId(fooEipAddress.id())
.instanceId(fooNatGateway.id())
.build());
var fooSnatEntry = new SnatEntry("fooSnatEntry", SnatEntryArgs.builder()
.snatTableId(fooNatGateway.snatTableIds())
.sourceVswitchId(fooSwitch.id())
.snatIp(fooEipAddress.ipAddress())
.build());
final var foo = VpcFunctions.getSnatEntries(GetSnatEntriesArgs.builder()
.snatTableId(fooSnatEntry.snatTableId())
.build());
}
}
configuration:
name:
type: string
default: snat-entry-example-name
resources:
fooNetwork:
type: alicloud:vpc:Network
name: foo
properties:
name: ${name}
cidrBlock: 172.16.0.0/12
fooSwitch:
type: alicloud:vpc:Switch
name: foo
properties:
vpcId: ${fooNetwork.id}
cidrBlock: 172.16.0.0/21
availabilityZone: ${default.zones[0].id}
vswitchName: ${name}
fooNatGateway:
type: alicloud:vpc:NatGateway
name: foo
properties:
vpcId: ${fooNetwork.id}
specification: Small
name: ${name}
fooEipAddress:
type: alicloud:ecs:EipAddress
name: foo
properties:
addressName: ${name}
fooEipAssociation:
type: alicloud:ecs:EipAssociation
name: foo
properties:
allocationId: ${fooEipAddress.id}
instanceId: ${fooNatGateway.id}
fooSnatEntry:
type: alicloud:vpc:SnatEntry
name: foo
properties:
snatTableId: ${fooNatGateway.snatTableIds}
sourceVswitchId: ${fooSwitch.id}
snatIp: ${fooEipAddress.ipAddress}
variables:
default:
fn::invoke:
Function: alicloud:getZones
Arguments:
availableResourceCreation: VSwitch
foo:
fn::invoke:
Function: alicloud:vpc:getSnatEntries
Arguments:
snatTableId: ${fooSnatEntry.snatTableId}
Using getSnatEntries
Two invocation forms are available. The direct form accepts plain arguments and either blocks until the result value is available, or returns a Promise-wrapped result. The output form accepts Input-wrapped arguments and returns an Output-wrapped result.
function getSnatEntries(args: GetSnatEntriesArgs, opts?: InvokeOptions): Promise<GetSnatEntriesResult>
function getSnatEntriesOutput(args: GetSnatEntriesOutputArgs, opts?: InvokeOptions): Output<GetSnatEntriesResult>
def get_snat_entries(ids: Optional[Sequence[str]] = None,
name_regex: Optional[str] = None,
output_file: Optional[str] = None,
snat_entry_name: Optional[str] = None,
snat_ip: Optional[str] = None,
snat_table_id: Optional[str] = None,
source_cidr: Optional[str] = None,
source_vswitch_id: Optional[str] = None,
status: Optional[str] = None,
opts: Optional[InvokeOptions] = None) -> GetSnatEntriesResult
def get_snat_entries_output(ids: Optional[pulumi.Input[Sequence[pulumi.Input[str]]]] = None,
name_regex: Optional[pulumi.Input[str]] = None,
output_file: Optional[pulumi.Input[str]] = None,
snat_entry_name: Optional[pulumi.Input[str]] = None,
snat_ip: Optional[pulumi.Input[str]] = None,
snat_table_id: Optional[pulumi.Input[str]] = None,
source_cidr: Optional[pulumi.Input[str]] = None,
source_vswitch_id: Optional[pulumi.Input[str]] = None,
status: Optional[pulumi.Input[str]] = None,
opts: Optional[InvokeOptions] = None) -> Output[GetSnatEntriesResult]
func GetSnatEntries(ctx *Context, args *GetSnatEntriesArgs, opts ...InvokeOption) (*GetSnatEntriesResult, error)
func GetSnatEntriesOutput(ctx *Context, args *GetSnatEntriesOutputArgs, opts ...InvokeOption) GetSnatEntriesResultOutput
> Note: This function is named GetSnatEntries
in the Go SDK.
public static class GetSnatEntries
{
public static Task<GetSnatEntriesResult> InvokeAsync(GetSnatEntriesArgs args, InvokeOptions? opts = null)
public static Output<GetSnatEntriesResult> Invoke(GetSnatEntriesInvokeArgs args, InvokeOptions? opts = null)
}
public static CompletableFuture<GetSnatEntriesResult> getSnatEntries(GetSnatEntriesArgs args, InvokeOptions options)
// Output-based functions aren't available in Java yet
fn::invoke:
function: alicloud:vpc/getSnatEntries:getSnatEntries
arguments:
# arguments dictionary
The following arguments are supported:
- Snat
Table stringId - The ID of the Snat table.
- Ids List<string>
- A list of Snat Entries IDs.
- Name
Regex string - A regex string to filter results by the resource name.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - Snat
Entry stringName - The name of snat entry.
- Snat
Ip string - The public IP of the Snat Entry.
- Source
Cidr string - The source CIDR block of the Snat Entry.
- Source
Vswitch stringId - The source vswitch ID.
- Status string
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- Snat
Table stringId - The ID of the Snat table.
- Ids []string
- A list of Snat Entries IDs.
- Name
Regex string - A regex string to filter results by the resource name.
- Output
File string - File name where to save data source results (after running
pulumi preview
). - Snat
Entry stringName - The name of snat entry.
- Snat
Ip string - The public IP of the Snat Entry.
- Source
Cidr string - The source CIDR block of the Snat Entry.
- Source
Vswitch stringId - The source vswitch ID.
- Status string
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- snat
Table StringId - The ID of the Snat table.
- ids List<String>
- A list of Snat Entries IDs.
- name
Regex String - A regex string to filter results by the resource name.
- output
File String - File name where to save data source results (after running
pulumi preview
). - snat
Entry StringName - The name of snat entry.
- snat
Ip String - The public IP of the Snat Entry.
- source
Cidr String - The source CIDR block of the Snat Entry.
- source
Vswitch StringId - The source vswitch ID.
- status String
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- snat
Table stringId - The ID of the Snat table.
- ids string[]
- A list of Snat Entries IDs.
- name
Regex string - A regex string to filter results by the resource name.
- output
File string - File name where to save data source results (after running
pulumi preview
). - snat
Entry stringName - The name of snat entry.
- snat
Ip string - The public IP of the Snat Entry.
- source
Cidr string - The source CIDR block of the Snat Entry.
- source
Vswitch stringId - The source vswitch ID.
- status string
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- snat_
table_ strid - The ID of the Snat table.
- ids Sequence[str]
- A list of Snat Entries IDs.
- name_
regex str - A regex string to filter results by the resource name.
- output_
file str - File name where to save data source results (after running
pulumi preview
). - snat_
entry_ strname - The name of snat entry.
- snat_
ip str - The public IP of the Snat Entry.
- source_
cidr str - The source CIDR block of the Snat Entry.
- source_
vswitch_ strid - The source vswitch ID.
- status str
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- snat
Table StringId - The ID of the Snat table.
- ids List<String>
- A list of Snat Entries IDs.
- name
Regex String - A regex string to filter results by the resource name.
- output
File String - File name where to save data source results (after running
pulumi preview
). - snat
Entry StringName - The name of snat entry.
- snat
Ip String - The public IP of the Snat Entry.
- source
Cidr String - The source CIDR block of the Snat Entry.
- source
Vswitch StringId - The source vswitch ID.
- status String
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
getSnatEntries Result
The following output properties are available:
- Entries
List<Pulumi.
Ali Cloud. Vpc. Outputs. Get Snat Entries Entry> - A list of Snat Entries. Each element contains the following attributes:
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids List<string>
- (Optional) A list of Snat Entries IDs.
- Names List<string>
- Snat
Table stringId - Name
Regex string - Output
File string - Snat
Entry stringName - The name of snat entry.
- Snat
Ip string - The public IP of the Snat Entry.
- Source
Cidr string - The source CIDR block of the Snat Entry.
- Source
Vswitch stringId - The source vswitch ID.
- Status string
- The status of the Snat Entry.
- Entries
[]Get
Snat Entries Entry - A list of Snat Entries. Each element contains the following attributes:
- Id string
- The provider-assigned unique ID for this managed resource.
- Ids []string
- (Optional) A list of Snat Entries IDs.
- Names []string
- Snat
Table stringId - Name
Regex string - Output
File string - Snat
Entry stringName - The name of snat entry.
- Snat
Ip string - The public IP of the Snat Entry.
- Source
Cidr string - The source CIDR block of the Snat Entry.
- Source
Vswitch stringId - The source vswitch ID.
- Status string
- The status of the Snat Entry.
- entries
List<Get
Snat Entries Entry> - A list of Snat Entries. Each element contains the following attributes:
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- (Optional) A list of Snat Entries IDs.
- names List<String>
- snat
Table StringId - name
Regex String - output
File String - snat
Entry StringName - The name of snat entry.
- snat
Ip String - The public IP of the Snat Entry.
- source
Cidr String - The source CIDR block of the Snat Entry.
- source
Vswitch StringId - The source vswitch ID.
- status String
- The status of the Snat Entry.
- entries
Get
Snat Entries Entry[] - A list of Snat Entries. Each element contains the following attributes:
- id string
- The provider-assigned unique ID for this managed resource.
- ids string[]
- (Optional) A list of Snat Entries IDs.
- names string[]
- snat
Table stringId - name
Regex string - output
File string - snat
Entry stringName - The name of snat entry.
- snat
Ip string - The public IP of the Snat Entry.
- source
Cidr string - The source CIDR block of the Snat Entry.
- source
Vswitch stringId - The source vswitch ID.
- status string
- The status of the Snat Entry.
- entries
Sequence[Get
Snat Entries Entry] - A list of Snat Entries. Each element contains the following attributes:
- id str
- The provider-assigned unique ID for this managed resource.
- ids Sequence[str]
- (Optional) A list of Snat Entries IDs.
- names Sequence[str]
- snat_
table_ strid - name_
regex str - output_
file str - snat_
entry_ strname - The name of snat entry.
- snat_
ip str - The public IP of the Snat Entry.
- source_
cidr str - The source CIDR block of the Snat Entry.
- source_
vswitch_ strid - The source vswitch ID.
- status str
- The status of the Snat Entry.
- entries List<Property Map>
- A list of Snat Entries. Each element contains the following attributes:
- id String
- The provider-assigned unique ID for this managed resource.
- ids List<String>
- (Optional) A list of Snat Entries IDs.
- names List<String>
- snat
Table StringId - name
Regex String - output
File String - snat
Entry StringName - The name of snat entry.
- snat
Ip String - The public IP of the Snat Entry.
- source
Cidr String - The source CIDR block of the Snat Entry.
- source
Vswitch StringId - The source vswitch ID.
- status String
- The status of the Snat Entry.
Supporting Types
GetSnatEntriesEntry
- Id string
- The ID of the Snat Entry.
- Snat
Entry stringId - The ID of snat entry.
- Snat
Entry stringName - The name of snat entry.
- Snat
Ip string - The public IP of the Snat Entry.
- Source
Cidr string - The source CIDR block of the Snat Entry.
- Source
Vswitch stringId - The source vswitch ID.
- Status string
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- Id string
- The ID of the Snat Entry.
- Snat
Entry stringId - The ID of snat entry.
- Snat
Entry stringName - The name of snat entry.
- Snat
Ip string - The public IP of the Snat Entry.
- Source
Cidr string - The source CIDR block of the Snat Entry.
- Source
Vswitch stringId - The source vswitch ID.
- Status string
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- id String
- The ID of the Snat Entry.
- snat
Entry StringId - The ID of snat entry.
- snat
Entry StringName - The name of snat entry.
- snat
Ip String - The public IP of the Snat Entry.
- source
Cidr String - The source CIDR block of the Snat Entry.
- source
Vswitch StringId - The source vswitch ID.
- status String
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- id string
- The ID of the Snat Entry.
- snat
Entry stringId - The ID of snat entry.
- snat
Entry stringName - The name of snat entry.
- snat
Ip string - The public IP of the Snat Entry.
- source
Cidr string - The source CIDR block of the Snat Entry.
- source
Vswitch stringId - The source vswitch ID.
- status string
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- id str
- The ID of the Snat Entry.
- snat_
entry_ strid - The ID of snat entry.
- snat_
entry_ strname - The name of snat entry.
- snat_
ip str - The public IP of the Snat Entry.
- source_
cidr str - The source CIDR block of the Snat Entry.
- source_
vswitch_ strid - The source vswitch ID.
- status str
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
- id String
- The ID of the Snat Entry.
- snat
Entry StringId - The ID of snat entry.
- snat
Entry StringName - The name of snat entry.
- snat
Ip String - The public IP of the Snat Entry.
- source
Cidr String - The source CIDR block of the Snat Entry.
- source
Vswitch StringId - The source vswitch ID.
- status String
- The status of the Snat Entry. Valid values:
Available
,Deleting
andPending
.
Package Details
- Repository
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
- This Pulumi package is based on the
alicloud
Terraform Provider.