Alibaba Cloud

v3.15.0 published on Thursday, Jan 13, 2022 by Pulumi

Ingress

Provides a Serverless App Engine (SAE) Ingress resource.

For information about Serverless App Engine (SAE) Ingress and how to use it, see What is Ingress.

NOTE: Available in v1.137.0+.

Example Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var config = new Config();
        var name = config.Get("name") ?? "example_value";
        var defaultZones = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
        {
            AvailableResourceCreation = "VSwitch",
        }));
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
        {
            CidrBlock = "172.16.0.0/12",
        });
        var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new AliCloud.Vpc.SwitchArgs
        {
            VpcId = defaultNetwork.Id,
            CidrBlock = "172.16.0.0/21",
            ZoneId = defaultZones.Apply(defaultZones => defaultZones.Zones?[0]?.Id),
            VswitchName = name,
        });
        var defaultLoadBalancer = new AliCloud.Slb.LoadBalancer("defaultLoadBalancer", new AliCloud.Slb.LoadBalancerArgs
        {
            Specification = "slb.s2.small",
            VswitchId = data.Alicloud_vswitches.Default.Ids[0],
        });
        var namespaceId = config.Get("namespaceId") ?? "cn-hangzhou:yourname";
        var defaultNamespace = new AliCloud.Sae.Namespace("defaultNamespace", new AliCloud.Sae.NamespaceArgs
        {
            NamespaceId = namespaceId,
            NamespaceName = name,
            NamespaceDescription = name,
        });
        var defaultApplication = new AliCloud.Sae.Application("defaultApplication", new AliCloud.Sae.ApplicationArgs
        {
            AppDescription = "your_app_description",
            AppName = "your_app_name",
            NamespaceId = "your_namespace_id",
            PackageUrl = "your_package_url",
            PackageType = "your_package_url",
            Jdk = "jdk_specifications",
            VswitchId = data.Alicloud_vswitches.Default.Ids[0],
            Replicas = "your_replicas",
            Cpu = "cpu_specifications",
            Memory = "memory_specifications",
        });
        var defaultIngress = new AliCloud.Sae.Ingress("defaultIngress", new AliCloud.Sae.IngressArgs
        {
            SlbId = defaultLoadBalancer.Id,
            NamespaceId = defaultNamespace.Id,
            ListenerPort = "your_listener_port",
            Rules = 
            {
                new AliCloud.Sae.Inputs.IngressRuleArgs
                {
                    AppId = defaultApplication.Id,
                    ContainerPort = "your_container_port",
                    Domain = "your_domain",
                    AppName = "your_name",
                    Path = "your_path",
                },
            },
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/sae"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/slb"
	"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 := "example_value"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		opt0 := "VSwitch"
		defaultZones, err := alicloud.GetZones(ctx, &GetZonesArgs{
			AvailableResourceCreation: &opt0,
		}, nil)
		if err != nil {
			return err
		}
		defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
			CidrBlock: pulumi.String("172.16.0.0/12"),
		})
		if err != nil {
			return err
		}
		_, err = vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
			VpcId:       defaultNetwork.ID(),
			CidrBlock:   pulumi.String("172.16.0.0/21"),
			ZoneId:      pulumi.String(defaultZones.Zones[0].Id),
			VswitchName: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		defaultLoadBalancer, err := slb.NewLoadBalancer(ctx, "defaultLoadBalancer", &slb.LoadBalancerArgs{
			Specification: pulumi.String("slb.s2.small"),
			VswitchId:     pulumi.Any(data.Alicloud_vswitches.Default.Ids[0]),
		})
		if err != nil {
			return err
		}
		namespaceId := "cn-hangzhou:yourname"
		if param := cfg.Get("namespaceId"); param != "" {
			namespaceId = param
		}
		defaultNamespace, err := sae.NewNamespace(ctx, "defaultNamespace", &sae.NamespaceArgs{
			NamespaceId:          pulumi.String(namespaceId),
			NamespaceName:        pulumi.String(name),
			NamespaceDescription: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		defaultApplication, err := sae.NewApplication(ctx, "defaultApplication", &sae.ApplicationArgs{
			AppDescription: pulumi.String("your_app_description"),
			AppName:        pulumi.String("your_app_name"),
			NamespaceId:    pulumi.String("your_namespace_id"),
			PackageUrl:     pulumi.String("your_package_url"),
			PackageType:    pulumi.String("your_package_url"),
			Jdk:            pulumi.String("jdk_specifications"),
			VswitchId:      pulumi.Any(data.Alicloud_vswitches.Default.Ids[0]),
			Replicas:       pulumi.Int("your_replicas"),
			Cpu:            pulumi.Int("cpu_specifications"),
			Memory:         pulumi.Int("memory_specifications"),
		})
		if err != nil {
			return err
		}
		_, err = sae.NewIngress(ctx, "defaultIngress", &sae.IngressArgs{
			SlbId:        defaultLoadBalancer.ID(),
			NamespaceId:  defaultNamespace.ID(),
			ListenerPort: pulumi.Int("your_listener_port"),
			Rules: sae.IngressRuleArray{
				&sae.IngressRuleArgs{
					AppId:         defaultApplication.ID(),
					ContainerPort: pulumi.Int("your_container_port"),
					Domain:        pulumi.String("your_domain"),
					AppName:       pulumi.String("your_name"),
					Path:          pulumi.String("your_path"),
				},
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "example_value"
default_zones = alicloud.get_zones(available_resource_creation="VSwitch")
default_network = alicloud.vpc.Network("defaultNetwork", cidr_block="172.16.0.0/12")
default_switch = alicloud.vpc.Switch("defaultSwitch",
    vpc_id=default_network.id,
    cidr_block="172.16.0.0/21",
    zone_id=default_zones.zones[0].id,
    vswitch_name=name)
default_load_balancer = alicloud.slb.LoadBalancer("defaultLoadBalancer",
    specification="slb.s2.small",
    vswitch_id=data["alicloud_vswitches"]["default"]["ids"])
namespace_id = config.get("namespaceId")
if namespace_id is None:
    namespace_id = "cn-hangzhou:yourname"
default_namespace = alicloud.sae.Namespace("defaultNamespace",
    namespace_id=namespace_id,
    namespace_name=name,
    namespace_description=name)
default_application = alicloud.sae.Application("defaultApplication",
    app_description="your_app_description",
    app_name="your_app_name",
    namespace_id="your_namespace_id",
    package_url="your_package_url",
    package_type="your_package_url",
    jdk="jdk_specifications",
    vswitch_id=data["alicloud_vswitches"]["default"]["ids"],
    replicas="your_replicas",
    cpu="cpu_specifications",
    memory="memory_specifications")
default_ingress = alicloud.sae.Ingress("defaultIngress",
    slb_id=default_load_balancer.id,
    namespace_id=default_namespace.id,
    listener_port="your_listener_port",
    rules=[alicloud.sae.IngressRuleArgs(
        app_id=default_application.id,
        container_port="your_container_port",
        domain="your_domain",
        app_name="your_name",
        path="your_path",
    )])
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "example_value";
const defaultZones = alicloud.getZones({
    availableResourceCreation: "VSwitch",
});
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {cidrBlock: "172.16.0.0/12"});
const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
    vpcId: defaultNetwork.id,
    cidrBlock: "172.16.0.0/21",
    zoneId: defaultZones.then(defaultZones => defaultZones.zones?[0]?.id),
    vswitchName: name,
});
const defaultLoadBalancer = new alicloud.slb.LoadBalancer("defaultLoadBalancer", {
    specification: "slb.s2.small",
    vswitchId: data.alicloud_vswitches["default"].ids[0],
});
const namespaceId = config.get("namespaceId") || "cn-hangzhou:yourname";
const defaultNamespace = new alicloud.sae.Namespace("defaultNamespace", {
    namespaceId: namespaceId,
    namespaceName: name,
    namespaceDescription: name,
});
const defaultApplication = new alicloud.sae.Application("defaultApplication", {
    appDescription: "your_app_description",
    appName: "your_app_name",
    namespaceId: "your_namespace_id",
    packageUrl: "your_package_url",
    packageType: "your_package_url",
    jdk: "jdk_specifications",
    vswitchId: data.alicloud_vswitches["default"].ids[0],
    replicas: "your_replicas",
    cpu: "cpu_specifications",
    memory: "memory_specifications",
});
const defaultIngress = new alicloud.sae.Ingress("defaultIngress", {
    slbId: defaultLoadBalancer.id,
    namespaceId: defaultNamespace.id,
    listenerPort: "your_listener_port",
    rules: [{
        appId: defaultApplication.id,
        containerPort: "your_container_port",
        domain: "your_domain",
        appName: "your_name",
        path: "your_path",
    }],
});

Create a Ingress Resource

new Ingress(name: string, args: IngressArgs, opts?: CustomResourceOptions);
@overload
def Ingress(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            cert_id: Optional[str] = None,
            default_rule: Optional[IngressDefaultRuleArgs] = None,
            description: Optional[str] = None,
            listener_port: Optional[int] = None,
            namespace_id: Optional[str] = None,
            rules: Optional[Sequence[IngressRuleArgs]] = None,
            slb_id: Optional[str] = None)
@overload
def Ingress(resource_name: str,
            args: IngressArgs,
            opts: Optional[ResourceOptions] = None)
func NewIngress(ctx *Context, name string, args IngressArgs, opts ...ResourceOption) (*Ingress, error)
public Ingress(string name, IngressArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args IngressArgs
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 IngressArgs
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 IngressArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args IngressArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

Ingress Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

The Ingress resource accepts the following input properties:

ListenerPort int
SLB listening port.
NamespaceId string
The Id of Namespace.It can contain 2 to 32 lowercase characters.The value is in format {RegionId}:{namespace}
Rules List<Pulumi.AliCloud.Sae.Inputs.IngressRuleArgs>
Forwarding rules. Forward traffic to the specified application according to the domain name and path.
SlbId string
SLB ID.
CertId string
Cert Id.
DefaultRule Pulumi.AliCloud.Sae.Inputs.IngressDefaultRuleArgs
Default Rule.
Description string
Description.
ListenerPort int
SLB listening port.
NamespaceId string
The Id of Namespace.It can contain 2 to 32 lowercase characters.The value is in format {RegionId}:{namespace}
Rules []IngressRuleArgs
Forwarding rules. Forward traffic to the specified application according to the domain name and path.
SlbId string
SLB ID.
CertId string
Cert Id.
DefaultRule IngressDefaultRuleArgs
Default Rule.
Description string
Description.
listenerPort number
SLB listening port.
namespaceId string
The Id of Namespace.It can contain 2 to 32 lowercase characters.The value is in format {RegionId}:{namespace}
rules IngressRuleArgs[]
Forwarding rules. Forward traffic to the specified application according to the domain name and path.
slbId string
SLB ID.
certId string
Cert Id.
defaultRule IngressDefaultRuleArgs
Default Rule.
description string
Description.
listener_port int
SLB listening port.
namespace_id str
The Id of Namespace.It can contain 2 to 32 lowercase characters.The value is in format {RegionId}:{namespace}
rules Sequence[IngressRuleArgs]
Forwarding rules. Forward traffic to the specified application according to the domain name and path.
slb_id str
SLB ID.
cert_id str
Cert Id.
default_rule IngressDefaultRuleArgs
Default Rule.
description str
Description.

Outputs

All input properties are implicitly available as output properties. Additionally, the Ingress resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Id string
The provider-assigned unique ID for this managed resource.
id string
The provider-assigned unique ID for this managed resource.
id str
The provider-assigned unique ID for this managed resource.

Look up an Existing Ingress Resource

Get an existing Ingress 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?: IngressState, opts?: CustomResourceOptions): Ingress
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        cert_id: Optional[str] = None,
        default_rule: Optional[IngressDefaultRuleArgs] = None,
        description: Optional[str] = None,
        listener_port: Optional[int] = None,
        namespace_id: Optional[str] = None,
        rules: Optional[Sequence[IngressRuleArgs]] = None,
        slb_id: Optional[str] = None) -> Ingress
func GetIngress(ctx *Context, name string, id IDInput, state *IngressState, opts ...ResourceOption) (*Ingress, error)
public static Ingress Get(string name, Input<string> id, IngressState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

CertId string
Cert Id.
DefaultRule Pulumi.AliCloud.Sae.Inputs.IngressDefaultRuleArgs
Default Rule.
Description string
Description.
ListenerPort int
SLB listening port.
NamespaceId string
The Id of Namespace.It can contain 2 to 32 lowercase characters.The value is in format {RegionId}:{namespace}
Rules List<Pulumi.AliCloud.Sae.Inputs.IngressRuleArgs>
Forwarding rules. Forward traffic to the specified application according to the domain name and path.
SlbId string
SLB ID.
CertId string
Cert Id.
DefaultRule IngressDefaultRuleArgs
Default Rule.
Description string
Description.
ListenerPort int
SLB listening port.
NamespaceId string
The Id of Namespace.It can contain 2 to 32 lowercase characters.The value is in format {RegionId}:{namespace}
Rules []IngressRuleArgs
Forwarding rules. Forward traffic to the specified application according to the domain name and path.
SlbId string
SLB ID.
certId string
Cert Id.
defaultRule IngressDefaultRuleArgs
Default Rule.
description string
Description.
listenerPort number
SLB listening port.
namespaceId string
The Id of Namespace.It can contain 2 to 32 lowercase characters.The value is in format {RegionId}:{namespace}
rules IngressRuleArgs[]
Forwarding rules. Forward traffic to the specified application according to the domain name and path.
slbId string
SLB ID.
cert_id str
Cert Id.
default_rule IngressDefaultRuleArgs
Default Rule.
description str
Description.
listener_port int
SLB listening port.
namespace_id str
The Id of Namespace.It can contain 2 to 32 lowercase characters.The value is in format {RegionId}:{namespace}
rules Sequence[IngressRuleArgs]
Forwarding rules. Forward traffic to the specified application according to the domain name and path.
slb_id str
SLB ID.

Supporting Types

IngressDefaultRule

AppId string
Target application ID.
AppName string
Target application name.
ContainerPort int
Application backend port.
AppId string
Target application ID.
AppName string
Target application name.
ContainerPort int
Application backend port.
appId string
Target application ID.
appName string
Target application name.
containerPort number
Application backend port.
app_id str
Target application ID.
app_name str
Target application name.
container_port int
Application backend port.

IngressRule

AppId string
Target application ID.
AppName string
Target application name.
ContainerPort int
Application backend port.
Domain string
Application domain name.
Path string
URL path.
AppId string
Target application ID.
AppName string
Target application name.
ContainerPort int
Application backend port.
Domain string
Application domain name.
Path string
URL path.
appId string
Target application ID.
appName string
Target application name.
containerPort number
Application backend port.
domain string
Application domain name.
path string
URL path.
app_id str
Target application ID.
app_name str
Target application name.
container_port int
Application backend port.
domain str
Application domain name.
path str
URL path.

Import

Serverless App Engine (SAE) Ingress can be imported using the id, e.g.

 $ pulumi import alicloud:sae/ingress:Ingress example <id>

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.