This repository has been archived by the owner on Mar 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathAcornfile
160 lines (135 loc) · 4.68 KB
/
Acornfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
name: "MongoDB Atlas Acorn"
description: "Acorn providing a MongoDB Atlas cluster"
readme: "./README.md"
info: localData.info
icon: "./icon.png"
args: {
// Cloud provider
provider: "AWS"
// Cloud provider region
region: "US_EAST_1"
// Cluster size (only M0 is free). See https://dochub.mongodb.org/core/cluster-tier-atlas for available tiers
tier: "M0"
// If passed this cluster name must exist in Atlas. Defaults to generated name
clusterName: ""
// Database version
dbVersion: "6.0"
// Default database
dbName: "mydb"
// If passed the user must exist in Atlas already. A user will be generated user and created by default.
dbUser: ""
// If passed the user must exist in Atlas already. A user will be generated user and created by default.
dbAdminUser: ""
// Disk size in GB. Ignored for M0, M2, and M5 clusters. Defaults to 10GB for M10+ clusters
diskSizeGB: 10
}
services: atlas: {
generated: job: "create-cluster"
default: true
}
jobs: "create-cluster": {
build: context: "."
env: {
ACORN_EXTERNAL_ID: "@{acorn.externalID}"
MONGODB_ATLAS_PUBLIC_API_KEY: "secret://atlas-creds/public_key"
MONGODB_ATLAS_PRIVATE_API_KEY: "secret://atlas-creds/private_key"
MONGODB_ATLAS_PROJECT_ID: "secret://atlas-creds/project_id"
PROVIDER: args.provider
REGION: args.region
TIER: args.tier
// Atlas has uniqueness requirements for the first 23 chars in the cluster name, cant use externalID
CLUSTER_NAME: if args.clusterName != "" {args.clusterName} else {"@{acorn.name}-@{acorn.project}-@{acorn.account}"}
DB_VERSION: args.dbVersion
DB_USER: if args.dbUser != "" {args.dbUser} else {"@{acorn.name}-@{acorn.project}-user"}
DB_PASS: "secret://internal-user/token"
DB_NAME: args.dbName
DB_ROOT_USER: if args.dbAdminUser != "" {args.dbAdminUser} else {"@{acorn.name}-@{acorn.project}-root"}
DB_ROOT_PASS: "secret://internal-admin/token"
if (args.tier != "M0" && args.tier != "M2" && args.tier != "M5") {
DISK_SIZE_GB: "\(args.diskSizeGB)"
}
GENERATED_DB_USER: "@{acorn.name}-@{acorn.project}-user"
GENERATED_ROOT_USER: "@{acorn.name}-@{acorn.project}-root"
GENERATED_CLUSTER_NAME: "@{acorn.name}-@{acorn.project}-@{acorn.account}"
}
events: ["create", "update"]
}
jobs: "delete-cluster": {
build: context: "."
dirs: "/acorn/scripts/": "./scripts/"
env: {
ACORN_EXTERNAL_ID: "@{acorn.externalID}"
MONGODB_ATLAS_PUBLIC_API_KEY: "secret://atlas-creds/public_key"
MONGODB_ATLAS_PRIVATE_API_KEY: "secret://atlas-creds/private_key"
MONGODB_ATLAS_PROJECT_ID: "secret://atlas-creds/project_id"
GENERATED_DB_USER: "@{acorn.name}-@{acorn.project}-user"
GENERATED_ROOT_USER: "@{acorn.name}-@{acorn.project}-root"
GENERATED_CLUSTER_NAME: "@{acorn.name}-@{acorn.project}-@{acorn.account}"
}
events: ["delete"]
entrypoint: "/acorn/scripts/delete.sh"
}
secrets: "atlas-creds": {
type: "credential.cloud.mongodb.com/atlas"
params: {
instructions: localData.credInfo
promptOrder: ["public_key", "private_key", "project_id"]
}
data: {
public_key: ""
private_key: ""
project_id: ""
}
}
secrets: admin: {
type: "generated"
params: job: "create-cluster"
}
secrets: "internal-admin": {
name: "password for admin user"
type: "token"
params: {
length: 24
characters: "A-Za-z0-9"
}
}
secrets: user: {
type: "generated"
params: job: "create-cluster"
}
secrets: "internal-user": {
name: "user password"
type: "token"
params: {
length: 24
characters: "A-Za-z0-9"
}
}
localData: info: """
## Usage
services: db: {
image: "ghcr.io/acorn-io/mongodb-atlas:v#.#-#"
}
containers: app: {
image: "app-image"
env: {
DB_HOST: "@{@{service.}db.address}"
DB_PORT: "@{@{service.}db.port.27017}"
DB_NAME: "@{@{service.}db.data.dbName}"
DB_PROTO: "@{@{service.}db.data.proto}"
DB_USER: "@{@{service.}db.secrets.user.username}"
DB_PASS: "@{@{service.}db.secrets.user.password}"
}
}
"""
localData: credInfo: """
## Mongo DB Atlas Setup Instructions
To use this service, you need to supply Mongo Atlas credentials.
We will need:
* Public key
* Private key
* Project ID
You will need to log into Mongo Atlas or [create a new account](https://www.mongodb.com/cloud/atlas/register) to obtain these values.
To learn how to create an API Key on Mongo Atlas, please see:
[https://www.mongodb.com/docs/atlas/configure-api-access/#invite-an-organization-api-key-to-a-project](https://www.mongodb.com/docs/atlas/configure-api-access/#invite-an-organization-api-key-to-a-project)
"""