AWS Tools for Windows PowerShell
Command Reference

AWS services or capabilities described in AWS Documentation may vary by region/location. Click Getting Started with Amazon AWS to see specific differences applicable to the China (Beijing) Region.

Synopsis

Calls the Amazon Elastic Compute Cloud (EC2) CreateFlowLogs API operation.

Syntax

New-EC2FlowLog
-LogGroupName <String>
-DeliverCrossAccountRole <String>
-DeliverLogsPermissionArn <String>
-DestinationOptions_FileFormat <DestinationFileFormat>
-DestinationOptions_HiveCompatiblePartition <Boolean>
-LogDestination <String>
-LogDestinationType <LogDestinationType>
-LogFormat <String>
-MaxAggregationInterval <Int32>
-DestinationOptions_PerHourPartition <Boolean>
-ResourceId <String[]>
-ResourceType <FlowLogsResourceType>
-TagSpecification <TagSpecification[]>
-TrafficType <TrafficType>
-ClientToken <String>
-Select <String>
-PassThru <SwitchParameter>
-Force <SwitchParameter>
-ClientConfig <AmazonEC2Config>

Description

Creates one or more flow logs to capture information about IP traffic for a specific network interface, subnet, or VPC. Flow log data for a monitored network interface is recorded as flow log records, which are log events consisting of fields that describe the traffic flow. For more information, see Flow log records in the Amazon Virtual Private Cloud User Guide. When publishing to CloudWatch Logs, flow log records are published to a log group, and each network interface has a unique log stream in the log group. When publishing to Amazon S3, flow log records for all of the monitored network interfaces are published to a single log file object that is stored in the specified bucket. For more information, see VPC Flow Logs in the Amazon Virtual Private Cloud User Guide.

Note: For scripts written against earlier versions of this module this cmdlet can also be invoked with the alias, New-EC2FlowLogs.

Parameters

-ClientConfig <AmazonEC2Config>
Amazon.PowerShell.Cmdlets.EC2.AmazonEC2ClientCmdlet.ClientConfig
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ClientToken <String>
Unique, case-sensitive identifier that you provide to ensure the idempotency of the request. For more information, see How to ensure idempotency.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-DeliverCrossAccountRole <String>
The ARN of the IAM role that allows Amazon EC2 to publish flow logs across accounts.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-DeliverLogsPermissionArn <String>
The ARN of the IAM role that allows Amazon EC2 to publish flow logs to the log destination.This parameter is required if the destination type is cloud-watch-logs, or if the destination type is kinesis-data-firehose and the delivery stream and the resources to monitor are in different accounts.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-DestinationOptions_FileFormat <DestinationFileFormat>
The format for the flow log. The default is plain-text.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-DestinationOptions_HiveCompatiblePartition <Boolean>
Indicates whether to use Hive-compatible prefixes for flow logs stored in Amazon S3. The default is false.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesDestinationOptions_HiveCompatiblePartitions
-DestinationOptions_PerHourPartition <Boolean>
Indicates whether to partition the flow log per hour. This reduces the cost and response time for queries. The default is false.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
This parameter overrides confirmation prompts to force the cmdlet to continue its operation. This parameter should always be used with caution.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LogDestination <String>
The destination for the flow log data. The meaning of this parameter depends on the destination type.
  • If the destination type is cloud-watch-logs, specify the ARN of a CloudWatch Logs log group. For example:arn:aws:logs:region:account_id:log-group:my_groupAlternatively, use the LogGroupName parameter.
  • If the destination type is s3, specify the ARN of an S3 bucket. For example:arn:aws:s3:::my_bucket/my_subfolder/The subfolder is optional. Note that you can't use AWSLogs as a subfolder name.
  • If the destination type is kinesis-data-firehose, specify the ARN of a Kinesis Data Firehose delivery stream. For example:arn:aws:firehose:region:account_id:deliverystream:my_stream
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LogDestinationType <LogDestinationType>
The type of destination for the flow log data.Default: cloud-watch-logs
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LogFormat <String>
The fields to include in the flow log record. List the fields in the order in which they should appear. If you omit this parameter, the flow log is created using the default format. If you specify this parameter, you must include at least one field. For more information about the available fields, see Flow log records in the Amazon VPC User Guide or Transit Gateway Flow Log records in the Amazon Web Services Transit Gateway Guide.Specify the fields using the ${field-id} format, separated by spaces.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-LogGroupName <String>
The name of a new or existing CloudWatch Logs log group where Amazon EC2 publishes your flow logs.This parameter is valid only if the destination type is cloud-watch-logs.
Required?False
Position?1
Accept pipeline input?True (ByValue, ByPropertyName)
-MaxAggregationInterval <Int32>
The maximum interval of time during which a flow of packets is captured and aggregated into a flow log record. The possible values are 60 seconds (1 minute) or 600 seconds (10 minutes). This parameter must be 60 seconds for transit gateway resource types.When a network interface is attached to a Nitro-based instance, the aggregation interval is always 60 seconds or less, regardless of the value that you specify.Default: 600
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-PassThru <SwitchParameter>
Changes the cmdlet behavior to return the value passed to the LogGroupName parameter. The -PassThru parameter is deprecated, use -Select '^LogGroupName' instead. This parameter will be removed in a future version.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-ResourceId <String[]>
The IDs of the resources to monitor. For example, if the resource type is VPC, specify the IDs of the VPCs.Constraints: Maximum of 25 for transit gateway resource types. Maximum of 1000 for the other resource types.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesResourceIds
-ResourceType <FlowLogsResourceType>
The type of resource to monitor.
Required?True
Position?Named
Accept pipeline input?True (ByPropertyName)
-Select <String>
Use the -Select parameter to control the cmdlet output. The default value is '*'. Specifying -Select '*' will result in the cmdlet returning the whole service response (Amazon.EC2.Model.CreateFlowLogsResponse). Specifying the name of a property of type Amazon.EC2.Model.CreateFlowLogsResponse will result in that property being returned. Specifying -Select '^ParameterName' will result in the cmdlet returning the selected cmdlet parameter value.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-TagSpecification <TagSpecification[]>
The tags to apply to the flow logs.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesTagSpecifications
-TrafficType <TrafficType>
The type of traffic to monitor (accepted traffic, rejected traffic, or all traffic). This parameter is not supported for transit gateway resource types. It is required for the other resource types.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)

