BuzzerboyAWSLightsail 0.329.1__tar.gz → 0.331.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsail.egg-info/PKG-INFO +20 -1
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsail.egg-info/SOURCES.txt +1 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsailStack/LightsailBase.py +22 -18
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsailStack/LightsailContainer.py +17 -3
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsailStack/LightsailDatabase.py +117 -38
- buzzerboyawslightsail-0.331.1/LICENSE +17 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/PKG-INFO +20 -1
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/pyproject.toml +1 -1
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsail.egg-info/dependency_links.txt +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsail.egg-info/requires.txt +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsail.egg-info/top_level.txt +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsailStack/LightSailPostDeploy.py +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsailStack/LightsailAIContainer.py +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/BuzzerboyAWSLightsailStack/__init__.py +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/MANIFEST.in +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/README.md +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/requirements.txt +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/setup.cfg +0 -0
- {buzzerboyawslightsail-0.329.1 → buzzerboyawslightsail-0.331.1}/setup.py +0 -0
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: BuzzerboyAWSLightsail
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.331.1
|
|
4
4
|
Summary: Buzzerboy Architecture for Deploying Web Applications on AWS LightSail
|
|
5
5
|
Home-page: https://www.buzzerboy.com/
|
|
6
6
|
Author: Buzzerboy Inc
|
|
7
7
|
Author-email: Buzzerboy Inc <info@buzzerboy.com>
|
|
8
|
+
License: Copyright (c) 2024 Buzzerboy Inc. Canada. All Rights Reserved.
|
|
9
|
+
|
|
10
|
+
This product and associated files (the "Software") is only available for use
|
|
11
|
+
within projects developed by Buzzerboy Inc. Canada with subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
For commercial projects, permission of use is required by sending an email to info@buzzerboy.com
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
8
25
|
Project-URL: Homepage, https://www.buzzerboy.com/
|
|
9
26
|
Project-URL: Issues, https://dev.azure.com/buzzerboyinc/buzzerboy
|
|
10
27
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -12,6 +29,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
12
29
|
Classifier: Operating System :: OS Independent
|
|
13
30
|
Requires-Python: >=3.8
|
|
14
31
|
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
15
33
|
Requires-Dist: cdktf<1.0,>=0.17.0
|
|
16
34
|
Requires-Dist: constructs<11.0,>=10.0.0
|
|
17
35
|
Requires-Dist: cdktf-cdktf-provider-aws>=12.0.0
|
|
@@ -24,6 +42,7 @@ Requires-Dist: BuzzerboyArchetype
|
|
|
24
42
|
Requires-Dist: AWSArchitectureBase
|
|
25
43
|
Dynamic: author
|
|
26
44
|
Dynamic: home-page
|
|
45
|
+
Dynamic: license-file
|
|
27
46
|
Dynamic: requires-dist
|
|
28
47
|
Dynamic: requires-python
|
|
29
48
|
|
|
@@ -79,7 +79,7 @@ class BaseLightsailArchitectureFlags(Enum):
|
|
|
79
79
|
#endregion
|
|
80
80
|
|
|
81
81
|
|
|
82
|
-
class LightsailBase(AWSArchitectureBase
|
|
82
|
+
class LightsailBase(AWSArchitectureBase):
|
|
83
83
|
"""
|
|
84
84
|
Abstract base class for AWS Lightsail Infrastructure Stacks.
|
|
85
85
|
|
|
@@ -126,19 +126,19 @@ class LightsailBase(AWSArchitectureBase, ABC):
|
|
|
126
126
|
# Default post-apply scripts executed after deployment
|
|
127
127
|
default_post_apply_scripts = []
|
|
128
128
|
|
|
129
|
-
|
|
130
|
-
@abstractmethod
|
|
131
|
-
def get_architecture_flags():
|
|
129
|
+
def get_architecture_flags(self):
|
|
132
130
|
"""
|
|
133
131
|
Get the ArchitectureFlags enum for configuration.
|
|
134
|
-
|
|
135
|
-
This method must be implemented by subclasses to return their
|
|
136
|
-
specific ArchitectureFlags enum class.
|
|
137
132
|
|
|
138
133
|
:returns: ArchitectureFlags enum class
|
|
139
|
-
:rtype: type[
|
|
134
|
+
:rtype: type[ArchitectureFlags]
|
|
140
135
|
"""
|
|
141
|
-
|
|
136
|
+
super_flags = super.get_architecture_flags()
|
|
137
|
+
this_flags = ArchitectureFlags
|
|
138
|
+
for flag in super_flags:
|
|
139
|
+
this_flags[flag.name] = flag.value
|
|
140
|
+
|
|
141
|
+
return this_flags
|
|
142
142
|
|
|
143
143
|
def __init__(self, scope, id, **kwargs):
|
|
144
144
|
"""
|
|
@@ -575,22 +575,26 @@ class LightsailBase(AWSArchitectureBase, ABC):
|
|
|
575
575
|
if not self.post_apply_scripts:
|
|
576
576
|
return
|
|
577
577
|
|
|
578
|
+
# Collect dependencies for post-apply scripts
|
|
579
|
+
dependencies = []
|
|
580
|
+
if hasattr(self, 'secrets_manager_secret'):
|
|
581
|
+
dependencies.append(self.secrets_manager_secret)
|
|
582
|
+
|
|
578
583
|
# Create a null resource for each post-apply script
|
|
579
584
|
for i, script in enumerate(self.post_apply_scripts):
|
|
580
585
|
script_resource = NullResource(
|
|
581
586
|
self,
|
|
582
587
|
f"post_apply_script_{i}",
|
|
583
|
-
|
|
584
|
-
"local-exec": {
|
|
585
|
-
"command": script,
|
|
586
|
-
"on_failure": "continue"
|
|
587
|
-
}
|
|
588
|
-
}]
|
|
588
|
+
depends_on=dependencies if dependencies else None
|
|
589
589
|
)
|
|
590
590
|
|
|
591
|
-
#
|
|
592
|
-
|
|
593
|
-
|
|
591
|
+
# Add provisioner using override
|
|
592
|
+
script_resource.add_override("provisioner", [{
|
|
593
|
+
"local-exec": {
|
|
594
|
+
"command": script,
|
|
595
|
+
"on_failure": "continue"
|
|
596
|
+
}
|
|
597
|
+
}])
|
|
594
598
|
|
|
595
599
|
# ==================== UTILITY METHODS ====================
|
|
596
600
|
|
|
@@ -66,16 +66,28 @@ from cdktf_cdktf_provider_aws.wafv2_rule_group import Wafv2RuleGroupRuleVisibili
|
|
|
66
66
|
|
|
67
67
|
|
|
68
68
|
#region ArchitectureFlags
|
|
69
|
-
class ArchitectureFlags(
|
|
69
|
+
class ArchitectureFlags(Enum):
|
|
70
70
|
"""
|
|
71
71
|
Architecture configuration flags for optional components.
|
|
72
72
|
|
|
73
|
-
|
|
73
|
+
Includes both base flags and container-specific flags.
|
|
74
74
|
|
|
75
|
+
Base flags:
|
|
76
|
+
:param SKIP_DEFAULT_POST_APPLY_SCRIPTS: Skip default post-apply scripts
|
|
77
|
+
:param PRESERVE_EXISTING_SECRETS: Don't overwrite existing secret versions (smart detection)
|
|
78
|
+
:param IGNORE_SECRET_CHANGES: Ignore all changes to secret after initial creation
|
|
79
|
+
|
|
80
|
+
Container-specific flags:
|
|
75
81
|
:param SKIP_DATABASE: Skip database creation
|
|
76
82
|
:param SKIP_DOMAIN: Skip domain and DNS configuration
|
|
77
83
|
"""
|
|
78
|
-
|
|
84
|
+
|
|
85
|
+
# Base flags from BaseLightsailArchitectureFlags
|
|
86
|
+
SKIP_DEFAULT_POST_APPLY_SCRIPTS = "skip_default_post_apply_scripts"
|
|
87
|
+
PRESERVE_EXISTING_SECRETS = "preserve_existing_secrets"
|
|
88
|
+
IGNORE_SECRET_CHANGES = "ignore_secret_changes"
|
|
89
|
+
|
|
90
|
+
# Container-specific flags
|
|
79
91
|
SKIP_DATABASE = "skip_database"
|
|
80
92
|
SKIP_DOMAIN = "skip_domain"
|
|
81
93
|
|
|
@@ -270,6 +282,8 @@ class LightsailContainerStack(LightsailBase):
|
|
|
270
282
|
"host": self.database.master_endpoint_address,
|
|
271
283
|
"port": self.database.master_endpoint_port,
|
|
272
284
|
}
|
|
285
|
+
)
|
|
286
|
+
|
|
273
287
|
def create_s3_bucket(self, bucket_name=None):
|
|
274
288
|
"""
|
|
275
289
|
Create S3 bucket for application data storage.
|
|
@@ -41,16 +41,33 @@ from cdktf_cdktf_provider_random import password
|
|
|
41
41
|
|
|
42
42
|
#endregion
|
|
43
43
|
|
|
44
|
+
#region Null Provider and Resources
|
|
45
|
+
from cdktf_cdktf_provider_null.resource import Resource as NullResource
|
|
46
|
+
|
|
47
|
+
#endregion
|
|
48
|
+
|
|
44
49
|
#region ArchitectureFlags
|
|
45
|
-
class ArchitectureFlags(
|
|
50
|
+
class ArchitectureFlags(Enum):
|
|
46
51
|
"""
|
|
47
52
|
Architecture configuration flags for optional components.
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
Includes both base flags and database-specific flags.
|
|
50
55
|
|
|
56
|
+
Base flags:
|
|
57
|
+
:param SKIP_DEFAULT_POST_APPLY_SCRIPTS: Skip default post-apply scripts
|
|
58
|
+
:param PRESERVE_EXISTING_SECRETS: Don't overwrite existing secret versions (smart detection)
|
|
59
|
+
:param IGNORE_SECRET_CHANGES: Ignore all changes to secret after initial creation
|
|
60
|
+
|
|
61
|
+
Database-specific flags:
|
|
51
62
|
:param SKIP_DATABASE_USERS: Skip creating individual database users (use master user only)
|
|
52
63
|
"""
|
|
53
|
-
|
|
64
|
+
|
|
65
|
+
# Base flags from BaseLightsailArchitectureFlags
|
|
66
|
+
SKIP_DEFAULT_POST_APPLY_SCRIPTS = "skip_default_post_apply_scripts"
|
|
67
|
+
PRESERVE_EXISTING_SECRETS = "preserve_existing_secrets"
|
|
68
|
+
IGNORE_SECRET_CHANGES = "ignore_secret_changes"
|
|
69
|
+
|
|
70
|
+
# Database-specific flags
|
|
54
71
|
SKIP_DATABASE_USERS = "skip_database_users"
|
|
55
72
|
|
|
56
73
|
#endregion
|
|
@@ -62,8 +79,8 @@ class LightsailDatabaseStack(LightsailBase):
|
|
|
62
79
|
|
|
63
80
|
A comprehensive database stack that deploys:
|
|
64
81
|
* Lightsail Database instance with PostgreSQL
|
|
65
|
-
* Multiple databases within the instance
|
|
66
|
-
* Individual database users with scoped permissions
|
|
82
|
+
* Multiple databases within the instance (automated creation)
|
|
83
|
+
* Individual database users with scoped permissions (automated creation)
|
|
67
84
|
* Secrets Manager for storing all database credentials
|
|
68
85
|
* IAM resources for programmatic access
|
|
69
86
|
|
|
@@ -115,6 +132,7 @@ class LightsailDatabaseStack(LightsailBase):
|
|
|
115
132
|
:param db_instance_size: Database instance size (default: "micro_2_0")
|
|
116
133
|
:param db_engine: Database engine version (default: "postgres_14")
|
|
117
134
|
:param master_username: Master database username (default: "dbmasteruser")
|
|
135
|
+
:param db_publicly_accessible: Enable public access to database (default: True, required for automated provisioning)
|
|
118
136
|
"""
|
|
119
137
|
# Set database-specific defaults
|
|
120
138
|
if "project_name" not in kwargs:
|
|
@@ -124,10 +142,7 @@ class LightsailDatabaseStack(LightsailBase):
|
|
|
124
142
|
environment = kwargs.get("environment", "dev")
|
|
125
143
|
kwargs["secret_name"] = f"{project_name}/{environment}/database-credentials"
|
|
126
144
|
|
|
127
|
-
#
|
|
128
|
-
super().__init__(scope, id, **kwargs)
|
|
129
|
-
|
|
130
|
-
# ===== Database-Specific Configuration =====
|
|
145
|
+
# ===== Database-Specific Configuration (MUST be set before super().__init__) =====
|
|
131
146
|
self.databases = kwargs.get("databases", [])
|
|
132
147
|
|
|
133
148
|
# Validate required parameters
|
|
@@ -138,10 +153,14 @@ class LightsailDatabaseStack(LightsailBase):
|
|
|
138
153
|
self.master_username = kwargs.get("master_username", "dbmasteruser")
|
|
139
154
|
self.db_instance_size = kwargs.get("db_instance_size", "micro_2_0")
|
|
140
155
|
self.db_engine = kwargs.get("db_engine", "postgres_14")
|
|
156
|
+
self.db_publicly_accessible = kwargs.get("db_publicly_accessible", True)
|
|
141
157
|
|
|
142
158
|
# ===== Internal State =====
|
|
143
159
|
self.database_users = {}
|
|
144
160
|
self.database_passwords = {}
|
|
161
|
+
|
|
162
|
+
# Call parent constructor (this will call _set_default_post_apply_scripts)
|
|
163
|
+
super().__init__(scope, id, **kwargs)
|
|
145
164
|
|
|
146
165
|
def _set_default_post_apply_scripts(self):
|
|
147
166
|
"""
|
|
@@ -180,8 +199,9 @@ class LightsailDatabaseStack(LightsailBase):
|
|
|
180
199
|
|
|
181
200
|
Creates:
|
|
182
201
|
* Database passwords for master and individual users
|
|
183
|
-
* Lightsail PostgreSQL database instance
|
|
184
|
-
* Individual
|
|
202
|
+
* Lightsail PostgreSQL database instance (with public access enabled)
|
|
203
|
+
* Individual databases within the instance (automated via SQL)
|
|
204
|
+
* Individual database users with scoped permissions (automated via SQL)
|
|
185
205
|
"""
|
|
186
206
|
# Generate passwords first
|
|
187
207
|
self.create_database_passwords()
|
|
@@ -230,7 +250,13 @@ class LightsailDatabaseStack(LightsailBase):
|
|
|
230
250
|
* Engine: PostgreSQL (version specified by db_engine)
|
|
231
251
|
* Size: Configurable (default: micro_2_0)
|
|
232
252
|
* Master database: Uses first database name from the list
|
|
253
|
+
* Public Access: Configurable (default: True for automated provisioning)
|
|
233
254
|
* Final snapshot: Disabled (skip_final_snapshot=True)
|
|
255
|
+
|
|
256
|
+
.. note::
|
|
257
|
+
Public access is enabled by default to allow automated database creation
|
|
258
|
+
via local-exec provisioners. This can be disabled by setting
|
|
259
|
+
db_publicly_accessible=False, but will require manual database setup.
|
|
234
260
|
"""
|
|
235
261
|
# Use the first database name as the master database name
|
|
236
262
|
master_db_name = self.clean_hyphens(self.databases[0])
|
|
@@ -244,6 +270,7 @@ class LightsailDatabaseStack(LightsailBase):
|
|
|
244
270
|
master_database_name=master_db_name,
|
|
245
271
|
master_username=self.master_username,
|
|
246
272
|
master_password=self.master_password.result,
|
|
273
|
+
publicly_accessible=self.db_publicly_accessible,
|
|
247
274
|
skip_final_snapshot=True,
|
|
248
275
|
tags={
|
|
249
276
|
"Environment": self.environment,
|
|
@@ -269,28 +296,35 @@ class LightsailDatabaseStack(LightsailBase):
|
|
|
269
296
|
|
|
270
297
|
def create_database_users(self):
|
|
271
298
|
"""
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
This method
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
299
|
+
Create individual databases and users within the Lightsail PostgreSQL instance.
|
|
300
|
+
|
|
301
|
+
This method automates the creation of databases and users using SQL commands
|
|
302
|
+
executed via null_resource provisioners. For each database in the databases list:
|
|
303
|
+
1. Generates a password for the database user
|
|
304
|
+
2. Stores credentials in the secrets dictionary
|
|
305
|
+
3. Creates the database (if not the first one - master database)
|
|
306
|
+
4. Creates a dedicated user with the generated password
|
|
307
|
+
5. Grants all privileges on the database to the user
|
|
308
|
+
|
|
309
|
+
**Automated Database Setup:**
|
|
310
|
+
The following operations are performed automatically for each database:
|
|
283
311
|
* CREATE DATABASE {db_name};
|
|
284
312
|
* CREATE USER "{db_name}-dbuser" WITH PASSWORD '{password}';
|
|
285
313
|
* GRANT ALL PRIVILEGES ON DATABASE {db_name} TO "{db_name}-dbuser";
|
|
314
|
+
* GRANT ALL ON SCHEMA public TO "{db_name}-dbuser";
|
|
286
315
|
|
|
287
316
|
.. note::
|
|
288
|
-
|
|
289
|
-
|
|
317
|
+
The first database in the list is created as the master database during
|
|
318
|
+
instance creation, so it's skipped in this automated provisioning process.
|
|
319
|
+
|
|
320
|
+
.. note::
|
|
321
|
+
Requires publicly_accessible=True on the database instance for the
|
|
322
|
+
provisioner to connect from the local machine running Terraform.
|
|
290
323
|
"""
|
|
291
324
|
if ArchitectureFlags.SKIP_DATABASE_USERS.value in self.flags:
|
|
292
325
|
return
|
|
293
326
|
|
|
327
|
+
# Store credentials for all databases
|
|
294
328
|
for db_name in self.databases:
|
|
295
329
|
clean_db_name = self.clean_hyphens(db_name)
|
|
296
330
|
username = f"{clean_db_name}-dbuser"
|
|
@@ -308,22 +342,67 @@ class LightsailDatabaseStack(LightsailBase):
|
|
|
308
342
|
"database": clean_db_name
|
|
309
343
|
}
|
|
310
344
|
|
|
311
|
-
#
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
f"CREATE USER \"{username}\" WITH PASSWORD '<password_from_secrets>';",
|
|
320
|
-
f"GRANT ALL PRIVILEGES ON DATABASE \"{clean_db_name}\" TO \"{username}\";"
|
|
321
|
-
])
|
|
345
|
+
# Skip the first database as it's already created as the master database
|
|
346
|
+
databases_to_create = self.databases[1:] if len(self.databases) > 1 else []
|
|
347
|
+
|
|
348
|
+
# Create additional databases and users using null_resource
|
|
349
|
+
for db_name in databases_to_create:
|
|
350
|
+
clean_db_name = self.clean_hyphens(db_name)
|
|
351
|
+
username = f"{clean_db_name}-dbuser"
|
|
352
|
+
password_ref = self.database_passwords[db_name].result
|
|
322
353
|
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
354
|
+
# SQL commands to create database and user
|
|
355
|
+
# Using environment variables to avoid Terraform interpolation issues
|
|
356
|
+
sql_commands = f"""#!/bin/bash
|
|
357
|
+
set -e
|
|
358
|
+
|
|
359
|
+
echo "Creating database: {clean_db_name}"
|
|
360
|
+
|
|
361
|
+
# Wait for database to be ready (add retry logic)
|
|
362
|
+
for i in {{1..30}}; do
|
|
363
|
+
if PGPASSWORD="$MASTER_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d postgres -c "SELECT 1" > /dev/null 2>&1; then
|
|
364
|
+
echo "Database is ready"
|
|
365
|
+
break
|
|
366
|
+
fi
|
|
367
|
+
echo "Waiting for database to be ready... ($i/30)"
|
|
368
|
+
sleep 10
|
|
369
|
+
done
|
|
370
|
+
|
|
371
|
+
# Create database
|
|
372
|
+
PGPASSWORD="$MASTER_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d postgres -c "CREATE DATABASE \\"{clean_db_name}\\";" || echo "Database {clean_db_name} may already exist"
|
|
373
|
+
|
|
374
|
+
# Create user
|
|
375
|
+
PGPASSWORD="$MASTER_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d postgres -c "CREATE USER \\"{username}\\" WITH PASSWORD '$USER_PASSWORD';" || echo "User {username} may already exist"
|
|
376
|
+
|
|
377
|
+
# Grant database privileges
|
|
378
|
+
PGPASSWORD="$MASTER_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d postgres -c "GRANT ALL PRIVILEGES ON DATABASE \\"{clean_db_name}\\" TO \\"{username}\\";"
|
|
379
|
+
|
|
380
|
+
# Grant schema privileges
|
|
381
|
+
PGPASSWORD="$MASTER_PASSWORD" psql -h "$DB_HOST" -p "$DB_PORT" -U "$DB_USER" -d {clean_db_name} -c "GRANT ALL ON SCHEMA public TO \\"{username}\\";"
|
|
382
|
+
|
|
383
|
+
echo "Successfully created database: {clean_db_name} with user: {username}"
|
|
384
|
+
"""
|
|
385
|
+
|
|
386
|
+
# Create null_resource to execute SQL commands
|
|
387
|
+
db_resource = NullResource(
|
|
388
|
+
self,
|
|
389
|
+
f"create_database_{clean_db_name}",
|
|
390
|
+
depends_on=[self.database]
|
|
326
391
|
)
|
|
392
|
+
|
|
393
|
+
# Add provisioner using override
|
|
394
|
+
db_resource.add_override("provisioner", [{
|
|
395
|
+
"local-exec": {
|
|
396
|
+
"command": sql_commands,
|
|
397
|
+
"environment": {
|
|
398
|
+
"DB_HOST": self.database.master_endpoint_address,
|
|
399
|
+
"DB_PORT": self.database.master_endpoint_port,
|
|
400
|
+
"DB_USER": self.master_username,
|
|
401
|
+
"MASTER_PASSWORD": self.master_password.result,
|
|
402
|
+
"USER_PASSWORD": password_ref,
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
}])
|
|
327
406
|
|
|
328
407
|
def create_outputs(self):
|
|
329
408
|
"""
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Copyright (c) 2024 Buzzerboy Inc. Canada. All Rights Reserved.
|
|
2
|
+
|
|
3
|
+
This product and associated files (the "Software") is only available for use
|
|
4
|
+
within projects developed by Buzzerboy Inc. Canada with subject to the following conditions:
|
|
5
|
+
|
|
6
|
+
The above copyright notice and this permission notice shall be included in all
|
|
7
|
+
copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
For commercial projects, permission of use is required by sending an email to info@buzzerboy.com
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
12
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
13
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
14
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
15
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
16
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
17
|
+
SOFTWARE.
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: BuzzerboyAWSLightsail
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.331.1
|
|
4
4
|
Summary: Buzzerboy Architecture for Deploying Web Applications on AWS LightSail
|
|
5
5
|
Home-page: https://www.buzzerboy.com/
|
|
6
6
|
Author: Buzzerboy Inc
|
|
7
7
|
Author-email: Buzzerboy Inc <info@buzzerboy.com>
|
|
8
|
+
License: Copyright (c) 2024 Buzzerboy Inc. Canada. All Rights Reserved.
|
|
9
|
+
|
|
10
|
+
This product and associated files (the "Software") is only available for use
|
|
11
|
+
within projects developed by Buzzerboy Inc. Canada with subject to the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
For commercial projects, permission of use is required by sending an email to info@buzzerboy.com
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
19
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
20
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
21
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
22
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
23
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
24
|
+
SOFTWARE.
|
|
8
25
|
Project-URL: Homepage, https://www.buzzerboy.com/
|
|
9
26
|
Project-URL: Issues, https://dev.azure.com/buzzerboyinc/buzzerboy
|
|
10
27
|
Classifier: Programming Language :: Python :: 3
|
|
@@ -12,6 +29,7 @@ Classifier: License :: OSI Approved :: MIT License
|
|
|
12
29
|
Classifier: Operating System :: OS Independent
|
|
13
30
|
Requires-Python: >=3.8
|
|
14
31
|
Description-Content-Type: text/markdown
|
|
32
|
+
License-File: LICENSE
|
|
15
33
|
Requires-Dist: cdktf<1.0,>=0.17.0
|
|
16
34
|
Requires-Dist: constructs<11.0,>=10.0.0
|
|
17
35
|
Requires-Dist: cdktf-cdktf-provider-aws>=12.0.0
|
|
@@ -24,6 +42,7 @@ Requires-Dist: BuzzerboyArchetype
|
|
|
24
42
|
Requires-Dist: AWSArchitectureBase
|
|
25
43
|
Dynamic: author
|
|
26
44
|
Dynamic: home-page
|
|
45
|
+
Dynamic: license-file
|
|
27
46
|
Dynamic: requires-dist
|
|
28
47
|
Dynamic: requires-python
|
|
29
48
|
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|