forked from xenova/whisper-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ft: use pulumi for infra (network + sql)
- Loading branch information
1 parent
5e57367
commit 3354b15
Showing
7 changed files
with
188 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
local Utils = (import '../utils/config.libsonnet'); | ||
{ | ||
GlobalAddress: { | ||
local this = self, | ||
Config:: Utils.Config, | ||
type: 'gcp:compute:GlobalAddress', | ||
name:: error 'GlobalAddress requires name', | ||
network:: error 'GlobalAddress requires VPC network', | ||
purpose:: error 'GlobalAddress requires purpose', | ||
addressType:: error 'GlobalAddress requires addressType', | ||
prefixLength:: error 'GlobalAddress requires prefixLength', | ||
properties: { | ||
name: 'ip-%s-%s-%s-%s' % [this.Config.Project, this.Config.Env, this.name, this.Config.ShortRegion], | ||
network: this.network, | ||
purpose: this.purpose, | ||
addressType: this.addressType, | ||
prefixLength: this.prefixLength, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
local Utils = (import '../utils/config.libsonnet'); | ||
{ | ||
Router: { | ||
local this = self, | ||
Config:: Utils.Config, | ||
type: 'gcp:compute:Router', | ||
name:: error 'Router name is required', | ||
network:: error 'Router requires VPC network', | ||
properties: { | ||
name: 'router-%s-%s-%s-%s' % [this.Config.Project, this.Config.Env, this.name, this.Config.ShortRegion], | ||
region: this.Config.Region, | ||
network: this.network, | ||
bgp: { | ||
asn: 64569, | ||
}, | ||
}, | ||
}, | ||
Nat: { | ||
local this = self, | ||
Config:: Utils.Config, | ||
name:: error 'NAT name is required', | ||
type: 'gcp:compute:RouterNat', | ||
router:: error 'NAT requires router', | ||
subnets:: [], | ||
properties: { | ||
name: 'nat-%s-%s-%s-%s' % [this.Config.Project, this.Config.Env, this.name, this.Config.ShortRegion], | ||
region: this.Config.Region, | ||
router: this.router, | ||
natIpAllocateOption: 'AUTO_ONLY', | ||
sourceSubnetworkIpRangesToNat: if std.length(this.subnets) > 0 then 'LIST_OF_SUBNETWORKS' else 'ALL_SUBNETWORKS_ALL_IP_RANGES', | ||
logConfig: { | ||
enable: true, | ||
filter: 'ERRORS_ONLY', | ||
}, | ||
subnetworks: [ | ||
{ | ||
name: subnet, | ||
sourceIpRangesToNats: ['ALL_IP_RANGES'], | ||
} | ||
for subnet in this.subnets | ||
], | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
local Utils = (import '../utils/config.libsonnet'); | ||
{ | ||
Connection: { | ||
local this = self, | ||
Config:: Utils.Config, | ||
type: 'gcp:servicenetworking:Connection', | ||
network:: error 'Connection requires VPC network', | ||
service:: 'servicenetworking.googleapis.com', | ||
reservedPeeringRanges:: error 'Connection requires reservedPeeringRanges', | ||
properties: { | ||
network: this.network, | ||
service: this.service, | ||
reservedPeeringRanges: this.reservedPeeringRanges, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
local Utils = (import '../utils/config.libsonnet'); | ||
{ | ||
Subnet: { | ||
local this = self, | ||
Config:: Utils.Config, | ||
type: 'gcp:compute:Subnetwork', | ||
name:: error 'Subnet name is required', | ||
network:: error 'Subnet requires VPC network', | ||
ipCidrRange:: error 'Subnet requires IP CIDR range', | ||
properties: { | ||
name: 'subnet-%s-%s-%s-%s' % [this.Config.Project, this.Config.Env, this.name, this.Config.ShortRegion], | ||
network: this.network, | ||
ipCidrRange: this.ipCidrRange, | ||
secondaryIpRanges: [], | ||
region: this.Config.Region, | ||
description: 'Subnet for the %s' % (this.Config.Project), | ||
privateIpGoogleAccess: true, | ||
purpose: 'PRIVATE', | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
local Utils = (import '../utils/config.libsonnet'); | ||
{ | ||
Vpc: { | ||
local this = self, | ||
Config:: Utils.Config, | ||
type: 'gcp:compute:Network', | ||
name:: error 'Vpc name is required', | ||
properties: { | ||
name: 'vpc-%s-%s-%s' % [this.Config.Project, this.Config.Env, this.name], | ||
autoCreateSubnetworks: false, | ||
description: 'VPC network for the %s' % (this.Config.Project), | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
local Utils = (import '../utils/config.libsonnet'); | ||
{ | ||
Database: { | ||
local this = self, | ||
Config:: Utils.Config, | ||
type: 'gcp:sql:DatabaseInstance', | ||
privateNetwork:: '', | ||
tier:: 'db-g1-small', | ||
name:: error 'DB Instance name must be set', | ||
settings:: {}, | ||
properties: { | ||
name: 'pgsql-%s-%s-%s-%s' % [this.Config.Project, this.Config.Env, this.name, this.Config.ShortRegion], | ||
region: this.Config.Region, | ||
databaseVersion: 'POSTGRES_15', | ||
deletionProtection: true, | ||
settings: { | ||
tier: this.tier, | ||
availabilityType: 'REGIONAL', | ||
diskSize: 20, | ||
ipConfiguration: { | ||
[if this.privateNetwork != '' then 'privateNetwork']: this.privateNetwork, | ||
[if this.privateNetwork != '' then 'enablePrivatePathForGoogleCloudServices']: true, | ||
[if this.privateNetwork == '' then 'ipv4Enabled']: true, | ||
sslMode: 'ENCRYPTED_ONLY', | ||
}, | ||
backupConfiguration: { | ||
enabled: true, | ||
backupRetentionSettings: { | ||
retentionUnit: 'COUNT', | ||
retainedBackups: 7, | ||
}, | ||
pointInTimeRecoveryEnabled: true, | ||
}, | ||
userLabels: { | ||
project: this.Config.Project, | ||
env: this.Config.Env, | ||
region: this.Config.Region, | ||
pulumi: '${pulumi.project}${pulumi.stack}', | ||
}, | ||
} + this.settings, | ||
}, | ||
}, | ||
SqlDB: { | ||
local this = self, | ||
type: 'gcp:sql:Database', | ||
database:: error 'Database name must be set', | ||
instance:: error 'DB Instance must be set', | ||
properties: { | ||
instance: this.instance, | ||
name: this.database, | ||
}, | ||
}, | ||
SqlUser: { | ||
local this = self, | ||
type: 'gcp:sql:User', | ||
name:: error 'User name must be set', | ||
instance:: error 'DB Instance must be set', | ||
password:: error 'Password must be set', | ||
properties: { | ||
instance: this.instance, | ||
name: this.name, | ||
password: this.password, | ||
}, | ||
}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
Config:: { | ||
Project: error 'Config.Project not found', | ||
Env: error 'Config.Env not found', | ||
Region: error 'Config.Region not found', | ||
ShortRegion: '[SHORTREGION]', | ||
}, | ||
} |