Powershell module for Linode – Akamai Connected Cloud
Even though I consider myself as being “platform-agnostic”, I originally come from a Microsoft side of the industry and because of that I had a lot of exposure to PowerShell.
After a relatively steep learning curve, I realized that PowerShell is cool and VERY powerful for some use cases.
Well, as a small side project, I started working on a Powershell module for Akamai Connected Cloud (Linode) platform.
Why? Why not!?
Linode is already known as being VERY developer friendly, why not make it even more friendlier 😀
General idea was to generate a module which will directly talk to the Linode API and eventually expose all platform features via some commandlet.
Besides that, I also wanted to implement some quality of life features which current Linode CLI doesn’t have.
Using the label/name of the resource in your commands.
With the current linode-cli, you need to use the resource ID in all commands which is a bit annoying for some use cases 🙂
With this module, you can use the resource label/name in your commands, and in the background the module will convert the label provided to a resource ID and use that to talk to the API.
Support for multiple Linode accounts and account switching.
I also implemented the possibility to have and switch between multiple different Linode “profiles”.
You can have a profile for your development Linode account, a profile for your test Linode account and switch between them using a single command.
Generate a random password when launching an instance
When you deploy instances with the linode-cli, you need to provide a password for the instance.
Since humans are lazy, we most probably end up using the same password over and over again. This feature will make sure that you always get a secure password generated for your Linode. Of course, you are still free to provide your own password if you like.
Check out the examples below to see how all of these things work.
How to start? It’s really easy! You will be up and running in less than 2 minutes!
Installation
To install the Linode PowerShell module, you need to clone the repository, position yourself into the module folder and import the module:
git clone https://github.com/slepix/LinodePowerShell.git
cd LinodePowerShell
Usage
Before you can use the module, you need to import it using the following command:
Import-Module -Name .\LinodePSModule.psd1
After the module has been imported, you need to configure it and add your Linode account.
Configuration
Configuration is really simple, all you need to do is run ‘Connect-LinodeAccount’ command and follow the configuration wizard.
Connect-LinodeAccount
You can run “Connect-LinodeAccount” command for each Linode account you want to add.
IMPORTANT!!!
When creating a new profile, you will be asked if you want to encrypt your Linode token or not. If you decide to encrypt the token, you won't be able to manually edit the profile file and edit the token.
It is recommended that you use encrypted profile option and recreate a profile if you need to change the token.
User configuration is stored in “$HOME\.LinodePSModule\$name-profile.json“
Check in the examples below how you can switch between different Linode accounts.
NOTE:
You will need Linode API token with the READ/WRITE permissions for all resources in order to get the full functionality of this module.
However, you are free to limit the scope of the API token to suit your security and usage requirements.
Available commands
List of currently available commands can be viewed by running this command
(Get-Module LinodePSModule).ExportedCommands
Example commands
List all currently configured profiles
PS C:\> Get-LinodeProviderProfiles # returns a list of all configured profiles
development
test
Switch to a profile named “test”
PS C:\> Set-LinodeProviderProfile -profile test
Profile test loaded
Get a list of all regions, but only return label, id and status of each region
PS C:\> Get-LinodeRegions | Select label, id, status
label id status
----- -- ------
Mumbai, IN ap-west ok
Toronto, CA ca-central ok
Sydney, AU ap-southeast ok
Washington, DC us-iad ok
Chicago, IL us-ord ok
Paris, FR fr-par ok
Seattle, WA us-sea ok
Sao Paulo, BR br-gru ok
Amsterdam, NL nl-ams ok
Stockholm, SE se-sto ok
Madrid, ES es-mad ok
Chennai, IN in-maa ok
Osaka, JP jp-osa ok
Milan, IT it-mil ok
Miami, FL us-mia ok
Jakarta, ID id-cgk ok
Los Angeles, CA us-lax ok
Dallas, TX us-central ok
Fremont, CA us-west ok
Atlanta, GA us-southeast ok
Newark, NJ us-east ok
London, UK eu-west ok
Singapore, SG ap-south ok
Frankfurt, DE eu-central ok
Tokyo, JP ap-northeast ok
Returns all properties of a single region
PS C:\> Get-LinodeRegion -region nl-ams # list only nl-ams region
id : nl-ams
label : Amsterdam, NL
country : nl
capabilities : {Linodes, Backups, NodeBalancers, Block Storage...}
status : ok
resolvers : @{ipv4=172.233.33.36, 172.233.33.38, 172.233.33.35, 172.233.33.39, 172.233.33.34, 172.233.33.33, 172.233.33.31, 172.233.33.30, 172.233.33.37, 172.233.33.32;
ipv6=2600:3c0e::f03c:93ff:fe9d:2d10, 2600:3c0e::f03c:93ff:fe9d:2d89, 2600:3c0e::f03c:93ff:fe9d:2d79, 2600:3c0e::f03c:93ff:fe9d:2d96, 2600:3c0e::f03c:93ff:fe9d:2da5,
2600:3c0e::f03c:93ff:fe9d:2d34, 2600:3c0e::f03c:93ff:fe9d:2d68, 2600:3c0e::f03c:93ff:fe9d:2d17, 2600:3c0e::f03c:93ff:fe9d:2d45, 2600:3c0e::f03c:93ff:fe9d:2d5c}
placement_group_limits : @{maximum_pgs_per_customer=100; maximum_linodes_per_pg=5}
site_type : core
Create a new Linode named “myInstance” with the instance type of “g6-nanode-1” in nl-ams region and a randomly generated password 25 characters long running Debian 11
PS C:\> New-LinodeInstance -label myInstance -region nl-ams -type g6-nanode-1 -image linode/debian11 -generatepassword -passwordlength 25
id : 60827598
label : myInstance
group :
status : provisioning
created : 2024-06-30T01:23:46
updated : 2024-06-30T01:23:46
type : g6-nanode-1
ipv4 : {172.233.40.46}
ipv6 : 2600:3c0e::f03c:94ff:fe85:29cf/128
image : linode/debian11
region : nl-ams
specs : @{disk=25600; memory=1024; vcpus=1; gpus=0; transfer=1000}
alerts : @{cpu=90; network_in=10; network_out=10; transfer_quota=80; io=10000}
backups : @{enabled=False; available=False; schedule=; last_successful=}
hypervisor : kvm
watchdog_enabled : True
tags : {}
host_uuid : 5f337dda11805445fc391c91e6dcbf45c2a38a21
has_user_data : False
placement_group :
lke_cluster_id :
root_password : eJbd\OQC9ypSagfvTSG@XREV4
Delete a Linode instance
All destructive commands will force you to use “-confirm” flag in order to actually delete a resource.
PS C:\> Remove-LinodeInstance -label myInstance
Please use the -confirm flag in order to delete an instance
PS C:\> Remove-LinodeInstance -label myInstance -confirm
Instance 60827598 deleted
Every other command
Even though each commandlet will ask you for parameters, you can also use ‘Get-Help’ commandlet in order to find out which parameters each command requires.
Example for “New-LinodeVPC” command:
PS /> Get-Help New-LinodeVPC
NAME
New-LinodeVPC
SYNTAX
New-LinodeVPC [[-description] <string>] [[-apiVersion] <string>] [[-label] <string>] [[-token] <string>] [[-region] <string>] [[-subnetlabel] <string>] [[-iprange] <string>] [<CommonParameters>]
ALIASES
None
REMARKS
None
Cool stuff and other quality of life improvements
Compared to Linode’s existing CLI, this module will allow you to specify a label for most of the resources you’re working with. In the background the module will convert the label to the ID of the resource for you.
Example of retrieving an instance details using linode-cli:
Example retrieving an instance details using Linode Powershell module:
PS C:\> Get-Linodeinstance -label blog.dummyserver.net
id : 12374123
label : blog.dummyserver.net
group :
status : running
created : 2024-02-29T17:53:49
updated : 2024-06-29T00:35:47
type : g6-standard-2
ipv4 : {172.123.123.123}
ipv6 : 2600:4c0e::f04c:95ff:fe48:cda4/128
image : linode/ubuntu22.04
region : nl-ams
specs : @{disk=81920; memory=4096; vcpus=2; gpus=0; transfer=4000}
alerts : @{cpu=180; network_in=10; network_out=10; transfer_quota=80; io=10000}
backups : @{enabled=True; available=True; schedule=; last_successful=2024-06-29T00:29:24}
hypervisor : kvm
watchdog_enabled : True
tags : {prod}
host_uuid : 123f8e495e9d51c53df4fa074e5844bce944a068
has_user_data : True
placement_group :
lke_cluster_id :
Development status as of 30.06.2024
Percent complete | 51.35% |
Total API commands: | 368 |
Implemented Powershell commands | 189 |
Development is focused on providing the most important features from the start, so that’s the reason you will see a lot of less important functionalities being implemented halfway or “almost there”.
This is a very active project and my expectation is that in the next few weeks there will be full coverage.
Status of implementation is as follows:
Area | Status | Notes |
---|---|---|
Account | Done | All functionalities besides billing available. |
Beta programs | Done | All functionalities available |
Account availability | Done | All functionalities available |
Child accounts | Not started | None |
Payments | Not started | None |
Entity transfers | Not started | None |
Events | WIP | Everything besides “Mark as read/seen” has been implemented |
Invoices | Done | All functionalities available |
Logins | Done | All functionalities available |
Maintenances | Done | All functionalities available |
Notifications | Done | All functionalities available |
Oauth Clients | Not started | None |
Client thumbnails | Not started | None |
Payment methods | Not started | None |
Promo credits | Not started | None |
Service transfers | Not started | None |
Account settings | Not started | None |
Settings | Not started | None |
Account transfer | Done | All functionalities available. |
Users | Done | Everything besides “Update user’s grant” command is implemented. |
Beta programs | Done | All functionalities available. |
Databases | WIP | MySQL 95% done, PostgreSQL 0%. |
Domains | WIP | All GET commands done, 80% of write commands done. |
Images | Done | All functionalities available. |
Instances | WIP | 60% done. Most important features like VM management are already available |
StackScripts | WIP | 80% done. All “GET” commands available |
LKE | WIP | 95% done. All “GET” commands available |
Longview | WIP | 0% done |
Managed | WIP | 0% done |
Networking | WIP | 80% done. All “GET” commands available |
NodeBalancers | WIP | 80% done. All “GET” commands available |
Object storage | Done | All functionalities available. |
Placement groups | WIP | 0% done |
Profile | WIP | 0% done |
Regions | Done | All functionalities available. |
Support | WIP | 0% done |
Tags | Done | All functionalities available. |
Volumes | WIP | 50% done |
VPC | Done | All functionalities available. |
Roadmap
Since this is a “weekend” project, no dates will be listed here 🙂
Project is under very active development and I’m expecting to finish the first stage in the next few weeks
- Stage 1 < -WE ARE HERE (30.06.2024)
- Full functionality coverage – 45% done
- Stage 2
- Write Pester tests for all functionalities
- Stage 3
- Build test and release pipelines
- Stage 4
- Get a signing certificate & publish to NuGet gallery if project gets enough traction
Contributing
To report a bug or request a feature in the module, please open a GitHub Issue. Will be happy to check it out <3
Have fun with it, please provide feedback (especially around naming commandlets) and until next time 😀
Alex!