Reputation: 334
When creating an AWS VPC with Ansible, how to enable VPC Flow Logs?
Upvotes: 3
Views: 1247
Reputation: 56839
You can't do this directly with any of the officially released Ansible modules, but - as with anything that Ansible doesn't directly support - you can just shell out instead.
So if you wanted to enable VPC flow logs you could use the AWS CLI's create-flow-logs
command:
- name: enable vpc flow logs
local_action: shell aws ec2 create-flow-logs --resource-type VPC --resource-ids {{ vpc_id }} --traffic-type ALL --log-group-name {{ vpc_flow_log_group_name }} --deliver-logs-permission-arn {{ vpc_flow_log_iam_role_arn }}
In addition to that, if ansible supports hooks or custom resource triggering, you can also enable VPC flow logs through the CloudFormation or even better using CDK. For more information refer to official doc
Upvotes: 5