0

Apply a Linode's firewalls

by
Published Oct 17, 2025

Reapply assigned firewalls to a Linode in case they were not applied successfully. The `firewall_apply` event indicates if the firewalls were applied. > --- - __CLI__. ``` linode-cli linodes apply-firewalls 123 ``` [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli) - __OAuth scopes__. ``` linodes:read_write ``` [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)

Script linode Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Linode = {
3
  token: string;
4
};
5
/**
6
 * Apply a Linode's firewalls
7
 * Reapply assigned firewalls to a Linode in case they were not applied successfully.
8

9
The `firewall_apply` event indicates if the firewalls were applied.
10

11

12
>
13

14
---
15

16

17
- __CLI__.
18

19
    ```
20
    linode-cli linodes apply-firewalls 123
21
    ```
22

23
    [Learn more...](https://techdocs.akamai.com/cloud-computing/docs/getting-started-with-the-linode-cli)
24

25
- __OAuth scopes__.
26

27
    ```
28
    linodes:read_write
29
    ```
30

31
    [Learn more...](https://techdocs.akamai.com/linode-api/reference/get-started#oauth)
32
 */
33
export async function main(
34
  auth: Linode,
35
  apiVersion: "v4" | "v4beta",
36
  linodeId: string,
37
) {
38
  const url = new URL(
39
    `https://api.linode.com/${apiVersion}/linode/instances/${linodeId}/firewalls/apply`,
40
  );
41

42
  const response = await fetch(url, {
43
    method: "POST",
44
    headers: {
45
      Authorization: "Bearer " + auth.token,
46
    },
47
    body: undefined,
48
  });
49
  if (!response.ok) {
50
    const text = await response.text();
51
    throw new Error(`${response.status} ${text}`);
52
  }
53
  return await response.json();
54
}
55