1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. simpleapplicationserver
  5. FirewallRule
Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi

alicloud.simpleapplicationserver.FirewallRule

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi

    Provides a Simple Application Server Firewall Rule resource.

    For information about Simple Application Server Firewall Rule and how to use it, see What is Firewall Rule.

    NOTE: Available since v1.143.0.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const config = new pulumi.Config();
    const name = config.get("name") || "tf_example";
    const default = alicloud.simpleapplicationserver.getImages({});
    const defaultGetServerPlans = alicloud.simpleapplicationserver.getServerPlans({});
    const defaultInstance = new alicloud.simpleapplicationserver.Instance("default", {
        paymentType: "Subscription",
        planId: defaultGetServerPlans.then(defaultGetServerPlans => defaultGetServerPlans.plans?.[0]?.id),
        instanceName: name,
        imageId: _default.then(_default => _default.images?.[0]?.id),
        period: 1,
        dataDiskSize: 100,
    });
    const defaultFirewallRule = new alicloud.simpleapplicationserver.FirewallRule("default", {
        instanceId: defaultInstance.id,
        ruleProtocol: "Tcp",
        port: "9999",
        remark: name,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "tf_example"
    default = alicloud.simpleapplicationserver.get_images()
    default_get_server_plans = alicloud.simpleapplicationserver.get_server_plans()
    default_instance = alicloud.simpleapplicationserver.Instance("default",
        payment_type="Subscription",
        plan_id=default_get_server_plans.plans[0].id,
        instance_name=name,
        image_id=default.images[0].id,
        period=1,
        data_disk_size=100)
    default_firewall_rule = alicloud.simpleapplicationserver.FirewallRule("default",
        instance_id=default_instance.id,
        rule_protocol="Tcp",
        port="9999",
        remark=name)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/simpleapplicationserver"
    	"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 := "tf_example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		_default, err := simpleapplicationserver.GetImages(ctx, &simpleapplicationserver.GetImagesArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		defaultGetServerPlans, err := simpleapplicationserver.GetServerPlans(ctx, &simpleapplicationserver.GetServerPlansArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		defaultInstance, err := simpleapplicationserver.NewInstance(ctx, "default", &simpleapplicationserver.InstanceArgs{
    			PaymentType:  pulumi.String("Subscription"),
    			PlanId:       pulumi.String(defaultGetServerPlans.Plans[0].Id),
    			InstanceName: pulumi.String(name),
    			ImageId:      pulumi.String(_default.Images[0].Id),
    			Period:       pulumi.Int(1),
    			DataDiskSize: pulumi.Int(100),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = simpleapplicationserver.NewFirewallRule(ctx, "default", &simpleapplicationserver.FirewallRuleArgs{
    			InstanceId:   defaultInstance.ID(),
    			RuleProtocol: pulumi.String("Tcp"),
    			Port:         pulumi.String("9999"),
    			Remark:       pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		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") ?? "tf_example";
        var @default = AliCloud.SimpleApplicationServer.GetImages.Invoke();
    
        var defaultGetServerPlans = AliCloud.SimpleApplicationServer.GetServerPlans.Invoke();
    
        var defaultInstance = new AliCloud.SimpleApplicationServer.Instance("default", new()
        {
            PaymentType = "Subscription",
            PlanId = defaultGetServerPlans.Apply(getServerPlansResult => getServerPlansResult.Plans[0]?.Id),
            InstanceName = name,
            ImageId = @default.Apply(@default => @default.Apply(getImagesResult => getImagesResult.Images[0]?.Id)),
            Period = 1,
            DataDiskSize = 100,
        });
    
        var defaultFirewallRule = new AliCloud.SimpleApplicationServer.FirewallRule("default", new()
        {
            InstanceId = defaultInstance.Id,
            RuleProtocol = "Tcp",
            Port = "9999",
            Remark = name,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.simpleapplicationserver.SimpleapplicationserverFunctions;
    import com.pulumi.alicloud.simpleapplicationserver.inputs.GetImagesArgs;
    import com.pulumi.alicloud.simpleapplicationserver.inputs.GetServerPlansArgs;
    import com.pulumi.alicloud.simpleapplicationserver.Instance;
    import com.pulumi.alicloud.simpleapplicationserver.InstanceArgs;
    import com.pulumi.alicloud.simpleapplicationserver.FirewallRule;
    import com.pulumi.alicloud.simpleapplicationserver.FirewallRuleArgs;
    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("tf_example");
            final var default = SimpleapplicationserverFunctions.getImages();
    
            final var defaultGetServerPlans = SimpleapplicationserverFunctions.getServerPlans();
    
            var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
                .paymentType("Subscription")
                .planId(defaultGetServerPlans.applyValue(getServerPlansResult -> getServerPlansResult.plans()[0].id()))
                .instanceName(name)
                .imageId(default_.images()[0].id())
                .period(1)
                .dataDiskSize(100)
                .build());
    
            var defaultFirewallRule = new FirewallRule("defaultFirewallRule", FirewallRuleArgs.builder()
                .instanceId(defaultInstance.id())
                .ruleProtocol("Tcp")
                .port("9999")
                .remark(name)
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: tf_example
    resources:
      defaultInstance:
        type: alicloud:simpleapplicationserver:Instance
        name: default
        properties:
          paymentType: Subscription
          planId: ${defaultGetServerPlans.plans[0].id}
          instanceName: ${name}
          imageId: ${default.images[0].id}
          period: 1
          dataDiskSize: 100
      defaultFirewallRule:
        type: alicloud:simpleapplicationserver:FirewallRule
        name: default
        properties:
          instanceId: ${defaultInstance.id}
          ruleProtocol: Tcp
          port: '9999'
          remark: ${name}
    variables:
      default:
        fn::invoke:
          Function: alicloud:simpleapplicationserver:getImages
          Arguments: {}
      defaultGetServerPlans:
        fn::invoke:
          Function: alicloud:simpleapplicationserver:getServerPlans
          Arguments: {}
    

    Create FirewallRule Resource

    Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

    Constructor syntax

    new FirewallRule(name: string, args: FirewallRuleArgs, opts?: CustomResourceOptions);
    @overload
    def FirewallRule(resource_name: str,
                     args: FirewallRuleArgs,
                     opts: Optional[ResourceOptions] = None)
    
    @overload
    def FirewallRule(resource_name: str,
                     opts: Optional[ResourceOptions] = None,
                     instance_id: Optional[str] = None,
                     port: Optional[str] = None,
                     rule_protocol: Optional[str] = None,
                     remark: Optional[str] = None)
    func NewFirewallRule(ctx *Context, name string, args FirewallRuleArgs, opts ...ResourceOption) (*FirewallRule, error)
    public FirewallRule(string name, FirewallRuleArgs args, CustomResourceOptions? opts = null)
    public FirewallRule(String name, FirewallRuleArgs args)
    public FirewallRule(String name, FirewallRuleArgs args, CustomResourceOptions options)
    
    type: alicloud:simpleapplicationserver:FirewallRule
    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 FirewallRuleArgs
    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 FirewallRuleArgs
    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 FirewallRuleArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args FirewallRuleArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args FirewallRuleArgs
    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 firewallRuleResource = new AliCloud.SimpleApplicationServer.FirewallRule("firewallRuleResource", new()
    {
        InstanceId = "string",
        Port = "string",
        RuleProtocol = "string",
        Remark = "string",
    });
    
    example, err := simpleapplicationserver.NewFirewallRule(ctx, "firewallRuleResource", &simpleapplicationserver.FirewallRuleArgs{
    	InstanceId:   pulumi.String("string"),
    	Port:         pulumi.String("string"),
    	RuleProtocol: pulumi.String("string"),
    	Remark:       pulumi.String("string"),
    })
    
    var firewallRuleResource = new FirewallRule("firewallRuleResource", FirewallRuleArgs.builder()
        .instanceId("string")
        .port("string")
        .ruleProtocol("string")
        .remark("string")
        .build());
    
    firewall_rule_resource = alicloud.simpleapplicationserver.FirewallRule("firewallRuleResource",
        instance_id="string",
        port="string",
        rule_protocol="string",
        remark="string")
    
    const firewallRuleResource = new alicloud.simpleapplicationserver.FirewallRule("firewallRuleResource", {
        instanceId: "string",
        port: "string",
        ruleProtocol: "string",
        remark: "string",
    });
    
    type: alicloud:simpleapplicationserver:FirewallRule
    properties:
        instanceId: string
        port: string
        remark: string
        ruleProtocol: string
    

    FirewallRule 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 FirewallRule resource accepts the following input properties:

    InstanceId string
    Alibaba Cloud simple application server instance ID.
    Port string
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    RuleProtocol string
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    Remark string
    The remarks of the firewall rule.
    InstanceId string
    Alibaba Cloud simple application server instance ID.
    Port string
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    RuleProtocol string
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    Remark string
    The remarks of the firewall rule.
    instanceId String
    Alibaba Cloud simple application server instance ID.
    port String
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    ruleProtocol String
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    remark String
    The remarks of the firewall rule.
    instanceId string
    Alibaba Cloud simple application server instance ID.
    port string
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    ruleProtocol string
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    remark string
    The remarks of the firewall rule.
    instance_id str
    Alibaba Cloud simple application server instance ID.
    port str
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    rule_protocol str
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    remark str
    The remarks of the firewall rule.
    instanceId String
    Alibaba Cloud simple application server instance ID.
    port String
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    ruleProtocol String
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    remark String
    The remarks of the firewall rule.

    Outputs

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

    FirewallRuleId string
    The ID of the firewall rule.
    Id string
    The provider-assigned unique ID for this managed resource.
    FirewallRuleId string
    The ID of the firewall rule.
    Id string
    The provider-assigned unique ID for this managed resource.
    firewallRuleId String
    The ID of the firewall rule.
    id String
    The provider-assigned unique ID for this managed resource.
    firewallRuleId string
    The ID of the firewall rule.
    id string
    The provider-assigned unique ID for this managed resource.
    firewall_rule_id str
    The ID of the firewall rule.
    id str
    The provider-assigned unique ID for this managed resource.
    firewallRuleId String
    The ID of the firewall rule.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing FirewallRule Resource

    Get an existing FirewallRule 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?: FirewallRuleState, opts?: CustomResourceOptions): FirewallRule
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            firewall_rule_id: Optional[str] = None,
            instance_id: Optional[str] = None,
            port: Optional[str] = None,
            remark: Optional[str] = None,
            rule_protocol: Optional[str] = None) -> FirewallRule
    func GetFirewallRule(ctx *Context, name string, id IDInput, state *FirewallRuleState, opts ...ResourceOption) (*FirewallRule, error)
    public static FirewallRule Get(string name, Input<string> id, FirewallRuleState? state, CustomResourceOptions? opts = null)
    public static FirewallRule get(String name, Output<String> id, FirewallRuleState state, CustomResourceOptions options)
    Resource lookup is not supported in YAML
    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.
    The following state arguments are supported:
    FirewallRuleId string
    The ID of the firewall rule.
    InstanceId string
    Alibaba Cloud simple application server instance ID.
    Port string
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    Remark string
    The remarks of the firewall rule.
    RuleProtocol string
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    FirewallRuleId string
    The ID of the firewall rule.
    InstanceId string
    Alibaba Cloud simple application server instance ID.
    Port string
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    Remark string
    The remarks of the firewall rule.
    RuleProtocol string
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    firewallRuleId String
    The ID of the firewall rule.
    instanceId String
    Alibaba Cloud simple application server instance ID.
    port String
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    remark String
    The remarks of the firewall rule.
    ruleProtocol String
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    firewallRuleId string
    The ID of the firewall rule.
    instanceId string
    Alibaba Cloud simple application server instance ID.
    port string
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    remark string
    The remarks of the firewall rule.
    ruleProtocol string
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    firewall_rule_id str
    The ID of the firewall rule.
    instance_id str
    Alibaba Cloud simple application server instance ID.
    port str
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    remark str
    The remarks of the firewall rule.
    rule_protocol str
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.
    firewallRuleId String
    The ID of the firewall rule.
    instanceId String
    Alibaba Cloud simple application server instance ID.
    port String
    The port range. Valid values of port numbers: 1 to 65535. Specify a port range in the format of <start port number>/<end port number>. Example: 1024/1055, which indicates the port range of 1024 through 1055.
    remark String
    The remarks of the firewall rule.
    ruleProtocol String
    The transport layer protocol. Valid values: Tcp, Udp, TcpAndUdp.

    Import

    Simple Application Server Firewall Rule can be imported using the id, e.g.

    $ pulumi import alicloud:simpleapplicationserver/firewallRule:FirewallRule example <instance_id>:<firewall_rule_id>
    

    To learn more about importing existing cloud resources, see Importing resources.

    Package Details

    Repository
    Alibaba Cloud pulumi/pulumi-alicloud
    License
    Apache-2.0
    Notes
    This Pulumi package is based on the alicloud Terraform Provider.
    alicloud logo
    Alibaba Cloud v3.66.0 published on Friday, Nov 15, 2024 by Pulumi