BuzzerboyAWSLightsail 0.329.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.
@@ -0,0 +1,191 @@
1
+ Metadata-Version: 2.4
2
+ Name: BuzzerboyAWSLightsail
3
+ Version: 0.329.1
4
+ Summary: Buzzerboy Architecture for Deploying Web Applications on AWS LightSail
5
+ Home-page: https://www.buzzerboy.com/
6
+ Author: Buzzerboy Inc
7
+ Author-email: Buzzerboy Inc <info@buzzerboy.com>
8
+ Project-URL: Homepage, https://www.buzzerboy.com/
9
+ Project-URL: Issues, https://dev.azure.com/buzzerboyinc/buzzerboy
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.8
14
+ Description-Content-Type: text/markdown
15
+ Requires-Dist: cdktf<1.0,>=0.17.0
16
+ Requires-Dist: constructs<11.0,>=10.0.0
17
+ Requires-Dist: cdktf-cdktf-provider-aws>=12.0.0
18
+ Requires-Dist: cdktf-cdktf-provider-random>=8.0.0
19
+ Requires-Dist: toml
20
+ Requires-Dist: pipenv
21
+ Requires-Dist: boto3>=1.26.0
22
+ Requires-Dist: botocore>=1.29.0
23
+ Requires-Dist: BuzzerboyArchetype
24
+ Requires-Dist: AWSArchitectureBase
25
+ Dynamic: author
26
+ Dynamic: home-page
27
+ Dynamic: requires-dist
28
+ Dynamic: requires-python
29
+
30
+ # AWS Infrastructure with CDKTF (Python)
31
+
32
+ This project uses the **Cloud Development Kit for Terraform (CDKTF)** with **Python** to define and deploy AWS infrastructure using named AWS profiles via `~/.aws/credentials` and `~/.aws/config`.
33
+
34
+ ---
35
+
36
+ ## ✅ Prerequisites
37
+
38
+ ### 1. Install Required Tools
39
+
40
+ Make sure the following tools are installed:
41
+
42
+ * **Node.js** (v16 or later)
43
+ * **npm**
44
+ * **Terraform CLI**
45
+ * **Python 3.7+**
46
+ * **AWS CLI**
47
+
48
+ #### macOS Example:
49
+
50
+ ```bash
51
+ brew install node
52
+ brew install terraform
53
+ brew install python
54
+ brew install awscli
55
+ ```
56
+
57
+ ### 2. Install CDKTF CLI
58
+
59
+ ```bash
60
+ npm install -g cdktf-cli
61
+ ```
62
+
63
+ ### 3a. Configure AWS CLI (Option 1 - Use AWS Provided Tooling)
64
+
65
+ ```bash
66
+ aws configure --profile myprofile
67
+ ```
68
+
69
+ This creates or updates the following files:
70
+
71
+ `~/.aws/credentials`:
72
+
73
+ ```ini
74
+ [myprofile]
75
+ aws_access_key_id=YOUR_ACCESS_KEY
76
+ aws_secret_access_key=YOUR_SECRET_KEY
77
+ ```
78
+
79
+ `~/.aws/config`:
80
+
81
+ ```ini
82
+ [profile myprofile]
83
+ region=us-west-2
84
+ output=json
85
+ ```
86
+
87
+
88
+ ### 3b. Configure AWS CLI (Option 2 - Use Open Source AWS Login - Recommended)
89
+
90
+
91
+ #### 3b - 1. Clone the code repo from Fahad Zain Jawaid
92
+ ```bash
93
+ git clone https://github.com/fahadzainjawaid/awsIdentityTools
94
+ ```
95
+
96
+ You can follow the ReadMe on the repo above to get latest usage and setup guides.
97
+
98
+ ---
99
+
100
+ ## 🚀 Getting Started
101
+
102
+ ### 1. Install the package
103
+
104
+ ```bash
105
+ pip install pip install BBAWSLightsailMiniV1a
106
+ ```
107
+
108
+ ### 2. Set Up Python Environment & Install Dependencies
109
+
110
+ ```bash
111
+ python3 -m venv .venv
112
+ source .venv/bin/activate
113
+ export PIPENV_VERBOSITY=-1
114
+ pip install -r requirements.txt
115
+ ```
116
+
117
+ ### 3. Install AWS Provider Bindings
118
+
119
+ ```bash
120
+ cdktf get
121
+ ```
122
+
123
+ ### 4. Synthesize Terraform Configuration
124
+
125
+ ```bash
126
+ cdktf synth
127
+ ```
128
+
129
+ ### 5. Review the Plan
130
+
131
+ ```bash
132
+ cdktf plan
133
+ ```
134
+
135
+ ### 6. Deploy the Infrastructure
136
+
137
+ ```bash
138
+ cdktf deploy
139
+ ```
140
+
141
+ ### 7. Destroy the Infrastructure (if needed)
142
+
143
+ ```bash
144
+ cdktf destroy
145
+ ```
146
+
147
+ ## 🛠 Useful Commands
148
+
149
+ | Command | Description |
150
+ | --------------- | ------------------------------- |
151
+ | `cdktf get` | Install provider bindings |
152
+ | `cdktf synth` | Generate Terraform JSON config |
153
+ | `cdktf plan` | Preview planned changes |
154
+ | `cdktf deploy` | Deploy infrastructure to AWS |
155
+ | `cdktf destroy` | Destroy deployed infrastructure |
156
+
157
+ ---
158
+
159
+ ## 📁 .gitignore Suggestions
160
+
161
+ ```gitignore
162
+ .venv/
163
+ cdktf.out/
164
+ .terraform/
165
+ __pycache__/
166
+ *.pyc
167
+ ```
168
+
169
+ ---
170
+
171
+ ## 📝 Notes
172
+
173
+ * To install additional Python packages:
174
+
175
+ ```bash
176
+ pip install <package>
177
+ pip freeze > requirements.txt
178
+ ```
179
+
180
+ * To suppress pipenv verbosity in environments where pipenv is used:
181
+
182
+ ```bash
183
+ export PIPENV_VERBOSITY=-1
184
+ ```
185
+
186
+ ---
187
+
188
+ ## 📚 References
189
+
190
+ * [CDK for Terraform Documentation](https://developer.hashicorp.com/terraform/cdktf)
191
+ * [AWS Provider Docs](https://registry.terraform.io/providers/hashicorp/aws/latest/docs)
@@ -0,0 +1,16 @@
1
+ MANIFEST.in
2
+ README.md
3
+ pyproject.toml
4
+ requirements.txt
5
+ setup.py
6
+ BuzzerboyAWSLightsail.egg-info/PKG-INFO
7
+ BuzzerboyAWSLightsail.egg-info/SOURCES.txt
8
+ BuzzerboyAWSLightsail.egg-info/dependency_links.txt
9
+ BuzzerboyAWSLightsail.egg-info/requires.txt
10
+ BuzzerboyAWSLightsail.egg-info/top_level.txt
11
+ BuzzerboyAWSLightsailStack/LightSailPostDeploy.py
12
+ BuzzerboyAWSLightsailStack/LightsailAIContainer.py
13
+ BuzzerboyAWSLightsailStack/LightsailBase.py
14
+ BuzzerboyAWSLightsailStack/LightsailContainer.py
15
+ BuzzerboyAWSLightsailStack/LightsailDatabase.py
16
+ BuzzerboyAWSLightsailStack/__init__.py
@@ -0,0 +1,10 @@
1
+ cdktf<1.0,>=0.17.0
2
+ constructs<11.0,>=10.0.0
3
+ cdktf-cdktf-provider-aws>=12.0.0
4
+ cdktf-cdktf-provider-random>=8.0.0
5
+ toml
6
+ pipenv
7
+ boto3>=1.26.0
8
+ botocore>=1.29.0
9
+ BuzzerboyArchetype
10
+ AWSArchitectureBase
@@ -0,0 +1 @@
1
+ BuzzerboyAWSLightsailStack
@@ -0,0 +1,113 @@
1
+
2
+ class LightSailPostDeploy:
3
+
4
+
5
+ #Get container service url from container service
6
+ #update the dns record for each domain to that container service url
7
+
8
+ def __init__(self, domains = [], container_service_name, region, profile="default"):
9
+ self.domains = domains
10
+ self.container_service_name = container_service_name
11
+ self.region = region
12
+ self.profile = profile
13
+ self.container_service_url = self.get_container_service_url()
14
+
15
+ def get_container_service_url(self):
16
+ return LightsailPostDeploy.get_lightsail_domain_from_aws(
17
+ self.container_service_name, self.region, self.profile
18
+ )
19
+
20
+
21
+ @static_method
22
+ def static_execute(domain, container_service_name, region='ca-central-1', profile='default'):
23
+ lightSailDeploy = LightsailPostDeploy(domains=[domain],
24
+ container_service_name=container_service_name, region=region, profile=profile)
25
+ lightSailDeploy.execute()
26
+
27
+ def execute(self):
28
+ for domain in self.domains:
29
+ self.update_dns_record(domain, self.container_service_url)
30
+
31
+ @staticmethod
32
+ def attach_cert_to_container(container_service_name, region, profile="default"):
33
+ """
34
+ Static method to attach SSL certificate to Lightsail container service.
35
+
36
+ :param container_service_name: Name of the container service
37
+ :type container_service_name: str
38
+ :param region: AWS region where the service is deployed
39
+ :type region: str
40
+ :param profile: AWS profile to use (default: "default")
41
+ :type profile: str
42
+ """
43
+ # Implementation for attaching SSL certificate goes here
44
+ import LightSailDomainAttachWrapper
45
+ lightsailWrapper = LightSailDomainAttachWrapper(container_service_name, region, profile)
46
+
47
+
48
+ def update_dns_record(domain, container_service_url):
49
+ print (f"Updating DNS record for {domain} to point to {container_service_url}")
50
+ pass
51
+
52
+ @staticmethod
53
+ def get_lightsail_domain_from_aws(container_service_name, region, profile="default"):
54
+ """
55
+ Static method to retrieve Lightsail container service domain from AWS.
56
+
57
+ This is a utility method that can be called independently to get the actual
58
+ domain name from AWS Lightsail for a given container service.
59
+
60
+ :param container_service_name: Name of the container service
61
+ :type container_service_name: str
62
+ :param region: AWS region where the service is deployed
63
+ :type region: str
64
+ :param profile: AWS profile to use (default: "default")
65
+ :type profile: str
66
+ :returns: The public domain URL ending with amazonlightsail.com
67
+ :rtype: str
68
+
69
+ Example:
70
+ >>> domain = BBAWSLightsailMiniV1a.get_lightsail_domain_from_aws(
71
+ ... "my-app", "us-east-1", "my-profile"
72
+ ... )
73
+ >>> print(domain) # my-app.us-east-1.cs.amazonlightsail.com
74
+ """
75
+ import boto3
76
+ from botocore.exceptions import ClientError
77
+
78
+ try:
79
+ # Create a session with the specified profile
80
+ session = boto3.Session(profile_name=profile)
81
+ lightsail_client = session.client('lightsail', region_name=region)
82
+
83
+ # Get container services
84
+ response = lightsail_client.get_container_services()
85
+
86
+ # Find our container service by name
87
+ for service in response.get('containerServices', []):
88
+ if service.get('containerServiceName') == container_service_name:
89
+ # Get the public domain endpoints
90
+ public_domain_names = service.get('publicDomainNames', {})
91
+
92
+ # Look for the domain that ends with amazonlightsail.com
93
+ for domain_list in public_domain_names.values():
94
+ for domain in domain_list:
95
+ if domain.endswith('amazonlightsail.com'):
96
+ return domain
97
+
98
+ # Fallback: use the URL from container service properties
99
+ url = service.get('url', '')
100
+ if url and 'amazonlightsail.com' in url:
101
+ # Extract domain from URL (remove https://)
102
+ return url.replace('https://', '').replace('http://', '')
103
+
104
+ # If not found, fall back to constructed domain
105
+ print(f"Warning: Could not find actual domain for {container_service_name}")
106
+ return f"{container_service_name}.{region}.cs.amazonlightsail.com"
107
+
108
+ except ClientError as e:
109
+ print(f"Error retrieving Lightsail domain: {e}")
110
+ return f"{container_service_name}.{region}.cs.amazonlightsail.com"
111
+ except Exception as e:
112
+ print(f"Unexpected error: {e}")
113
+ return f"{container_service_name}.{region}.cs.amazonlightsail.com"