Skip to content

Commit 4cc936e

Browse files
author
Dimy Jeannot
committed
fix: working on infrastructure with Pulumi
1 parent ec68d0d commit 4cc936e

File tree

10 files changed

+320
-0
lines changed

10 files changed

+320
-0
lines changed

go.work

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ use (
2222
./infrastructure/apps/workloads/private/edge/v2alpha/edge-router
2323
./infrastructure/apps/workloads/private/event/v2alpha/event-multiplexer
2424
./infrastructure/apps/workloads/public/mesh/v2alpha/lighthouse
25+
./infrastructure/apps/workloads/public/cryptography/v2alpha/account-authority
2526

2627
// Partner libraries
2728
// ===================================
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"extends": ["../../../../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*"],
4+
"overrides": [
5+
{
6+
"files": ["*.yaml", "*.yml"],
7+
"rules": {}
8+
}
9+
]
10+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
name: workloads-public-cryptography-v2alpha-account-authority
2+
description: An Account Authority
3+
runtime: go
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
#
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
infrastructurev2alphalib "libs/private/go/infrastructure/v2alpha"
6+
)
7+
8+
func cloudinit(key, caCrt, hostCrt, hostKey, version string) string {
9+
_caCrt := infrastructurev2alphalib.WriteIndentedMultilineText(caCrt)
10+
_hostCrt := infrastructurev2alphalib.WriteIndentedMultilineText(hostCrt)
11+
_hostKey := infrastructurev2alphalib.WriteIndentedMultilineText(hostKey)
12+
13+
return fmt.Sprintf(
14+
`#cloud-config
15+
package_update: true
16+
package_upgrade: true
17+
users:
18+
- default
19+
- name: notroot
20+
groups: sudo
21+
sudo:
22+
- ALL=(ALL) NOPASSWD:ALL
23+
shell: /bin/bash
24+
lock_passwd: true
25+
ssh_authorized_keys:
26+
- %s
27+
write_files:
28+
- path: /etc/motd
29+
content: |
30+
Welcome to your Lighthouse!
31+
- content: |
32+
[Unit]
33+
Description=Lighthouse Service
34+
ConditionPathExists=/opt/app
35+
After=network.target
36+
37+
[Service]
38+
Type=simple
39+
User=notroot
40+
Group=notroot
41+
LimitNOFILE=1024
42+
43+
Restart=on-failure
44+
RestartSec=10
45+
startLimitIntervalSec=60
46+
47+
WorkingDirectory=/opt
48+
ExecStart=/opt/app
49+
50+
# make sure log directory exists and owned by syslog
51+
#PermissionsStartOnly=true
52+
#ExecStartPre=/bin/mkdir -p /var/log/app
53+
#ExecStartPre=/bin/chown syslog:adm /var/log/app
54+
#ExecStartPre=/bin/chmod 755 /var/log/app
55+
#SyslogIdentifier=app
56+
57+
[Install]
58+
WantedBy=multi-user.target
59+
path: /lib/systemd/system/lighthouse.service
60+
permissions: '0755'
61+
defer: true
62+
- path: /etc/nebula/ca.crt
63+
content: |
64+
%s
65+
- path: /etc/nebula/host.crt
66+
content: |
67+
%s
68+
- path: /etc/nebula/host.key
69+
content: |
70+
%s
71+
72+
packages:
73+
- polkitd
74+
75+
runcmd:
76+
- sed -i '/PermitRootLogin/d' /etc/ssh/sshd_config
77+
- echo "PermitRootLogin no" >> /etc/ssh/sshd_config
78+
- echo "PasswordAuthentication no" >> /etc/ssh/sshd_config
79+
- echo "ChallengeResponseAuthentication no" >> /etc/ssh/sshd_config
80+
- systemctl restart sshd
81+
- curl -L https://github.com/openecosystems/ecosystem/releases/download/apps-workloads-public-mesh-v2alpha-lighthouse/devel/apps-workloads-public-mesh-v2alpha-lighthouse_%s_Linux_x86_64.tar.gz | tar zx --strip-components=1 --directory /opt
82+
- chmod +x /opt/app
83+
- sudo systemctl enable lighthouse.service
84+
- sudo systemctl start lighthouse.service
85+
86+
`, key, _caCrt, _hostCrt, _hostKey, version)
87+
}
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
module infrastructure/apps/workloads/public/cryptography/v2alpha/account-authority
2+
3+
go 1.23
4+
5+
require (
6+
github.com/dirien/pulumi-vultr/sdk/v2 v2.21.1
7+
github.com/pulumi/pulumi/sdk/v3 v3.137.0
8+
)
9+
10+
require (
11+
dario.cat/mergo v1.0.0 // indirect
12+
github.com/BurntSushi/toml v1.3.2 // indirect
13+
github.com/Microsoft/go-winio v0.6.1 // indirect
14+
github.com/ProtonMail/go-crypto v1.0.0 // indirect
15+
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
16+
github.com/agext/levenshtein v1.2.3 // indirect
17+
github.com/apparentlymart/go-textseg/v13 v13.0.0 // indirect
18+
github.com/atotto/clipboard v0.1.4 // indirect
19+
github.com/aymanbagabas/go-osc52/v2 v2.0.1 // indirect
20+
github.com/blang/semver v3.5.1+incompatible // indirect
21+
github.com/charmbracelet/bubbles v0.16.1 // indirect
22+
github.com/charmbracelet/bubbletea v0.25.0 // indirect
23+
github.com/charmbracelet/lipgloss v0.7.1 // indirect
24+
github.com/cheggaaa/pb v1.0.29 // indirect
25+
github.com/cloudflare/circl v1.3.7 // indirect
26+
github.com/containerd/console v1.0.4-0.20230313162750-1ae8d489ac81 // indirect
27+
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
28+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
29+
github.com/djherbis/times v1.5.0 // indirect
30+
github.com/emirpasic/gods v1.18.1 // indirect
31+
github.com/fatih/color v1.14.1 // indirect
32+
github.com/go-git/gcfg v1.5.1-0.20230307220236-3a3c6141e376 // indirect
33+
github.com/go-git/go-billy/v5 v5.5.0 // indirect
34+
github.com/go-git/go-git/v5 v5.12.0 // indirect
35+
github.com/gogo/protobuf v1.3.2 // indirect
36+
github.com/golang/glog v1.2.1 // indirect
37+
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
38+
github.com/google/uuid v1.6.0 // indirect
39+
github.com/grpc-ecosystem/grpc-opentracing v0.0.0-20180507213350-8e809c8a8645 // indirect
40+
github.com/hashicorp/errwrap v1.1.0 // indirect
41+
github.com/hashicorp/go-multierror v1.1.1 // indirect
42+
github.com/hashicorp/hcl/v2 v2.17.0 // indirect
43+
github.com/inconshreveable/mousetrap v1.1.0 // indirect
44+
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
45+
github.com/kevinburke/ssh_config v1.2.0 // indirect
46+
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
47+
github.com/mattn/go-colorable v0.1.13 // indirect
48+
github.com/mattn/go-isatty v0.0.20 // indirect
49+
github.com/mattn/go-localereader v0.0.1 // indirect
50+
github.com/mattn/go-runewidth v0.0.15 // indirect
51+
github.com/mitchellh/go-ps v1.0.0 // indirect
52+
github.com/mitchellh/go-wordwrap v1.0.1 // indirect
53+
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
54+
github.com/muesli/cancelreader v0.2.2 // indirect
55+
github.com/muesli/reflow v0.3.0 // indirect
56+
github.com/muesli/termenv v0.15.2 // indirect
57+
github.com/opentracing/basictracer-go v1.1.0 // indirect
58+
github.com/opentracing/opentracing-go v1.2.0 // indirect
59+
github.com/pgavlin/fx v0.1.6 // indirect
60+
github.com/pjbgf/sha1cd v0.3.0 // indirect
61+
github.com/pkg/errors v0.9.1 // indirect
62+
github.com/pkg/term v1.1.0 // indirect
63+
github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 // indirect
64+
github.com/pulumi/appdash v0.0.0-20231130102222-75f619a67231 // indirect
65+
github.com/pulumi/esc v0.9.1 // indirect
66+
github.com/rivo/uniseg v0.4.4 // indirect
67+
github.com/rogpeppe/go-internal v1.12.0 // indirect
68+
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 // indirect
69+
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0 // indirect
70+
github.com/sergi/go-diff v1.3.2-0.20230802210424-5b0b94c5c0d3 // indirect
71+
github.com/skeema/knownhosts v1.2.2 // indirect
72+
github.com/spf13/cobra v1.7.0 // indirect
73+
github.com/spf13/pflag v1.0.5 // indirect
74+
github.com/stretchr/objx v0.5.2 // indirect
75+
github.com/texttheater/golang-levenshtein v1.0.1 // indirect
76+
github.com/uber/jaeger-client-go v2.30.0+incompatible // indirect
77+
github.com/uber/jaeger-lib v2.4.1+incompatible // indirect
78+
github.com/xanzy/ssh-agent v0.3.3 // indirect
79+
github.com/zclconf/go-cty v1.13.2 // indirect
80+
go.uber.org/atomic v1.10.0 // indirect
81+
golang.org/x/crypto v0.27.0 // indirect
82+
golang.org/x/exp v0.0.0-20240604190554-fc45aab8b7f8 // indirect
83+
golang.org/x/mod v0.18.0 // indirect
84+
golang.org/x/net v0.29.0 // indirect
85+
golang.org/x/sync v0.8.0 // indirect
86+
golang.org/x/sys v0.25.0 // indirect
87+
golang.org/x/term v0.24.0 // indirect
88+
golang.org/x/text v0.18.0 // indirect
89+
golang.org/x/tools v0.22.0 // indirect
90+
google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect
91+
google.golang.org/grpc v1.66.1 // indirect
92+
google.golang.org/protobuf v1.34.2 // indirect
93+
gopkg.in/warnings.v0 v0.1.2 // indirect
94+
gopkg.in/yaml.v3 v3.0.1 // indirect
95+
lukechampine.com/frand v1.4.2 // indirect
96+
97+
)
Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
package main
2+
3+
import (
4+
"encoding/base64"
5+
"libs/private/go/infrastructure/v2alpha"
6+
"libs/public/go/sdk/v2alpha"
7+
8+
"github.com/dirien/pulumi-vultr/sdk/v2/go/vultr"
9+
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
10+
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
11+
)
12+
13+
func main() {
14+
bounds := []sdkv2alphalib.Binding{}
15+
16+
infrastructure := infrastructurev2alphalib.NewInfrastructure(bounds)
17+
18+
cnf := infrastructure.Config
19+
name := infrastructurev2alphalib.ShortenString(cnf.App.EnvironmentName+"-"+cnf.App.Name, 63)
20+
21+
infrastructure.Run(func(ctx *pulumi.Context) error {
22+
cfg := config.New(ctx, "")
23+
version := cfg.Require("version")
24+
publicKey := cfg.Require("publicKey")
25+
caCrt := cfg.Require("caCrt")
26+
hostCrt := cfg.Require("hostCrt")
27+
hostKey := cfg.Require("hostKey")
28+
29+
script, err := vultr.NewStartupScript(ctx, name, &vultr.StartupScriptArgs{
30+
Name: pulumi.String(name + "-startup-script"),
31+
Script: pulumi.String(base64.StdEncoding.EncodeToString([]byte(cloudinit(publicKey, caCrt, hostCrt, hostKey, version)))),
32+
Type: pulumi.String("boot"),
33+
})
34+
if err != nil {
35+
return err
36+
}
37+
38+
firewallGroup, err := vultr.NewFirewallGroup(ctx, "AccountAuthorityInbound", &vultr.FirewallGroupArgs{
39+
Description: pulumi.String("Account Authority Firewall Group"),
40+
})
41+
if err != nil {
42+
return err
43+
}
44+
45+
_, err = vultr.NewFirewallRule(ctx, "22/tcp", &vultr.FirewallRuleArgs{
46+
FirewallGroupId: firewallGroup.ID(),
47+
Protocol: pulumi.String("tcp"),
48+
IpType: pulumi.String("v4"),
49+
Subnet: pulumi.String("0.0.0.0"),
50+
SubnetSize: pulumi.Int(0),
51+
Port: pulumi.String("22"),
52+
Notes: pulumi.String("22/tcp/v4"),
53+
})
54+
if err != nil {
55+
return err
56+
}
57+
58+
_, err = vultr.NewFirewallRule(ctx, "ICMP", &vultr.FirewallRuleArgs{
59+
FirewallGroupId: firewallGroup.ID(),
60+
Protocol: pulumi.String("icmp"),
61+
IpType: pulumi.String("v4"),
62+
Subnet: pulumi.String("0.0.0.0"),
63+
SubnetSize: pulumi.Int(0),
64+
Notes: pulumi.String("ICMP/v4"),
65+
})
66+
if err != nil {
67+
return err
68+
}
69+
70+
_, err = vultr.NewInstance(ctx, name, &vultr.InstanceArgs{
71+
ActivationEmail: pulumi.Bool(false),
72+
Backups: pulumi.String("enabled"),
73+
BackupsSchedule: &vultr.InstanceBackupsScheduleArgs{
74+
Type: pulumi.String("daily"),
75+
},
76+
DdosProtection: pulumi.Bool(false),
77+
DisablePublicIpv4: pulumi.Bool(false),
78+
EnableIpv6: pulumi.Bool(false),
79+
FirewallGroupId: firewallGroup.ID(),
80+
Hostname: pulumi.String(name),
81+
Label: pulumi.String(name),
82+
OsId: pulumi.Int(2136), // "Debian 12 x64 (bookworm)"
83+
Plan: pulumi.String("vhp-1c-1gb-amd"), // AMD High Performance
84+
Region: pulumi.String("lax"),
85+
ScriptId: script.ID(),
86+
Tags: pulumi.StringArray{
87+
pulumi.String("system:cryptography"),
88+
pulumi.String("language:golang"),
89+
pulumi.String("cycle:public"),
90+
pulumi.String("version:v2alpha"),
91+
},
92+
})
93+
if err != nil {
94+
return err
95+
}
96+
return nil
97+
})
98+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"name": "infrastructure-apps-workloads-public-cryptography-v2alpha-account-authority",
3+
"$schema": "../../../../../../../node_modules/nx/schemas/project-schema.json",
4+
"projectType": "application",
5+
"sourceRoot": "infrastructure/apps/workloads/public/cryptography/v2alpha/account-authority",
6+
"targets": {
7+
8+
},
9+
"tags": [
10+
"type:infrastructure",
11+
"cycle:public",
12+
"language:golang",
13+
"system:cryptography",
14+
"version:v2alpha",
15+
"exposure:internal"
16+
]
17+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
app:
2+
name: 'cryptography-v2alpha-account-authority'
3+
version: 'v2.0.0'
4+
environmentName: 'local-1'
5+
environmentType: 'local'
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
apps/workloads/private/event/v2alpha/event-multiplexer=0.33.1-devel

0 commit comments

Comments
 (0)