alicloud.vpc.VpcNetworkAclAttachment
Explore with Pulumi AI
Provides a VPC Network Acl Attachment resource. Resources associated with network Acl.
For information about VPC Network Acl Attachment and how to use it, see What is Network Acl Attachment.
NOTE: Available since v1.193.0.
Example Usage
Basic Usage
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
import * as std from "@pulumi/std";
const _default = alicloud.getZones({
availableResourceCreation: "VSwitch",
});
const defaultNetwork = new alicloud.vpc.Network("default", {cidrBlock: "192.168.0.0/16"});
const defaultSwitch = new alicloud.vpc.Switch("default", {
vpcId: defaultNetwork.id,
cidrBlock: defaultNetwork.cidrBlock.apply(cidrBlock => std.cidrsubnetOutput({
input: cidrBlock,
newbits: 8,
netnum: 2,
})).apply(invoke => invoke.result),
zoneId: _default.then(_default => _default.zones?.[0]?.id),
});
const defaultNetworkAcl = new alicloud.vpc.NetworkAcl("default", {vpcId: defaultSwitch.vpcId});
const defaultVpcNetworkAclAttachment = new alicloud.vpc.VpcNetworkAclAttachment("default", {
networkAclId: defaultNetworkAcl.id,
resourceId: defaultSwitch.id,
resourceType: "VSwitch",
});
import pulumi
import pulumi_alicloud as alicloud
import pulumi_std as std
default = alicloud.get_zones(available_resource_creation="VSwitch")
default_network = alicloud.vpc.Network("default", cidr_block="192.168.0.0/16")
default_switch = alicloud.vpc.Switch("default",
vpc_id=default_network.id,
cidr_block=default_network.cidr_block.apply(lambda cidr_block: std.cidrsubnet_output(input=cidr_block,
newbits=8,
netnum=2)).apply(lambda invoke: invoke.result),
zone_id=default.zones[0].id)
default_network_acl = alicloud.vpc.NetworkAcl("default", vpc_id=default_switch.vpc_id)
default_vpc_network_acl_attachment = alicloud.vpc.VpcNetworkAclAttachment("default",
network_acl_id=default_network_acl.id,
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-std/sdk/go/std"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
_default, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
AvailableResourceCreation: pulumi.StringRef("VSwitch"),
}, nil)
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
CidrBlock: pulumi.String("192.168.0.0/16"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
VpcId: defaultNetwork.ID(),
CidrBlock: pulumi.String(defaultNetwork.CidrBlock.ApplyT(func(cidrBlock string) (std.CidrsubnetResult, error) {
return std.CidrsubnetResult(interface{}(std.CidrsubnetOutput(ctx, std.CidrsubnetOutputArgs{
Input: cidrBlock,
Newbits: 8,
Netnum: 2,
}, nil))), nil
}).(std.CidrsubnetResultOutput).ApplyT(func(invoke std.CidrsubnetResult) (*string, error) {
return invoke.Result, nil
}).(pulumi.StringPtrOutput)),
ZoneId: pulumi.String(_default.Zones[0].Id),
})
if err != nil {
return err
}
defaultNetworkAcl, err := vpc.NewNetworkAcl(ctx, "default", &vpc.NetworkAclArgs{
VpcId: defaultSwitch.VpcId,
})
if err != nil {
return err
}
_, err = vpc.NewVpcNetworkAclAttachment(ctx, "default", &vpc.VpcNetworkAclAttachmentArgs{
NetworkAclId: defaultNetworkAcl.ID(),
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;
using Std = Pulumi.Std;
return await Deployment.RunAsync(() =>
{
var @default = AliCloud.GetZones.Invoke(new()
{
AvailableResourceCreation = "VSwitch",
});
var defaultNetwork = new AliCloud.Vpc.Network("default", new()
{
CidrBlock = "192.168.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
{
VpcId = defaultNetwork.Id,
CidrBlock = defaultNetwork.CidrBlock.Apply(cidrBlock => Std.Cidrsubnet.Invoke(new()
{
Input = cidrBlock,
Newbits = 8,
Netnum = 2,
})).Apply(invoke => invoke.Result),
ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
});
var defaultNetworkAcl = new AliCloud.Vpc.NetworkAcl("default", new()
{
VpcId = defaultSwitch.VpcId,
});
var defaultVpcNetworkAclAttachment = new AliCloud.Vpc.VpcNetworkAclAttachment("default", new()
{
NetworkAclId = defaultNetworkAcl.Id,
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.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.std.StdFunctions;
import com.pulumi.std.inputs.CidrsubnetArgs;
import com.pulumi.alicloud.vpc.NetworkAcl;
import com.pulumi.alicloud.vpc.NetworkAclArgs;
import com.pulumi.alicloud.vpc.VpcNetworkAclAttachment;
import com.pulumi.alicloud.vpc.VpcNetworkAclAttachmentArgs;
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 default = AlicloudFunctions.getZones(GetZonesArgs.builder()
.availableResourceCreation("VSwitch")
.build());
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.cidrBlock("192.168.0.0/16")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.vpcId(defaultNetwork.id())
.cidrBlock(defaultNetwork.cidrBlock().applyValue(_cidrBlock -> StdFunctions.cidrsubnet(CidrsubnetArgs.builder()
.input(_cidrBlock)
.newbits(8)
.netnum(2)
.build())).applyValue(_invoke -> _invoke.result()))
.zoneId(default_.zones()[0].id())
.build());
var defaultNetworkAcl = new NetworkAcl("defaultNetworkAcl", NetworkAclArgs.builder()
.vpcId(defaultSwitch.vpcId())
.build());
var defaultVpcNetworkAclAttachment = new VpcNetworkAclAttachment("defaultVpcNetworkAclAttachment", VpcNetworkAclAttachmentArgs.builder()
.networkAclId(defaultNetworkAcl.id())
.resourceId(defaultSwitch.id())
.resourceType("VSwitch")
.build());
}
}
resources:
defaultNetwork:
type: alicloud:vpc:Network
name: default
properties:
cidrBlock: 192.168.0.0/16
defaultSwitch:
type: alicloud:vpc:Switch
name: default
properties:
vpcId: ${defaultNetwork.id}
cidrBlock:
fn::invoke:
function: std:cidrsubnet
arguments:
input: ${defaultNetwork.cidrBlock}
newbits: 8
netnum: 2
return: result
zoneId: ${default.zones[0].id}
defaultNetworkAcl:
type: alicloud:vpc:NetworkAcl
name: default
properties:
vpcId: ${defaultSwitch.vpcId}
defaultVpcNetworkAclAttachment:
type: alicloud:vpc:VpcNetworkAclAttachment
name: default
properties:
networkAclId: ${defaultNetworkAcl.id}
resourceId: ${defaultSwitch.id}
resourceType: VSwitch
variables:
default:
fn::invoke:
function: alicloud:getZones
arguments:
availableResourceCreation: VSwitch
Create VpcNetworkAclAttachment Resource
Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.
Constructor syntax
new VpcNetworkAclAttachment(name: string, args: VpcNetworkAclAttachmentArgs, opts?: CustomResourceOptions);
@overload
def VpcNetworkAclAttachment(resource_name: str,
args: VpcNetworkAclAttachmentArgs,
opts: Optional[ResourceOptions] = None)
@overload
def VpcNetworkAclAttachment(resource_name: str,
opts: Optional[ResourceOptions] = None,
network_acl_id: Optional[str] = None,
resource_id: Optional[str] = None,
resource_type: Optional[str] = None)
func NewVpcNetworkAclAttachment(ctx *Context, name string, args VpcNetworkAclAttachmentArgs, opts ...ResourceOption) (*VpcNetworkAclAttachment, error)
public VpcNetworkAclAttachment(string name, VpcNetworkAclAttachmentArgs args, CustomResourceOptions? opts = null)
public VpcNetworkAclAttachment(String name, VpcNetworkAclAttachmentArgs args)
public VpcNetworkAclAttachment(String name, VpcNetworkAclAttachmentArgs args, CustomResourceOptions options)
type: alicloud:vpc:VpcNetworkAclAttachment
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 VpcNetworkAclAttachmentArgs
- 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 VpcNetworkAclAttachmentArgs
- 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 VpcNetworkAclAttachmentArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args VpcNetworkAclAttachmentArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args VpcNetworkAclAttachmentArgs
- 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 vpcNetworkAclAttachmentResource = new AliCloud.Vpc.VpcNetworkAclAttachment("vpcNetworkAclAttachmentResource", new()
{
NetworkAclId = "string",
ResourceId = "string",
ResourceType = "string",
});
example, err := vpc.NewVpcNetworkAclAttachment(ctx, "vpcNetworkAclAttachmentResource", &vpc.VpcNetworkAclAttachmentArgs{
NetworkAclId: pulumi.String("string"),
ResourceId: pulumi.String("string"),
ResourceType: pulumi.String("string"),
})
var vpcNetworkAclAttachmentResource = new VpcNetworkAclAttachment("vpcNetworkAclAttachmentResource", VpcNetworkAclAttachmentArgs.builder()
.networkAclId("string")
.resourceId("string")
.resourceType("string")
.build());
vpc_network_acl_attachment_resource = alicloud.vpc.VpcNetworkAclAttachment("vpcNetworkAclAttachmentResource",
network_acl_id="string",
resource_id="string",
resource_type="string")
const vpcNetworkAclAttachmentResource = new alicloud.vpc.VpcNetworkAclAttachment("vpcNetworkAclAttachmentResource", {
networkAclId: "string",
resourceId: "string",
resourceType: "string",
});
type: alicloud:vpc:VpcNetworkAclAttachment
properties:
networkAclId: string
resourceId: string
resourceType: string
VpcNetworkAclAttachment 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 VpcNetworkAclAttachment resource accepts the following input properties:
- Network
Acl stringId - The ID of the network ACL.
- Resource
Id string - The ID of the associated resource.
- Resource
Type string - The type of the associated resource. Valid values:
VSwitch
.
- Network
Acl stringId - The ID of the network ACL.
- Resource
Id string - The ID of the associated resource.
- Resource
Type string - The type of the associated resource. Valid values:
VSwitch
.
- network
Acl StringId - The ID of the network ACL.
- resource
Id String - The ID of the associated resource.
- resource
Type String - The type of the associated resource. Valid values:
VSwitch
.
- network
Acl stringId - The ID of the network ACL.
- resource
Id string - The ID of the associated resource.
- resource
Type string - The type of the associated resource. Valid values:
VSwitch
.
- network_
acl_ strid - The ID of the network ACL.
- resource_
id str - The ID of the associated resource.
- resource_
type str - The type of the associated resource. Valid values:
VSwitch
.
- network
Acl StringId - The ID of the network ACL.
- resource
Id String - The ID of the associated resource.
- resource
Type String - The type of the associated resource. Valid values:
VSwitch
.
Outputs
All input properties are implicitly available as output properties. Additionally, the VpcNetworkAclAttachment resource produces the following output properties:
Look up Existing VpcNetworkAclAttachment Resource
Get an existing VpcNetworkAclAttachment 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?: VpcNetworkAclAttachmentState, opts?: CustomResourceOptions): VpcNetworkAclAttachment
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
network_acl_id: Optional[str] = None,
resource_id: Optional[str] = None,
resource_type: Optional[str] = None,
status: Optional[str] = None) -> VpcNetworkAclAttachment
func GetVpcNetworkAclAttachment(ctx *Context, name string, id IDInput, state *VpcNetworkAclAttachmentState, opts ...ResourceOption) (*VpcNetworkAclAttachment, error)
public static VpcNetworkAclAttachment Get(string name, Input<string> id, VpcNetworkAclAttachmentState? state, CustomResourceOptions? opts = null)
public static VpcNetworkAclAttachment get(String name, Output<String> id, VpcNetworkAclAttachmentState state, CustomResourceOptions options)
resources: _: type: alicloud:vpc:VpcNetworkAclAttachment get: id: ${id}
- 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.
- Network
Acl stringId - The ID of the network ACL.
- Resource
Id string - The ID of the associated resource.
- Resource
Type string - The type of the associated resource. Valid values:
VSwitch
. - Status string
- The status of the Network Acl Attachment.
- Network
Acl stringId - The ID of the network ACL.
- Resource
Id string - The ID of the associated resource.
- Resource
Type string - The type of the associated resource. Valid values:
VSwitch
. - Status string
- The status of the Network Acl Attachment.
- network
Acl StringId - The ID of the network ACL.
- resource
Id String - The ID of the associated resource.
- resource
Type String - The type of the associated resource. Valid values:
VSwitch
. - status String
- The status of the Network Acl Attachment.
- network
Acl stringId - The ID of the network ACL.
- resource
Id string - The ID of the associated resource.
- resource
Type string - The type of the associated resource. Valid values:
VSwitch
. - status string
- The status of the Network Acl Attachment.
- network_
acl_ strid - The ID of the network ACL.
- resource_
id str - The ID of the associated resource.
- resource_
type str - The type of the associated resource. Valid values:
VSwitch
. - status str
- The status of the Network Acl Attachment.
- network
Acl StringId - The ID of the network ACL.
- resource
Id String - The ID of the associated resource.
- resource
Type String - The type of the associated resource. Valid values:
VSwitch
. - status String
- The status of the Network Acl Attachment.
Import
VPC Network Acl Attachment can be imported using the id, e.g.
$ pulumi import alicloud:vpc/vpcNetworkAclAttachment:VpcNetworkAclAttachment example <network_acl_id>:<resource_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.