alicloud logo
Alibaba Cloud v3.34.0, Mar 17 23

alicloud.vpc.getSnatEntries

This data source provides a list of Snat Entries owned by an Alibaba Cloud account.

NOTE: Available in 1.37.0+.

Example Usage

using System.Collections.Generic;
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("fooNetwork", new()
    {
        CidrBlock = "172.16.0.0/12",
    });

    var fooSwitch = new AliCloud.Vpc.Switch("fooSwitch", 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("fooNatGateway", new()
    {
        VpcId = fooNetwork.Id,
        Specification = "Small",
    });

    var fooEipAddress = new AliCloud.Ecs.EipAddress("fooEipAddress", new()
    {
        AddressName = name,
    });

    var fooEipAssociation = new AliCloud.Ecs.EipAssociation("fooEipAssociation", new()
    {
        AllocationId = fooEipAddress.Id,
        InstanceId = fooNatGateway.Id,
    });

    var fooSnatEntry = new AliCloud.Vpc.SnatEntry("fooSnatEntry", new()
    {
        SnatTableId = fooNatGateway.SnatTableIds,
        SourceVswitchId = fooSwitch.Id,
        SnatIp = fooEipAddress.IpAddress,
    });

    var fooSnatEntries = AliCloud.Vpc.GetSnatEntries.Invoke(new()
    {
        SnatTableId = fooSnatEntry.SnatTableId,
    });

});
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, "fooNetwork", &vpc.NetworkArgs{
			CidrBlock: pulumi.String("172.16.0.0/12"),
		})
		if err != nil {
			return err
		}
		fooSwitch, err := vpc.NewSwitch(ctx, "fooSwitch", &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, "fooNatGateway", &vpc.NatGatewayArgs{
			VpcId:         fooNetwork.ID(),
			Specification: pulumi.String("Small"),
		})
		if err != nil {
			return err
		}
		fooEipAddress, err := ecs.NewEipAddress(ctx, "fooEipAddress", &ecs.EipAddressArgs{
			AddressName: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		_, err = ecs.NewEipAssociation(ctx, "fooEipAssociation", &ecs.EipAssociationArgs{
			AllocationId: fooEipAddress.ID(),
			InstanceId:   fooNatGateway.ID(),
		})
		if err != nil {
			return err
		}
		fooSnatEntry, err := vpc.NewSnatEntry(ctx, "fooSnatEntry", &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
	})
}
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()        
            .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")
            .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 fooSnatEntries = VpcFunctions.getSnatEntries(GetSnatEntriesArgs.builder()
            .snatTableId(fooSnatEntry.snatTableId())
            .build());

    }
}
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("fooNetwork", cidr_block="172.16.0.0/12")
foo_switch = alicloud.vpc.Switch("fooSwitch",
    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("fooNatGateway",
    vpc_id=foo_network.id,
    specification="Small")
foo_eip_address = alicloud.ecs.EipAddress("fooEipAddress", address_name=name)
foo_eip_association = alicloud.ecs.EipAssociation("fooEipAssociation",
    allocation_id=foo_eip_address.id,
    instance_id=foo_nat_gateway.id)
foo_snat_entry = alicloud.vpc.SnatEntry("fooSnatEntry",
    snat_table_id=foo_nat_gateway.snat_table_ids,
    source_vswitch_id=foo_switch.id,
    snat_ip=foo_eip_address.ip_address)
foo_snat_entries = alicloud.vpc.get_snat_entries_output(snat_table_id=foo_snat_entry.snat_table_id)
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("fooNetwork", {cidrBlock: "172.16.0.0/12"});
const fooSwitch = new alicloud.vpc.Switch("fooSwitch", {
    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("fooNatGateway", {
    vpcId: fooNetwork.id,
    specification: "Small",
});
const fooEipAddress = new alicloud.ecs.EipAddress("fooEipAddress", {addressName: name});
const fooEipAssociation = new alicloud.ecs.EipAssociation("fooEipAssociation", {
    allocationId: fooEipAddress.id,
    instanceId: fooNatGateway.id,
});
const fooSnatEntry = new alicloud.vpc.SnatEntry("fooSnatEntry", {
    snatTableId: fooNatGateway.snatTableIds,
    sourceVswitchId: fooSwitch.id,
    snatIp: fooEipAddress.ipAddress,
});
const fooSnatEntries = alicloud.vpc.getSnatEntriesOutput({
    snatTableId: fooSnatEntry.snatTableId,
});
configuration:
  name:
    type: string
    default: snat-entry-example-name
resources:
  fooNetwork:
    type: alicloud:vpc:Network
    properties:
      cidrBlock: 172.16.0.0/12
  fooSwitch:
    type: alicloud:vpc:Switch
    properties:
      vpcId: ${fooNetwork.id}
      cidrBlock: 172.16.0.0/21
      availabilityZone: ${default.zones[0].id}
      vswitchName: ${name}
  fooNatGateway:
    type: alicloud:vpc:NatGateway
    properties:
      vpcId: ${fooNetwork.id}
      specification: Small
  fooEipAddress:
    type: alicloud:ecs:EipAddress
    properties:
      addressName: ${name}
  fooEipAssociation:
    type: alicloud:ecs:EipAssociation
    properties:
      allocationId: ${fooEipAddress.id}
      instanceId: ${fooNatGateway.id}
  fooSnatEntry:
    type: alicloud:vpc:SnatEntry
    properties:
      snatTableId: ${fooNatGateway.snatTableIds}
      sourceVswitchId: ${fooSwitch.id}
      snatIp: ${fooEipAddress.ipAddress}
variables:
  default:
    fn::invoke:
      Function: alicloud:getZones
      Arguments:
        availableResourceCreation: VSwitch
  fooSnatEntries:
    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:

SnatTableId string

The ID of the Snat table.

Ids List<string>

A list of Snat Entries IDs.

NameRegex string

A regex string to filter results by the resource name.

OutputFile string
SnatEntryName string

The name of snat entry.

SnatIp string

The public IP of the Snat Entry.

SourceCidr string

The source CIDR block of the Snat Entry.

SourceVswitchId string

The source vswitch ID.

Status string

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

SnatTableId string

The ID of the Snat table.

Ids []string

A list of Snat Entries IDs.

NameRegex string

A regex string to filter results by the resource name.

OutputFile string
SnatEntryName string

The name of snat entry.

SnatIp string

The public IP of the Snat Entry.

SourceCidr string

The source CIDR block of the Snat Entry.

SourceVswitchId string

The source vswitch ID.

Status string

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

snatTableId String

The ID of the Snat table.

ids List<String>

A list of Snat Entries IDs.

nameRegex String

A regex string to filter results by the resource name.

outputFile String
snatEntryName String

The name of snat entry.

snatIp String

The public IP of the Snat Entry.

sourceCidr String

The source CIDR block of the Snat Entry.

sourceVswitchId String

The source vswitch ID.

status String

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

snatTableId string

The ID of the Snat table.

ids string[]

A list of Snat Entries IDs.

nameRegex string

A regex string to filter results by the resource name.

outputFile string
snatEntryName string

The name of snat entry.

snatIp string

The public IP of the Snat Entry.

sourceCidr string

The source CIDR block of the Snat Entry.

sourceVswitchId string

The source vswitch ID.

status string

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

snat_table_id str

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
snat_entry_name str

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_id str

The source vswitch ID.

status str

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

snatTableId String

The ID of the Snat table.

ids List<String>

A list of Snat Entries IDs.

nameRegex String

A regex string to filter results by the resource name.

outputFile String
snatEntryName String

The name of snat entry.

snatIp String

The public IP of the Snat Entry.

sourceCidr String

The source CIDR block of the Snat Entry.

sourceVswitchId String

The source vswitch ID.

status String

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

getSnatEntries Result

The following output properties are available:

Entries List<Pulumi.AliCloud.Vpc.Outputs.GetSnatEntriesEntry>

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>
SnatTableId string
NameRegex string
OutputFile string
SnatEntryName string

The name of snat entry.

SnatIp string

The public IP of the Snat Entry.

SourceCidr string

The source CIDR block of the Snat Entry.

SourceVswitchId string

The source vswitch ID.

Status string

The status of the Snat Entry.

Entries []GetSnatEntriesEntry

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
SnatTableId string
NameRegex string
OutputFile string
SnatEntryName string

The name of snat entry.

SnatIp string

The public IP of the Snat Entry.

SourceCidr string

The source CIDR block of the Snat Entry.

SourceVswitchId string

The source vswitch ID.

Status string

The status of the Snat Entry.

entries List<GetSnatEntriesEntry>

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>
snatTableId String
nameRegex String
outputFile String
snatEntryName String

The name of snat entry.

snatIp String

The public IP of the Snat Entry.

sourceCidr String

The source CIDR block of the Snat Entry.

sourceVswitchId String

The source vswitch ID.

status String

The status of the Snat Entry.

entries GetSnatEntriesEntry[]

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[]
snatTableId string
nameRegex string
outputFile string
snatEntryName string

The name of snat entry.

snatIp string

The public IP of the Snat Entry.

sourceCidr string

The source CIDR block of the Snat Entry.

sourceVswitchId string

The source vswitch ID.

status string

The status of the Snat Entry.

entries Sequence[GetSnatEntriesEntry]

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_id str
name_regex str
output_file str
snat_entry_name str

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_id str

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>
snatTableId String
nameRegex String
outputFile String
snatEntryName String

The name of snat entry.

snatIp String

The public IP of the Snat Entry.

sourceCidr String

The source CIDR block of the Snat Entry.

sourceVswitchId String

The source vswitch ID.

status String

The status of the Snat Entry.

Supporting Types

GetSnatEntriesEntry

Id string

The ID of the Snat Entry.

SnatEntryId string

The ID of snat entry.

SnatEntryName string

The name of snat entry.

SnatIp string

The public IP of the Snat Entry.

SourceCidr string

The source CIDR block of the Snat Entry.

SourceVswitchId string

The source vswitch ID.

Status string

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

Id string

The ID of the Snat Entry.

SnatEntryId string

The ID of snat entry.

SnatEntryName string

The name of snat entry.

SnatIp string

The public IP of the Snat Entry.

SourceCidr string

The source CIDR block of the Snat Entry.

SourceVswitchId string

The source vswitch ID.

Status string

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

id String

The ID of the Snat Entry.

snatEntryId String

The ID of snat entry.

snatEntryName String

The name of snat entry.

snatIp String

The public IP of the Snat Entry.

sourceCidr String

The source CIDR block of the Snat Entry.

sourceVswitchId String

The source vswitch ID.

status String

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

id string

The ID of the Snat Entry.

snatEntryId string

The ID of snat entry.

snatEntryName string

The name of snat entry.

snatIp string

The public IP of the Snat Entry.

sourceCidr string

The source CIDR block of the Snat Entry.

sourceVswitchId string

The source vswitch ID.

status string

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

id str

The ID of the Snat Entry.

snat_entry_id str

The ID of snat entry.

snat_entry_name str

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_id str

The source vswitch ID.

status str

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

id String

The ID of the Snat Entry.

snatEntryId String

The ID of snat entry.

snatEntryName String

The name of snat entry.

snatIp String

The public IP of the Snat Entry.

sourceCidr String

The source CIDR block of the Snat Entry.

sourceVswitchId String

The source vswitch ID.

status String

The status of the Snat Entry. Valid values: Available, Deleting and Pending.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.