flow_logs
Creates, updates, deletes or gets a flow_log resource or lists flow_logs in a region
Overview
| Name | flow_logs |
| Type | Resource |
| Description | Specifies a VPC flow log, which enables you to capture IP traffic for a specific network interface, subnet, or VPC. |
| Id | awscc.ec2.flow_logs |
Fields
- get (all properties)
- list (identifiers only)
| Name | Datatype | Description |
|---|---|---|
id | string | The Flow Log ID |
deliver_cross_account_role | string | The ARN of the IAM role that allows Amazon EC2 to publish flow logs across accounts. |
deliver_logs_permission_arn | string | The ARN for the IAM role that permits Amazon EC2 to publish flow logs to a CloudWatch Logs log group in your account. If you specify LogDestinationType as s3 or kinesis-data-firehose, do not specify DeliverLogsPermissionArn or LogGroupName. |
log_destination | string | Specifies the destination to which the flow log data is to be published. Flow log data can be published to a CloudWatch Logs log group, an Amazon S3 bucket, or a Kinesis Firehose stream. The value specified for this parameter depends on the value specified for LogDestinationType. |
log_destination_type | string | Specifies the type of destination to which the flow log data is to be published. Flow log data can be published to CloudWatch Logs or Amazon S3. |
log_format | string | The fields to include in the flow log record, in the order in which they should appear. |
log_group_name | string | The name of a new or existing CloudWatch Logs log group where Amazon EC2 publishes your flow logs. If you specify LogDestinationType as s3 or kinesis-data-firehose, do not specify DeliverLogsPermissionArn or LogGroupName. |
max_aggregation_interval | integer | The maximum interval of time during which a flow of packets is captured and aggregated into a flow log record. You can specify 60 seconds (1 minute) or 600 seconds (10 minutes). |
resource_id | string | The ID of the subnet, network interface, or VPC for which you want to create a flow log. |
resource_type | string | The type of resource for which to create the flow log. For example, if you specified a VPC ID for the ResourceId property, specify VPC for this property. |
tags | array | The tags to apply to the flow logs. |
traffic_type | string | The type of traffic to log. You can log traffic that the resource accepts or rejects, or all traffic. |
destination_options | object | |
region | string | AWS region. |
| Name | Datatype | Description |
|---|---|---|
id | string | The Flow Log ID |
region | string | AWS region. |
For more information, see AWS::EC2::FlowLog.
Methods
| Name | Resource | Accessible by | Required Params |
|---|---|---|---|
create_resource | flow_logs | INSERT | ResourceType, ResourceId, region |
delete_resource | flow_logs | DELETE | Identifier, region |
update_resource | flow_logs | UPDATE | Identifier, PatchDocument, region |
list_resources | flow_logs_list_only | SELECT | region |
get_resource | flow_logs | SELECT | Identifier, region |
SELECT examples
- get (all properties)
- list (identifiers only)
Gets all properties from an individual flow_log.
SELECT
region,
id,
deliver_cross_account_role,
deliver_logs_permission_arn,
log_destination,
log_destination_type,
log_format,
log_group_name,
max_aggregation_interval,
resource_id,
resource_type,
tags,
traffic_type,
destination_options
FROM awscc.ec2.flow_logs
WHERE
region = 'us-east-1' AND
Identifier = '{{ id }}';
Lists all flow_logs in a region.
SELECT
region,
id
FROM awscc.ec2.flow_logs_list_only
WHERE
region = 'us-east-1';
INSERT example
Use the following StackQL query and manifest file to create a new flow_log resource, using stack-deploy.
- Required Properties
- All Properties
- Manifest
/*+ create */
INSERT INTO awscc.ec2.flow_logs (
ResourceId,
ResourceType,
region
)
SELECT
'{{ resource_id }}',
'{{ resource_type }}',
'{{ region }}';
/*+ create */
INSERT INTO awscc.ec2.flow_logs (
DeliverCrossAccountRole,
DeliverLogsPermissionArn,
LogDestination,
LogDestinationType,
LogFormat,
LogGroupName,
MaxAggregationInterval,
ResourceId,
ResourceType,
Tags,
TrafficType,
DestinationOptions,
region
)
SELECT
'{{ deliver_cross_account_role }}',
'{{ deliver_logs_permission_arn }}',
'{{ log_destination }}',
'{{ log_destination_type }}',
'{{ log_format }}',
'{{ log_group_name }}',
'{{ max_aggregation_interval }}',
'{{ resource_id }}',
'{{ resource_type }}',
'{{ tags }}',
'{{ traffic_type }}',
'{{ destination_options }}',
'{{ region }}';
version: 1
name: stack name
description: stack description
providers:
- aws
globals:
- name: region
value: '{{ vars.AWS_REGION }}'
resources:
- name: flow_log
props:
- name: deliver_cross_account_role
value: '{{ deliver_cross_account_role }}'
- name: deliver_logs_permission_arn
value: '{{ deliver_logs_permission_arn }}'
- name: log_destination
value: '{{ log_destination }}'
- name: log_destination_type
value: '{{ log_destination_type }}'
- name: log_format
value: '{{ log_format }}'
- name: log_group_name
value: '{{ log_group_name }}'
- name: max_aggregation_interval
value: '{{ max_aggregation_interval }}'
- name: resource_id
value: '{{ resource_id }}'
- name: resource_type
value: '{{ resource_type }}'
- name: tags
value:
- key: '{{ key }}'
value: '{{ value }}'
- name: traffic_type
value: '{{ traffic_type }}'
- name: destination_options
value:
file_format: '{{ file_format }}'
hive_compatible_partitions: '{{ hive_compatible_partitions }}'
per_hour_partition: '{{ per_hour_partition }}'
UPDATE example
Use the following StackQL query and manifest file to update a flow_log resource, using stack-deploy.
/*+ update */
UPDATE awscc.ec2.flow_logs
SET PatchDocument = string('{{ {
"Tags": tags
} | generate_patch_document }}')
WHERE
region = '{{ region }}' AND
Identifier = '{{ id }}';
DELETE example
/*+ delete */
DELETE FROM awscc.ec2.flow_logs
WHERE
Identifier = '{{ id }}' AND
region = 'us-east-1';
Permissions
To operate on the flow_logs resource, the following permissions are required:
- Create
- Read
- Update
- Delete
- List
ec2:CreateFlowLogs,
ec2:DescribeFlowLogs,
ec2:CreateTags,
iam:PassRole,
logs:CreateLogDelivery,
s3:GetBucketPolicy,
s3:PutBucketPolicy
ec2:DescribeFlowLogs
ec2:CreateTags,
ec2:DeleteTags,
ec2:DescribeFlowLogs
ec2:DeleteFlowLogs,
ec2:DescribeFlowLogs,
logs:DeleteLogDelivery
ec2:DescribeFlowLogs