I was recently exploring container security monitoring solutions and came across {Falco}: an open-source sys-call based solution. Coupled with an interest in {AWS Cloudformation} templates (infrastructure-as-code), I thought it would be interesting to automate the entire deployment; a one-click solution.
All source material can be found on my Github repo: {container-monitoring-platform-automation}.
The file cloudformation_stack.yaml is pretty much all you need to get started. Head over to the AWS console and upload the YAML file. Fill in appropriate parameters, run and take note of the public IP assigned to the instance. Wait for about 10 minutes and then navigate to instance-public-ip:5601. You should see a Kibana instance with pre-configured indices and dashboards.
This project auto-deploys :
AWS infrastructure
Containerized instances of Elasticsearch and Kibana
Sets up Falco with a Python integration to push alerts to ES
An event-generator container and a custom Kibana dashboard.
More details are in the specifics sections below.
Cloudformation | Infrastructure
Inputs via console
EC2 Instance-type:t2-medium recommended. You will be charged for the instance, however, this instance for a few hours/days is inexpensive. The solution does not work on t2-micro with the little operating memory it has.
IP address to whitelist: The monitoring stack (Kibana) will respond to requests from this IP alone. Enter your public IP address suffixed with a /32.
SSH key-pair name: You should already have one set up to SSH into your EC2-instances. If not, create a pair via console or CLI.
Outputs
A VPC with a (public) subnet, auto-public-IP assignment (non-elastic) and DHCP, Internet Gateway and appropriate route tables.
An EC2 instance of the type specified earlier, launched into the public subnet.
An EBS volume for the EC2-instance - gp2, 8GB.
A security group that allows SSH (TCP/22) and Kibana via HTTP (TCP/5601) and the default all-outbound.
EC2-instance user data. i.e. a shell script that will run on startup that pulls the file {ec2_setup.sh} from the repo and pipes it into bash.
Run the Cloudformation script. Verify that all resources deployed successfully. The output section should display the public IP address of the machine.
User-data and configuration scripts
That script invoked by the user-data command pulls all other necessary files from the repo and sets up all moving parts.
Runs containerized Elasticsearch and Kibana instances.
Runs the Falco service with a custom configuration and a Python integration to ship alerts to the local Elasticsearch store.
Sets up the Kibana index and creates a dashboard via the Kibana API. (Dashboard created and manually exported as a JSON - this file is in the repo.)
Starts the Falco event generator container that triggers Falco rules and creates dummy events for a total of 5 minutes.
The End Result
From a file upload to Kibana dashboards.
Notes:
If you would like to continue running the testbed and/or play with the analytics yourself, simply SSH into the instance with the key pair you specified (user: ec2-user) as a parameter and run: docker run --rm falcosecurity/event-generator run syscall --loop & to run the event-generator.
Falco runs by hooking into system calls made by the container runtime into the kernel. You may choose to run your own containers on the EC2 instance and trigger the rules if you do not prefer the event-generator container.
If the solution isn’t deploying successfully or if you would like to monitor the status, you can view execution logs of EC2 user-data and subsequent scripts in /var/log/cloud-init.log and /var/log/cloud-init-output.log.
To tear down the system after you’re done evaluating, delete the stack from the Cloudformation console and ensure that all the resources were deleted. Leave the default rollback on failure setting checked in the Cloudformation console. An S3 bucket will also be created to store the template, if it doesn’t exist already. You may empty and delete the bucket when done.
I am not affiliated with Falco in any way. This project was out of interest and all opinions are purely my own.