Egress & Networking
Control outbound network access, expose ports via shares, and manage SSH keys.
Egress policies
Set session egress
from instavm import InstaVM
client = InstaVM('your_api_key')
client.egress.set_session(
allow_package_managers=True,
allow_http=False,
allow_https=True,
allowed_domains=["api.example.com", "github.com"],
allowed_cidrs=["10.0.0.0/8"]
)
Get session egress
policy = client.egress.get_session()
print(f"HTTPS: {policy.get('allow_https')}")
print(f"Domains: {policy.get('allowed_domains', [])}")
Set VM egress
client.egress.set_vm(
vm_id="vm_abc123",
allow_package_managers=True,
allow_https=True,
allow_http=False,
allowed_domains=["api.example.com"]
)
Get VM egress
policy = client.egress.get_vm(vm_id="vm_abc123")
Shares
Expose a port from a running VM to the internet.
Create share
# Share from current session
share = client.shares.create(port=8080, is_public=True)
print(f"URL: {share.get('public_url')}")
# Share from a specific VM
share = client.shares.create(vm_id="vm_abc123", port=3000, is_public=False)
print(f"Token: {share.get('access_token')}")
Update share
# Make public
client.shares.update(share_id="share_def456", is_public=True)
# Revoke
client.shares.update(share_id="share_def456", revoke=True)
SSH key management
Add key
result = client.ssh.add_key(
public_key="ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQC..."
)
print(f"Key ID: {result.get('key_id')}")
List keys
keys = client.ssh.list_keys()
for key in keys:
print(f"{key.get('key_id')}: {key.get('fingerprint')}")
Delete key
client.ssh.delete_key(key_id=123)
Next steps
- Concepts: Egress Policies -- how egress policies work
- Concepts: Shares -- shares and custom domains
- Concepts: SSH -- SSH access details