Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

civo vm infra #15

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions platform-wasmcloud/civo/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/bin/
/node_modules/
2 changes: 2 additions & 0 deletions platform-wasmcloud/civo/Pulumi.dev.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
config:
civo:region: lon1
10 changes: 10 additions & 0 deletions platform-wasmcloud/civo/Pulumi.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: platform-poc
runtime:
name: nodejs
options:
packagemanager: pnpm
description: RB Platform PoC - VMs
config:
pulumi:tags:
value:
pulumi:template: typescript
7 changes: 7 additions & 0 deletions platform-wasmcloud/civo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
### Civo infrastructure as code

#### VM network

```bash
pulumi up
```
57 changes: 57 additions & 0 deletions platform-wasmcloud/civo/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import * as civo from "@pulumi/civo";
import * as pulumi from "@pulumi/pulumi";
import * as std from "@pulumi/std";

const project = "platform-poc-vm";

const network_label = `${project}-network`;

const network = new civo.Network(project, {
label: network_label,
});

const firewall = new civo.Firewall(project, {
name: `${project}-firewall`,
createDefaultRules: true,
networkId: network.id,
});

const debian = civo.getDiskImage({
filters: [
{
key: "name",
values: ["debian-11"],
},
],
});

const instance1 = new civo.Instance(project, {
hostname: `${project}-instance-1`,
tags: [project],
notes: "Red Badger Platform PoC - instance 1",
firewallId: firewall.id,
networkId: network.id,
size: "g3.xsmall",
diskImage: debian.then((debian) => debian.diskimages?.[0]?.id),
initialUser: "civo",
script: std.file({ input: "./init.sh" }).then((invoke) => invoke.result),
});

export const instanceId = instance1.id;
export const instanceIp = instance1.publicIp;
export const instancePassword = instance1.initialPassword;

// const db = new civo.Database(project, {
// name: `${project}-db`,
// engine: "PostgreSQL",
// version: "14",
// nodes: 1,
// size: "g3.db.xsmall",
// firewallId: firewall.id,
// networkId: network.id,
// });

// export const dbId = db.id;
// export const dbPassword = db.password;
// export const dbUsername = db.username;
// export const dbEndpoint = db.endpoint;
17 changes: 17 additions & 0 deletions platform-wasmcloud/civo/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/bash

# redis
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
sudo chmod 644 /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
sudo apt-get update
sudo apt-get install --yes redis
sudo systemctl start redis

# postgres
sudo apt-get install --yes postgresql postgresql-contrib
sudo systemctl start postgresql@13-main

# wasmCloud
curl -s https://packagecloud.io/install/repositories/wasmcloud/core/script.deb.sh | sudo bash
sudo apt install wash
14 changes: 14 additions & 0 deletions platform-wasmcloud/civo/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "platform-poc",
"main": "index.ts",
"devDependencies": {
"@types/node": "^18",
"typescript": "^5.0.0"
},
"dependencies": {
"@pulumi/civo": "^2.4.2",
"@pulumi/pulumi": "^3.113.0",
"@pulumi/std": "^1.7.3"
},
"packageManager": "[email protected]+sha512.38dc6fba8dba35b39340b9700112c2fe1e12f10b17134715a4aa98ccf7bb035e76fd981cf0bb384dfa98f8d6af5481c2bef2f4266a24bfa20c34eb7147ce0b5e"
}
Loading