1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. vpc
  5. NetworkAclAttachment
Alibaba Cloud v3.53.0 published on Wednesday, Apr 17, 2024 by Pulumi

alicloud.vpc.NetworkAclAttachment

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.53.0 published on Wednesday, Apr 17, 2024 by Pulumi

    Provides a network acl attachment resource to associate network acls to vswitches.

    DEPRECATED: This resource has been deprecated from version 1.124.0. Replace by resources with the resource alicloud_network_acl. Note that because this resource conflicts with the resources attribute of alicloud.vpc.NetworkAcl, this resource can no be used.

    NOTE: Available in 1.44.0+. Currently, the resource are only available in Hongkong(cn-hongkong), and Indonesia(ap-southeast-1) regions.

    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") || "NatGatewayConfigSpec";
    const defaultZones = alicloud.getZones({
        availableResourceCreation: "VSwitch",
    });
    const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
        vpcName: name,
        cidrBlock: "172.16.0.0/12",
    });
    const defaultNetworkAcl = new alicloud.vpc.NetworkAcl("defaultNetworkAcl", {
        vpcId: defaultNetwork.id,
        networkAclName: name,
    });
    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 defaultNetworkAclAttachment = new alicloud.vpc.NetworkAclAttachment("defaultNetworkAclAttachment", {
        networkAclId: defaultNetworkAcl.id,
        resources: [{
            resourceId: defaultSwitch.id,
            resourceType: "VSwitch",
        }],
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "NatGatewayConfigSpec"
    default_zones = alicloud.get_zones(available_resource_creation="VSwitch")
    default_network = alicloud.vpc.Network("defaultNetwork",
        vpc_name=name,
        cidr_block="172.16.0.0/12")
    default_network_acl = alicloud.vpc.NetworkAcl("defaultNetworkAcl",
        vpc_id=default_network.id,
        network_acl_name=name)
    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_network_acl_attachment = alicloud.vpc.NetworkAclAttachment("defaultNetworkAclAttachment",
        network_acl_id=default_network_acl.id,
        resources=[alicloud.vpc.NetworkAclAttachmentResourceArgs(
            resource_id=default_switch.id,
            resource_type="VSwitch",
        )])
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
    	"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 := "NatGatewayConfigSpec"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		defaultZones, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
    			AvailableResourceCreation: pulumi.StringRef("VSwitch"),
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
    			VpcName:   pulumi.String(name),
    			CidrBlock: pulumi.String("172.16.0.0/12"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultNetworkAcl, err := vpc.NewNetworkAcl(ctx, "defaultNetworkAcl", &vpc.NetworkAclArgs{
    			VpcId:          defaultNetwork.ID(),
    			NetworkAclName: pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		defaultSwitch, 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
    		}
    		_, err = vpc.NewNetworkAclAttachment(ctx, "defaultNetworkAclAttachment", &vpc.NetworkAclAttachmentArgs{
    			NetworkAclId: defaultNetworkAcl.ID(),
    			Resources: vpc.NetworkAclAttachmentResourceArray{
    				&vpc.NetworkAclAttachmentResourceArgs{
    					ResourceId:   defaultSwitch.ID(),
    					ResourceType: pulumi.String("VSwitch"),
    				},
    			},
    		})
    		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") ?? "NatGatewayConfigSpec";
        var defaultZones = AliCloud.GetZones.Invoke(new()
        {
            AvailableResourceCreation = "VSwitch",
        });
    
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
        {
            VpcName = name,
            CidrBlock = "172.16.0.0/12",
        });
    
        var defaultNetworkAcl = new AliCloud.Vpc.NetworkAcl("defaultNetworkAcl", new()
        {
            VpcId = defaultNetwork.Id,
            NetworkAclName = name,
        });
    
        var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new()
        {
            VpcId = defaultNetwork.Id,
            CidrBlock = "172.16.0.0/21",
            ZoneId = defaultZones.Apply(getZonesResult => getZonesResult.Zones[0]?.Id),
            VswitchName = name,
        });
    
        var defaultNetworkAclAttachment = new AliCloud.Vpc.NetworkAclAttachment("defaultNetworkAclAttachment", new()
        {
            NetworkAclId = defaultNetworkAcl.Id,
            Resources = new[]
            {
                new AliCloud.Vpc.Inputs.NetworkAclAttachmentResourceArgs
                {
                    ResourceId = defaultSwitch.Id,
                    ResourceType = "VSwitch",
                },
            },
        });
    
    });
    
    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.NetworkAcl;
    import com.pulumi.alicloud.vpc.NetworkAclArgs;
    import com.pulumi.alicloud.vpc.Switch;
    import com.pulumi.alicloud.vpc.SwitchArgs;
    import com.pulumi.alicloud.vpc.NetworkAclAttachment;
    import com.pulumi.alicloud.vpc.NetworkAclAttachmentArgs;
    import com.pulumi.alicloud.vpc.inputs.NetworkAclAttachmentResourceArgs;
    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("NatGatewayConfigSpec");
            final var defaultZones = AlicloudFunctions.getZones(GetZonesArgs.builder()
                .availableResourceCreation("VSwitch")
                .build());
    
            var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
                .vpcName(name)
                .cidrBlock("172.16.0.0/12")
                .build());
    
            var defaultNetworkAcl = new NetworkAcl("defaultNetworkAcl", NetworkAclArgs.builder()        
                .vpcId(defaultNetwork.id())
                .networkAclName(name)
                .build());
    
            var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()        
                .vpcId(defaultNetwork.id())
                .cidrBlock("172.16.0.0/21")
                .zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
                .vswitchName(name)
                .build());
    
            var defaultNetworkAclAttachment = new NetworkAclAttachment("defaultNetworkAclAttachment", NetworkAclAttachmentArgs.builder()        
                .networkAclId(defaultNetworkAcl.id())
                .resources(NetworkAclAttachmentResourceArgs.builder()
                    .resourceId(defaultSwitch.id())
                    .resourceType("VSwitch")
                    .build())
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: NatGatewayConfigSpec
    resources:
      defaultNetwork:
        type: alicloud:vpc:Network
        properties:
          vpcName: ${name}
          cidrBlock: 172.16.0.0/12
      defaultNetworkAcl:
        type: alicloud:vpc:NetworkAcl
        properties:
          vpcId: ${defaultNetwork.id}
          networkAclName: ${name}
      defaultSwitch:
        type: alicloud:vpc:Switch
        properties:
          vpcId: ${defaultNetwork.id}
          cidrBlock: 172.16.0.0/21
          zoneId: ${defaultZones.zones[0].id}
          vswitchName: ${name}
      defaultNetworkAclAttachment:
        type: alicloud:vpc:NetworkAclAttachment
        properties:
          networkAclId: ${defaultNetworkAcl.id}
          resources:
            - resourceId: ${defaultSwitch.id}
              resourceType: VSwitch
    variables:
      defaultZones:
        fn::invoke:
          Function: alicloud:getZones
          Arguments:
            availableResourceCreation: VSwitch
    

    Create NetworkAclAttachment Resource

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

    Constructor syntax

    new NetworkAclAttachment(name: string, args: NetworkAclAttachmentArgs, opts?: CustomResourceOptions);
    @overload
    def NetworkAclAttachment(resource_name: str,
                             args: NetworkAclAttachmentArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def NetworkAclAttachment(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             network_acl_id: Optional[str] = None,
                             resources: Optional[Sequence[NetworkAclAttachmentResourceArgs]] = None)
    func NewNetworkAclAttachment(ctx *Context, name string, args NetworkAclAttachmentArgs, opts ...ResourceOption) (*NetworkAclAttachment, error)
    public NetworkAclAttachment(string name, NetworkAclAttachmentArgs args, CustomResourceOptions? opts = null)
    public NetworkAclAttachment(String name, NetworkAclAttachmentArgs args)
    public NetworkAclAttachment(String name, NetworkAclAttachmentArgs args, CustomResourceOptions options)
    
    type: alicloud:vpc:NetworkAclAttachment
    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 NetworkAclAttachmentArgs
    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 NetworkAclAttachmentArgs
    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 NetworkAclAttachmentArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args NetworkAclAttachmentArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args NetworkAclAttachmentArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    Example

    The following reference example uses placeholder values for all input properties.

    var networkAclAttachmentResource = new AliCloud.Vpc.NetworkAclAttachment("networkAclAttachmentResource", new()
    {
        NetworkAclId = "string",
        Resources = new[]
        {
            new AliCloud.Vpc.Inputs.NetworkAclAttachmentResourceArgs
            {
                ResourceId = "string",
                ResourceType = "string",
            },
        },
    });
    
    example, err := vpc.NewNetworkAclAttachment(ctx, "networkAclAttachmentResource", &vpc.NetworkAclAttachmentArgs{
    	NetworkAclId: pulumi.String("string"),
    	Resources: vpc.NetworkAclAttachmentResourceArray{
    		&vpc.NetworkAclAttachmentResourceArgs{
    			ResourceId:   pulumi.String("string"),
    			ResourceType: pulumi.String("string"),
    		},
    	},
    })
    
    var networkAclAttachmentResource = new NetworkAclAttachment("networkAclAttachmentResource", NetworkAclAttachmentArgs.builder()        
        .networkAclId("string")
        .resources(NetworkAclAttachmentResourceArgs.builder()
            .resourceId("string")
            .resourceType("string")
            .build())
        .build());
    
    network_acl_attachment_resource = alicloud.vpc.NetworkAclAttachment("networkAclAttachmentResource",
        network_acl_id="string",
        resources=[alicloud.vpc.NetworkAclAttachmentResourceArgs(
            resource_id="string",
            resource_type="string",
        )])
    
    const networkAclAttachmentResource = new alicloud.vpc.NetworkAclAttachment("networkAclAttachmentResource", {
        networkAclId: "string",
        resources: [{
            resourceId: "string",
            resourceType: "string",
        }],
    });
    
    type: alicloud:vpc:NetworkAclAttachment
    properties:
        networkAclId: string
        resources:
            - resourceId: string
              resourceType: string
    

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

    NetworkAclId string
    The id of the network acl, the field can't be changed.
    Resources List<Pulumi.AliCloud.Vpc.Inputs.NetworkAclAttachmentResource>
    List of the resources associated with the network acl. The details see Block Resources.
    NetworkAclId string
    The id of the network acl, the field can't be changed.
    Resources []NetworkAclAttachmentResourceArgs
    List of the resources associated with the network acl. The details see Block Resources.
    networkAclId String
    The id of the network acl, the field can't be changed.
    resources List<NetworkAclAttachmentResource>
    List of the resources associated with the network acl. The details see Block Resources.
    networkAclId string
    The id of the network acl, the field can't be changed.
    resources NetworkAclAttachmentResource[]
    List of the resources associated with the network acl. The details see Block Resources.
    network_acl_id str
    The id of the network acl, the field can't be changed.
    resources Sequence[NetworkAclAttachmentResourceArgs]
    List of the resources associated with the network acl. The details see Block Resources.
    networkAclId String
    The id of the network acl, the field can't be changed.
    resources List<Property Map>
    List of the resources associated with the network acl. The details see Block Resources.

    Outputs

    All input properties are implicitly available as output properties. Additionally, the NetworkAclAttachment 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 string
    The provider-assigned unique ID for this managed resource.
    id str
    The provider-assigned unique ID for this managed resource.
    id String
    The provider-assigned unique ID for this managed resource.

    Look up Existing NetworkAclAttachment Resource

    Get an existing NetworkAclAttachment 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?: NetworkAclAttachmentState, opts?: CustomResourceOptions): NetworkAclAttachment
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            network_acl_id: Optional[str] = None,
            resources: Optional[Sequence[NetworkAclAttachmentResourceArgs]] = None) -> NetworkAclAttachment
    func GetNetworkAclAttachment(ctx *Context, name string, id IDInput, state *NetworkAclAttachmentState, opts ...ResourceOption) (*NetworkAclAttachment, error)
    public static NetworkAclAttachment Get(string name, Input<string> id, NetworkAclAttachmentState? state, CustomResourceOptions? opts = null)
    public static NetworkAclAttachment get(String name, Output<String> id, NetworkAclAttachmentState 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:
    NetworkAclId string
    The id of the network acl, the field can't be changed.
    Resources List<Pulumi.AliCloud.Vpc.Inputs.NetworkAclAttachmentResource>
    List of the resources associated with the network acl. The details see Block Resources.
    NetworkAclId string
    The id of the network acl, the field can't be changed.
    Resources []NetworkAclAttachmentResourceArgs
    List of the resources associated with the network acl. The details see Block Resources.
    networkAclId String
    The id of the network acl, the field can't be changed.
    resources List<NetworkAclAttachmentResource>
    List of the resources associated with the network acl. The details see Block Resources.
    networkAclId string
    The id of the network acl, the field can't be changed.
    resources NetworkAclAttachmentResource[]
    List of the resources associated with the network acl. The details see Block Resources.
    network_acl_id str
    The id of the network acl, the field can't be changed.
    resources Sequence[NetworkAclAttachmentResourceArgs]
    List of the resources associated with the network acl. The details see Block Resources.
    networkAclId String
    The id of the network acl, the field can't be changed.
    resources List<Property Map>
    List of the resources associated with the network acl. The details see Block Resources.

    Supporting Types

    NetworkAclAttachmentResource, NetworkAclAttachmentResourceArgs

    ResourceId string
    The resource id that the network acl will associate with.
    ResourceType string
    The resource id that the network acl will associate with. Only support VSwitch now.
    ResourceId string
    The resource id that the network acl will associate with.
    ResourceType string
    The resource id that the network acl will associate with. Only support VSwitch now.
    resourceId String
    The resource id that the network acl will associate with.
    resourceType String
    The resource id that the network acl will associate with. Only support VSwitch now.
    resourceId string
    The resource id that the network acl will associate with.
    resourceType string
    The resource id that the network acl will associate with. Only support VSwitch now.
    resource_id str
    The resource id that the network acl will associate with.
    resource_type str
    The resource id that the network acl will associate with. Only support VSwitch now.
    resourceId String
    The resource id that the network acl will associate with.
    resourceType String
    The resource id that the network acl will associate with. Only support VSwitch now.

    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.53.0 published on Wednesday, Apr 17, 2024 by Pulumi