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

feat(provisioning-terraform-gcp-database-csql): add initial version of the plugin #293

Merged
merged 10 commits into from
Dec 8, 2023
Merged
10 changes: 5 additions & 5 deletions plugins/provisioning-terraform-gcp-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class TerraformGcpCorePlugin implements AmplicationPlugin {
async afterCreateServer(
context: DsgContext,
eventParams: CreateServerParams,
modules: ModuleMap
modules: ModuleMap,
): Promise<ModuleMap> {
context.logger.info("Generating Terraform Google Cloud Platform Core ...");

Expand Down Expand Up @@ -87,11 +87,11 @@ class TerraformGcpCorePlugin implements AmplicationPlugin {
environmentsConfiguration = JSON.stringify(
settings.environments,
null,
"\t"
"\t",
);
} else {
context.logger.warn(
"TerraformGcpCorePlugin: no environments were passed..."
"TerraformGcpCorePlugin: no environments were passed...",
);
environmentsConfiguration = "{}";
}
Expand All @@ -100,7 +100,7 @@ class TerraformGcpCorePlugin implements AmplicationPlugin {
const staticPath = resolve(__dirname, "./static");
const staticFiles = await context.utils.importStaticModules(
staticPath,
terraformDirectoryPath
terraformDirectoryPath,
);

staticFiles.replaceModulesCode((_path, code) =>
Expand All @@ -111,7 +111,7 @@ class TerraformGcpCorePlugin implements AmplicationPlugin {
.replaceAll(globalDomainKey, settings.global.domain)
.replaceAll(globalRegionPrefixKey, settings.global.region_prefix)
.replaceAll(environmentsKey, environmentsConfiguration)
.replaceAll(backendKey, backendConfiguration)
.replaceAll(backendKey, backendConfiguration),
);

context.logger.info("Generated Terraform Google Cloud Platform Core ...");
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"settings": {
"global": {
"name": "",
"environment": "sandbox",
"team": "development",
"region": "europe-west2",
"zone_suffix": "a",
"availability_type": "ZONAL",
"tier": "db-custom-2-3840",
"disk_size": "10",
"disk_type": "PD_SSD",
"charset": "UTF8",
"collation": "en_US.UTF8",
"deletion_protection": "true",
"version": "POSTGRES_15"
},
"configuration": {
"type": "postgres"
}
},
"systemSettings": {
"requireAuthenticationEntity": "false"
}
}
18 changes: 18 additions & 0 deletions plugins/provisioning-terraform-gcp-database-csql/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": ["../../.eslintrc.json"],
"ignorePatterns": ["!**/*"],
"overrides": [
{
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
"rules": {}
},
{
"files": ["*.ts", "*.tsx"],
"rules": {}
},
{
"files": ["*.js", "*.jsx"],
"rules": {}
}
]
}
36 changes: 36 additions & 0 deletions plugins/provisioning-terraform-gcp-database-csql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Mac/OSX
.DS_Store

# Private Files
*.csv
*.csv.gz
*.tsv
*.tsv.gz
*.xlsx

# Build Files
dist/

# Private Node Modules
node_modules/
creds.js

# VSCode
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

# Local History for Visual Studio Code
.history/

# Common credential files
**/credentials.json
**/client_secrets.json
**/client_secret.json
*creds*
*.dat
*password*
*.httr-oauth*
2 changes: 2 additions & 0 deletions plugins/provisioning-terraform-gcp-database-csql/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.prettierignore
.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
41 changes: 41 additions & 0 deletions plugins/provisioning-terraform-gcp-database-csql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# @amplication/plugin-provisioning-terraform-gcp-database-csql

[![NPM Downloads](https://img.shields.io/npm/dt/@amplication/plugin-provisioning-terraform-gcp-database-csql)](https://www.npmjs.com/package/@amplication/plugin-provisioning-terraform-gcp-database-csql)

Adds a container registry setup based on terraform for Google Cloud Platform to the generated service.

## Purpose

Adds a container registry setup based on terraform for Google Cloud Platform to the generated service.

## Configuration

`name` will determine the name of the database instance, if unset it will default to the name of the generated service.

`environment` used to determine in which project to place the database instance.

`team` used to determine in which project to place the database instance.

`region` determines where the database instance will be hosted.

`zone_suffix` in which gcp zone within the region to place the resource, when a single zone instance is applicable.

`tier` the database instance type/tier, resulting in less or more cpu and memory.

`availability_type` the availability type for the database instance, options are `REGIONAL` or `ZONAL`

`disk_size` the disk size for the database instance.

`disk_type` the disk type for the database instance.

`charset` the database character set.

`collation` the database collation.

`deletion_protection` whether or not to enable deletion protection, preventing easy deletion of the resource.

`version` the version of the database type.

## Usage

It will add a terraform file containing the resources information for the container repository, it is dependant on the `provisioning-terraform-gcp-core` plugin to work.
Loading
Loading