Skip to content

A python script to allow creation of Network Security Groups (NSG) & associated Security Rules in Oracle Cloud Infrastructure (OCI)

License

Notifications You must be signed in to change notification settings

xKhronoz/OCI-NSG-Python-Script

Repository files navigation

OCI NSG Python Script

Table of Contents

About

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

Getting Started

Ensure you have setup your OCI tenancy with the following:

  • A VCN with a subnet
  • A compartment
  • A user with API keys

Prerequisites

What things you need to install the software and how to install them.

Python 3.9

Installing

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

Usage

Run the script

python3 main.py

TODO

  • 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

About

A python script to allow creation of Network Security Groups (NSG) & associated Security Rules in Oracle Cloud Infrastructure (OCI)

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages