Oracle Cloud Infrastructure (OCI) NSG Python Script is a script that will create a NSG & associated Security Rules in OCI.
It was created to allow for easy creation of NSGs for use with Cloudflare's IP Lists in mind, but could be adapted to do more than just for Cloudflare's IP Lists.
Of couse you could also use Terraform
to perform this automations as well which could be included in the future.
The script can currently create a NSG with the following rules:
- Allow all traffic from Cloudflare IPv4s and/or IPv6s to the TCP HTTP (80) port
- Allow all traffic from Cloudflare IPv4s and/or IPv6s to the TCP HTTPS (443) port
- Allow all traffic from Cloudflare IPv4s and/or IPv6s to the UDP HTTPS (443) port for QUIC/HTTP3
Ensure you have setup your OCI tenancy with the following:
- A VCN with a subnet
- A compartment
- A user with API keys
What things you need to install the software and how to install them.
Python 3.9
A step by step series of examples that tell you how to get a development env running.
Install the required Python modules
pip install -r requirements.txt
Edit the config file with your OCI tenancy details
cp config.example config
Edit the .env file with your OCI VCN/Compartment & environment details
cp .env.example .env
Run the script
python3 main.py
- Add support for multiple VCNs
- Add support for multiple compartments
- Add support for multiple NSGs
- Add support for multiple ports
- Add support for custom ip list from .txt file