Skip to content

Instantly share code, notes, and snippets.

@matt40k
Last active May 5, 2017 11:36
Show Gist options
  • Save matt40k/f5ddb3cb5e3cc9c060f5ec5565ad18de to your computer and use it in GitHub Desktop.
Save matt40k/f5ddb3cb5e3cc9c060f5ec5565ad18de to your computer and use it in GitHub Desktop.
Basic Civo powershell script - https://www.civo.com/
$api_key = 'PUT YOUR API KEY HERE'
$baseApiUrl = 'api.civo.com'
$apiVer = 'v2'
$apiUrl = "https://$baseApiUrl/$apiVer"
$header = @{}
$header.add("Authorization", "bearer $api_key")
#$header.add("Content-Type", "application/json")
$id = "wp-ubuntu"
$name = "wordpress-ubuntu"
$image_id = "ubuntu-16.04"
$short_description = "WordPress (Ubuntu)"
$description = "WordPress (Ubuntu)"
$default_username = "wpusr"
$cloud_config = "#cloud-config
users:
- name: matt
ssh-authorized-keys:
- ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAgEAzYWH/SxikQUyYmO9KQGmzAWhoP2zMAOdAgZfcvjEB2oA1lLAdywQW7rX1SJHBujFmsqkOwl4ESnA1TYhuH5P9rMRc5gaF+4LbhvJ6Vmxw0kzU2CKMdp+wZ5AqJlVFNlhowMI9RTa6I8HfKLZJAkmWqsUJ2tN1ff9wgtImkF4UUtSnjh/I17fGL/rTVxMeYZ84cHmop7RT+UVAlX59TxD5n4LepHsYq1ZoIOUoJ4B7BdzrpltRlTfu1HxlzPWcMy2WA6Uxu5g/iu73onJS0yVpRPVSLpqTrRA8ogtr0lZpea69qNdQy2ndKKjFmQZC4aOJIOCpLRiEw/XDViy5N/a4et/VnDHTllGYTDI8Y6eV71Vy8yOn3oDfD9UpjeTLBBOmjPoKJ4regdEpmkZlvyb0o8lqRmAriehZTmh/+nfc7qAnQm09gLqR7vKxaKua5W/lD2LRmty98Ktx1DgrkmR59gJPoCGasj0//R8x2+CCA6ckGF6ojHdocNVC3lcgp9TW+AVWUDjQUE3S//OFjUfuJwj29RIJw5IoK7nAuDeXYT+OyrYDKs2Gj5CRqQppse92Pj4zfLr9EGWHYmuhUxBY6rhR/eilAPut5gLcHTXwypRtpX/TbhnGyFZWCJsMHrAOwpRzeJUHAS/q1dZLTWorJYSiXi8GTodXOj08e8YaAE= [email protected]
sudo: ['ALL=(ALL) NOPASSWD:ALL']
groups: sudo
shell: /bin/bash
runcmd:
- apt-get update"
$userdata = @{id=$id;name=$name;image_id=$image_id;short_description=$short_description;description=$description;default_username=$default_username;cloud_config=$cloud_config} | ConvertTo-Json
$userdata1 = "id=$id&name=$name&image_id=$image_id&short_description=$short_description&description=$description&default_username=$default_username&cloud_config=$cloud_config"
#$r = Invoke-WebRequest -Uri $apiUrl/templates -Method POST -Headers $header -Body $userdata1
#Write-Host $r.content
$hostname = "test.matt40k.uk"
$size = "g1.xsmall"
$region = "lon1"
$public_ip = "true"
$network_id = "fa1e84a0-9e3d-4292-5d9f-c4fcf44da7cc"
$template = "wp-ubuntu"
$initial_user = "matt"
$ssh_key_id = "e6414ea0-4df7-48cf-62c1-46d3f2261d7b"
$tags = '"Test","WordPress"'
$svr = "hostname=$hostname&size=$size&region=$region&public_ip=$public_ip&network_id=$network_id&template=$template&initial_user=&$initial_user&ssh_key_id=$ssh_key_id&tags=%tags"
Write-Host $svr
$r1 = Invoke-WebRequest -Uri $apiUrl/instances -Method POST -Headers $header -Body $svr
Write-Host $r1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment