Alibaba Cloud

Pulumi Official
Package maintained by Pulumi
v3.28.0 published on Tuesday, Aug 16, 2022 by Pulumi

FlowLog

Provides a VPC Flow Log resource.

For information about VPC Flow log and how to use it, see Flow log overview.

NOTE: Available in v1.117.0+

NOTE: While it uses alicloud.vpc.FlowLog to build a vpc flow log resource, it will be active by default.

Example Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var config = new Config();
        var name = config.Get("name") ?? "terratest_vpc_flow_log";
        var logStoreName = config.Get("logStoreName") ?? "vpc-flow-log-for-vpc";
        var projectName = config.Get("projectName") ?? "vpc-flow-log-for-vpc";
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
        {
            CidrBlock = "192.168.0.0/24",
        });
        var defaultFlowLog = new AliCloud.Vpc.FlowLog("defaultFlowLog", new AliCloud.Vpc.FlowLogArgs
        {
            ResourceId = defaultNetwork.Id,
            ResourceType = "VPC",
            TrafficType = "All",
            LogStoreName = logStoreName,
            ProjectName = projectName,
            FlowLogName = name,
            Status = "Active",
        }, new CustomResourceOptions
        {
            DependsOn = 
            {
                "alicloud_vpc.default",
            },
        });
    }

}
package main

import (
	"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 := "terratest_vpc_flow_log"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		logStoreName := "vpc-flow-log-for-vpc"
		if param := cfg.Get("logStoreName"); param != "" {
			logStoreName = param
		}
		projectName := "vpc-flow-log-for-vpc"
		if param := cfg.Get("projectName"); param != "" {
			projectName = param
		}
		defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
			CidrBlock: pulumi.String("192.168.0.0/24"),
		})
		if err != nil {
			return err
		}
		_, err = vpc.NewFlowLog(ctx, "defaultFlowLog", &vpc.FlowLogArgs{
			ResourceId:   defaultNetwork.ID(),
			ResourceType: pulumi.String("VPC"),
			TrafficType:  pulumi.String("All"),
			LogStoreName: pulumi.String(logStoreName),
			ProjectName:  pulumi.String(projectName),
			FlowLogName:  pulumi.String(name),
			Status:       pulumi.String("Active"),
		}, pulumi.DependsOn([]pulumi.Resource{
			pulumi.Resource("alicloud_vpc.default"),
		}))
		if err != nil {
			return err
		}
		return nil
	})
}
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.FlowLog;
import com.pulumi.alicloud.vpc.FlowLogArgs;
import com.pulumi.resources.CustomResourceOptions;
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("terratest_vpc_flow_log");
        final var logStoreName = config.get("logStoreName").orElse("vpc-flow-log-for-vpc");
        final var projectName = config.get("projectName").orElse("vpc-flow-log-for-vpc");
        var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
            .cidrBlock("192.168.0.0/24")
            .build());

        var defaultFlowLog = new FlowLog("defaultFlowLog", FlowLogArgs.builder()        
            .resourceId(defaultNetwork.id())
            .resourceType("VPC")
            .trafficType("All")
            .logStoreName(logStoreName)
            .projectName(projectName)
            .flowLogName(name)
            .status("Active")
            .build(), CustomResourceOptions.builder()
                .dependsOn("alicloud_vpc.default")
                .build());

    }
}
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "terratest_vpc_flow_log"
log_store_name = config.get("logStoreName")
if log_store_name is None:
    log_store_name = "vpc-flow-log-for-vpc"
project_name = config.get("projectName")
if project_name is None:
    project_name = "vpc-flow-log-for-vpc"
default_network = alicloud.vpc.Network("defaultNetwork", cidr_block="192.168.0.0/24")
default_flow_log = alicloud.vpc.FlowLog("defaultFlowLog",
    resource_id=default_network.id,
    resource_type="VPC",
    traffic_type="All",
    log_store_name=log_store_name,
    project_name=project_name,
    flow_log_name=name,
    status="Active",
    opts=pulumi.ResourceOptions(depends_on=["alicloud_vpc.default"]))
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "terratest_vpc_flow_log";
const logStoreName = config.get("logStoreName") || "vpc-flow-log-for-vpc";
const projectName = config.get("projectName") || "vpc-flow-log-for-vpc";
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {cidrBlock: "192.168.0.0/24"});
const defaultFlowLog = new alicloud.vpc.FlowLog("defaultFlowLog", {
    resourceId: defaultNetwork.id,
    resourceType: "VPC",
    trafficType: "All",
    logStoreName: logStoreName,
    projectName: projectName,
    flowLogName: name,
    status: "Active",
}, {
    dependsOn: ["alicloud_vpc.default"],
});
configuration:
  name:
    type: string
    default: terratest_vpc_flow_log
  logStoreName:
    type: string
    default: vpc-flow-log-for-vpc
  projectName:
    type: string
    default: vpc-flow-log-for-vpc
resources:
  defaultNetwork:
    type: alicloud:vpc:Network
    properties:
      cidrBlock: 192.168.0.0/24
  defaultFlowLog:
    type: alicloud:vpc:FlowLog
    properties:
      resourceId: ${defaultNetwork.id}
      resourceType: VPC
      trafficType: All
      logStoreName: ${logStoreName}
      projectName: ${projectName}
      flowLogName: ${name}
      status: Active
    options:
      dependson:
        - alicloud_vpc.default

Create a FlowLog Resource

new FlowLog(name: string, args: FlowLogArgs, opts?: CustomResourceOptions);
@overload
def FlowLog(resource_name: str,
            opts: Optional[ResourceOptions] = None,
            description: Optional[str] = None,
            flow_log_name: Optional[str] = None,
            log_store_name: Optional[str] = None,
            project_name: Optional[str] = None,
            resource_id: Optional[str] = None,
            resource_type: Optional[str] = None,
            status: Optional[str] = None,
            traffic_type: Optional[str] = None)
@overload
def FlowLog(resource_name: str,
            args: FlowLogArgs,
            opts: Optional[ResourceOptions] = None)
func NewFlowLog(ctx *Context, name string, args FlowLogArgs, opts ...ResourceOption) (*FlowLog, error)
public FlowLog(string name, FlowLogArgs args, CustomResourceOptions? opts = null)
public FlowLog(String name, FlowLogArgs args)
public FlowLog(String name, FlowLogArgs args, CustomResourceOptions options)
type: alicloud:vpc:FlowLog
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

name string
The unique name of the resource.
args FlowLogArgs
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 FlowLogArgs
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 FlowLogArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args FlowLogArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name String
The unique name of the resource.
args FlowLogArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

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

LogStoreName string

The name of the logstore.

ProjectName string

The name of the project.

ResourceId string

The ID of the resource.

ResourceType string

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

TrafficType string

The type of traffic collected. Valid values All, Drop and Allow.

Description string

The Description of the VPC Flow Log.

FlowLogName string

The Name of the VPC Flow Log.

Status string

The status of the VPC Flow Log. Valid values Active and Inactive.

LogStoreName string

The name of the logstore.

ProjectName string

The name of the project.

ResourceId string

The ID of the resource.

ResourceType string

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

TrafficType string

The type of traffic collected. Valid values All, Drop and Allow.

Description string

The Description of the VPC Flow Log.

FlowLogName string

The Name of the VPC Flow Log.

Status string

The status of the VPC Flow Log. Valid values Active and Inactive.

logStoreName String

The name of the logstore.

projectName String

The name of the project.

resourceId String

The ID of the resource.

resourceType String

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

trafficType String

The type of traffic collected. Valid values All, Drop and Allow.

description String

The Description of the VPC Flow Log.

flowLogName String

The Name of the VPC Flow Log.

status String

The status of the VPC Flow Log. Valid values Active and Inactive.

logStoreName string

The name of the logstore.

projectName string

The name of the project.

resourceId string

The ID of the resource.

resourceType string

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

trafficType string

The type of traffic collected. Valid values All, Drop and Allow.

description string

The Description of the VPC Flow Log.

flowLogName string

The Name of the VPC Flow Log.

status string

The status of the VPC Flow Log. Valid values Active and Inactive.

log_store_name str

The name of the logstore.

project_name str

The name of the project.

resource_id str

The ID of the resource.

