analogsea icon indicating copy to clipboard operation
analogsea copied to clipboard

analogsea::firewall_create doesnt work anymore

Open Sade154 opened this issue 1 year ago • 2 comments

I encountered an issue with the example code below provided in the documentation for the firewall_create function.

Code from Documentation:

library(analogsea)
inbound <- list(list(protocol = "tcp", ports = "80", 
                     sources = list(addresses = "18.0.0.0/8")))
outbound <- list(list(protocol = "tcp", ports = "80", 
                      destinations = list(addresses = "0.0.0.0/0")))
res <- firewall_create("myfirewall", inbound, outbound)
res

Error received:

Error: missing name

Also, the message error is weird as the name is provided in the first argument.

Sade154 avatar Nov 06 '24 10:11 Sade154

I encountered an issue with the example code below provided in the documentation for the firewall_create function.

Code from Documentation:

library(analogsea)
inbound <- list(list(protocol = "tcp", ports = "80", 
                     sources = list(addresses = "18.0.0.0/8")))
outbound <- list(list(protocol = "tcp", ports = "80", 
                      destinations = list(addresses = "0.0.0.0/0")))
res <- firewall_create("myfirewall", inbound, outbound)
res

Error received:

Error: missing name

Also, the message error is weird as the name is provided in the first argument.

this seems to be a change in the API, let me ask Digital Ocean

pachadotdev avatar Nov 07 '24 14:11 pachadotdev

Hello,

same problem here.

if it's of any help, this function works using httr2:

library(httr2)

api_token = "kshjqlf"

create_firewall = function(droplet_ids, firewall_name, authorized_IPs){

Define the request body

body <- list( name = firewall_name, droplet_ids = droplet_ids, inbound_rules = list( # Allowing specific IPs to communicate over SSH list( protocol = "tcp", ports = "22",
sources = list( addresses = authorized_IPs # Add ) ), # Allowing specific IPs to communicate over HTTP list( protocol = "tcp", ports = "80", sources = list( addresses = authorized_IPs ) ), # Allow ICMP for ping list( protocol = "icmp",
sources = list( #addresses = list("0.0.0.0/0") # Allow from all sources or specify your source IP addresses = authorized_IPs ) ) ) )

URL = "https://api.digitalocean.com/v2/firewalls" resp = request(URL) %>% req_headers( "Content-Type" = "application/json", "Authorization" = paste("Bearer", api_token) ) %>% req_body_json(body) |> req_perform() resp$status_code }

stadbern avatar Nov 08 '24 09:11 stadbern