Common Credential and Region Parameters

-AccessKey <String>
The AWS access key for the user account. This can be a temporary access key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAK
-Credential <AWSCredentials>
An AWSCredentials object instance containing access and secret key information, and optionally a token for session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-EndpointUrl <String>
The endpoint to make the call against.Note: This parameter is primarily for internal AWS use and is not required/should not be specified for normal usage. The cmdlets normally determine which endpoint to call based on the region specified to the -Region parameter or set as default in the shell (via Set-DefaultAWSRegion). Only specify this parameter if you must direct the call to a specific custom endpoint.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
-NetworkCredential <PSCredential>
Used with SAML-based authentication when ProfileName references a SAML role profile. Contains the network credentials to be supplied during authentication with the configured identity provider's endpoint. This parameter is not required if the user's default network identity can or should be used during authentication.
Required?False
Position?Named
Accept pipeline input?True (ByValue, ByPropertyName)
-ProfileLocation <String>
Used to specify the name and location of the ini-format credential file (shared with the AWS CLI and other AWS SDKs)If this optional parameter is omitted this cmdlet will search the encrypted credential file used by the AWS SDK for .NET and AWS Toolkit for Visual Studio first. If the profile is not found then the cmdlet will search in the ini-format credential file at the default location: (user's home directory)\.aws\credentials.If this parameter is specified then this cmdlet will only search the ini-format credential file at the location given.As the current folder can vary in a shell or during script execution it is advised that you use specify a fully qualified path instead of a relative path.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesAWSProfilesLocation, ProfilesLocation
-ProfileName <String>
The user-defined name of an AWS credentials or SAML-based role profile containing credential information. The profile is expected to be found in the secure credential file shared with the AWS SDK for .NET and AWS Toolkit for Visual Studio. You can also specify the name of a profile stored in the .ini-format credential file used with the AWS CLI and other AWS SDKs.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesStoredCredentials, AWSProfileName
-Region <Object>
The system name of an AWS region or an AWSRegion instance. This governs the endpoint that will be used when calling service operations. Note that the AWS resources referenced in a call are usually region-specific.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesRegionToCall
-SecretKey <String>
The AWS secret key for the user account. This can be a temporary secret key if the corresponding session token is supplied to the -SessionToken parameter.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesSK, SecretAccessKey
-SessionToken <String>
The session token if the access and secret keys are temporary session-based credentials.
Required?False
Position?Named
Accept pipeline input?True (ByPropertyName)
AliasesST

Outputs

This cmdlet returns an Amazon.EC2.Model.CreateFlowLogsResponse object containing multiple properties. The object can also be referenced from properties attached to the cmdlet entry in the $AWSHistory stack.

Examples

Example 1

New-EC2FlowLog -ResourceId "subnet-1d234567" -LogDestinationType cloud-watch-logs -LogGroupName subnet1-log -TrafficType "REJECT" -ResourceType Subnet -DeliverLogsPermissionArn "arn:aws:iam::98765432109:role/Admin"

ClientToken FlowLogIds Unsuccessful
----------- ---------- ------------
m1VN2cxP3iB4qo//VUKl5EU6cF7gQLOxcqNefvjeTGw= {fl-012fc34eed5678c9d} {}
This example creates EC2 flowlog for the subnet subnet-1d234567 to the cloud-watch-log named 'subnet1-log' for all 'REJECT' traffic using the perimssions of the 'Admin' role

Supported Version

AWS Tools for PowerShell: 2.x.y.z