resource_type str

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

traffic_type str

The type of traffic collected. Valid values All, Drop and Allow.

description str

The Description of the VPC Flow Log.

flow_log_name str

The Name of the VPC Flow Log.

status str

The status of the VPC Flow Log. Valid values Active and Inactive.

logStoreName String

The name of the logstore.

projectName String

The name of the project.

resourceId String

The ID of the resource.

resourceType String

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

trafficType String

The type of traffic collected. Valid values All, Drop and Allow.

description String

The Description of the VPC Flow Log.

flowLogName String

The Name of the VPC Flow Log.

status String

The status of the VPC Flow Log. Valid values Active and Inactive.

Outputs

All input properties are implicitly available as output properties. Additionally, the FlowLog 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 an Existing FlowLog Resource

Get an existing FlowLog 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?: FlowLogState, opts?: CustomResourceOptions): FlowLog
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        description: Optional[str] = None,
        flow_log_name: Optional[str] = None,
        log_store_name: Optional[str] = None,
        project_name: Optional[str] = None,
        resource_id: Optional[str] = None,
        resource_type: Optional[str] = None,
        status: Optional[str] = None,
        traffic_type: Optional[str] = None) -> FlowLog
func GetFlowLog(ctx *Context, name string, id IDInput, state *FlowLogState, opts ...ResourceOption) (*FlowLog, error)
public static FlowLog Get(string name, Input<string> id, FlowLogState? state, CustomResourceOptions? opts = null)
public static FlowLog get(String name, Output<String> id, FlowLogState 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:
Description string

The Description of the VPC Flow Log.

FlowLogName string

The Name of the VPC Flow Log.

LogStoreName string

The name of the logstore.

ProjectName string

The name of the project.

ResourceId string

The ID of the resource.

ResourceType string

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

Status string

The status of the VPC Flow Log. Valid values Active and Inactive.

TrafficType string

The type of traffic collected. Valid values All, Drop and Allow.

Description string

The Description of the VPC Flow Log.

FlowLogName string

The Name of the VPC Flow Log.

LogStoreName string

The name of the logstore.

ProjectName string

The name of the project.

ResourceId string

The ID of the resource.

ResourceType string

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

Status string

The status of the VPC Flow Log. Valid values Active and Inactive.

TrafficType string

The type of traffic collected. Valid values All, Drop and Allow.

description String

The Description of the VPC Flow Log.

flowLogName String

The Name of the VPC Flow Log.

logStoreName String

The name of the logstore.

projectName String

The name of the project.

resourceId String

The ID of the resource.

resourceType String

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

status String

The status of the VPC Flow Log. Valid values Active and Inactive.

trafficType String

The type of traffic collected. Valid values All, Drop and Allow.

description string

The Description of the VPC Flow Log.

flowLogName string

The Name of the VPC Flow Log.

logStoreName string

The name of the logstore.

projectName string

The name of the project.

resourceId string

The ID of the resource.

resourceType string

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

status string

The status of the VPC Flow Log. Valid values Active and Inactive.

trafficType string

The type of traffic collected. Valid values All, Drop and Allow.

description str

The Description of the VPC Flow Log.

flow_log_name str

The Name of the VPC Flow Log.

log_store_name str

The name of the logstore.

project_name str

The name of the project.

resource_id str

The ID of the resource.

resource_type str

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

status str

The status of the VPC Flow Log. Valid values Active and Inactive.

traffic_type str

The type of traffic collected. Valid values All, Drop and Allow.

description String

The Description of the VPC Flow Log.

flowLogName String

The Name of the VPC Flow Log.

logStoreName String

The name of the logstore.

projectName String

The name of the project.

resourceId String

The ID of the resource.

resourceType String

The type of the resource to capture traffic. Valid values NetworkInterface, VPC, and VSwitch.

status String

The status of the VPC Flow Log. Valid values Active and Inactive.

trafficType String

The type of traffic collected. Valid values All, Drop and Allow.

Import

VPC Flow Log can be imported using the id, e.g.

 $ pulumi import alicloud:vpc/flowLog:FlowLog example fl-abc123456

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes

This Pulumi package is based on the alicloud Terraform Provider.