OCI Network Logging
cloudspells.providers.oci.network_logging
VCN Flow Log observability block for the CloudSpells framework.
Provides VcnFlowLogs, which provisions an OCI Logging Log Group
dedicated to network audit traffic and one VCN Flow Log per subnet tier.
Architecture
A single oci.logging.LogGroup named {stack}-{name}-network-audit is
created as the common container. Up to four oci.logging.Log resources —
one per subnet tier (public, private, secure, management) — are created as
SERVICE logs against the flowlogs OCI service. Each log captures all
accepted and rejected traffic on its subnet.
Secure and management flow logs are created only when those subnets are
present — they may be absent when VcnRef is used and the upstream stack
did not export those subnet IDs.
Retention
Log retention is configurable via retention_duration (default 90 days).
OCI accepts only the discrete values 30, 60, 90, 120, 150, 180;
any other value raises ValueError at construction time.
Exports
VcnFlowLogs
VcnFlowLogs
Bases: BaseResource
VCN Flow Logs for all four subnet tiers collected under one Log Group.
Accepts both a live Vcn and a cross-stack VcnRef. When a Vcn is
supplied, finalize_network is called automatically to materialise
subnets before attaching the flow logs. For a VcnRef the call is a
no-op (the remote stack owns that lifecycle).
Secure and management flow logs are created only when those subnets
exist — they are always present for a Vcn, but may be absent on a
VcnRef if the upstream stack did not export those subnet IDs.
Creates:
- One
oci.logging.LogGroup({stack}-{name}-network-audit). - Two to four
oci.logging.Logresources (one per existing subnet tier) configured as SERVICE logs against the OCIflowlogsservice.
The Log Group OCID is exported as a Pulumi stack output so it can be used as an audit-trail reference by other stacks or compliance tooling.
Attributes:
| Name | Type | Description |
|---|---|---|
log_group |
LogGroup
|
The |
log_group_id |
Output[str]
|
|
public_flow_log |
Log
|
Flow log for the public (LB) subnet. |
private_flow_log |
Log
|
Flow log for the private (App) subnet. |
secure_flow_log |
Log | None
|
Flow log for the secure (DB) subnet, or |
management_flow_log |
Log | None
|
Flow log for the management subnet, or |
Example
vcn = Vcn(name="lab", compartment_id=compartment_id)
flow_logs = VcnFlowLogs(
name="lab", compartment_id=compartment_id, vcn=vcn
) # finalize_network() called automatically
pulumi.export("log_group_id", flow_logs.log_group_id)
Source code in packages/cloudspells-oci/src/cloudspells/providers/oci/network_logging.py
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |
__init__(name: str, compartment_id: pulumi.Input[str], vcn: Vcn | VcnRef, retention_duration: int = 90, stack_name: str | None = None, opts: pulumi.ResourceOptions | None = None) -> None
Provision the network-audit Log Group and per-subnet flow logs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Logical name for this logging component (e.g. |
required |
compartment_id
|
Input[str]
|
OCID of the OCI compartment to deploy into.
Required explicitly because |
required |
vcn
|
Vcn | VcnRef
|
The |
required |
retention_duration
|
int
|
Log retention in days. Accepted values are
|
90
|
stack_name
|
str | None
|
Pulumi stack name. Defaults to
|
None
|
opts
|
ResourceOptions | None
|
Pulumi resource options forwarded to the component. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in packages/cloudspells-oci/src/cloudspells/providers/oci/network_logging.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
export() -> None
Export the network-audit log group OCID as a Pulumi stack output.
Registers network_audit_log_group_id so other stacks and compliance
tooling can reference the log group without duplicating its OCID.
Example
flow_logs = VcnFlowLogs(name="lab", vcn=vcn)
flow_logs.export()
# Stack output: network_audit_log_group_id = ocid1.loggroup...
Source code in packages/cloudspells-oci/src/cloudspells/providers/oci/network_logging.py
235 236 237 238 239 240 241 242 243 244 245 246 247 248 | |