-
Notifications
You must be signed in to change notification settings - Fork 0
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
Nadia, OpenTofu, cdk8s #32
Merged
Merged
Changes from 1 commit
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
405e829
Improve OpenTofu support
covracer 2d2cbe8
Expand to multi-file package and add py.typed
covracer 32872e6
Exclude yarn.lock from spell checking
covracer 8664b7c
Drop outdir for now
covracer cfb503d
typo
covracer 496fde0
cdk8s dependencies
covracer e75cfd9
R2 state
covracer 2313263
autoformat
covracer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 @@ | ||
1.8.2 |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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,118 @@ | ||
## Why Write Down Infrastructure? | ||
* Reproducibility | ||
* Automation | ||
* Disaster recovery | ||
|
||
## Why Use Terraform? | ||
* Simplicity | ||
* Wealth of providers | ||
* Good diffing | ||
|
||
## Original CDKTF | ||
```python | ||
#!/usr/bin/env python | ||
|
||
from constructs import Construct | ||
from cdktf import App, TerraformStack | ||
from cdktf_cdktf_provider_docker.image import Image | ||
from cdktf_cdktf_provider_docker.container import Container | ||
from cdktf_cdktf_provider_docker.provider import DockerProvider | ||
|
||
|
||
class MyStack(TerraformStack): | ||
def __init__(self, scope: Construct, ns: str): | ||
super().__init__(scope, ns) | ||
|
||
DockerProvider(self, 'docker') | ||
|
||
docker_image = Image(self, 'nginxImage', | ||
name='nginx:latest', | ||
keep_locally=False) | ||
|
||
Container(self, 'nginxContainer', | ||
name='tutorial', | ||
image=docker_image.name, | ||
ports=[{ | ||
'internal': 80, | ||
'external': 8000 | ||
}]) | ||
|
||
|
||
app = App() | ||
MyStack(app, "learn-cdktf-docker") | ||
|
||
app.synth() | ||
``` | ||
|
||
## Diff from CDKTF to Helicopyter | ||
```diff | ||
--- documentation/learn_cdktf_docker.py 2024-08-05 08:47:30 | ||
+++ documentation/learn_helicopyter_docker.py 2024-08-05 08:47:25 | ||
@@ -1,28 +1,18 @@ | ||
-from cdktf import App, TerraformStack | ||
from cdktf_cdktf_provider_docker.container import Container | ||
from cdktf_cdktf_provider_docker.image import Image | ||
-from cdktf_cdktf_provider_docker.provider import DockerProvider | ||
-from constructs import Construct | ||
+from helicopyter import HeliStack | ||
|
||
-class MyStack(TerraformStack): | ||
- def __init__(self, scope: Construct, ns: str): | ||
- super().__init__(scope, ns) | ||
+def synth(stack: HeliStack): | ||
- | ||
- DockerProvider(self, 'docker') | ||
+ stack.provide('docker') | ||
|
||
- docker_image = Image(self, 'nginxImage', name='nginx:latest', keep_locally=False) | ||
+ docker_image = stack.push(Image, 'nginxImage', name='nginx:latest', keep_locally=False) | ||
|
||
- Container( | ||
- self, | ||
- 'nginxContainer', | ||
- name='tutorial', | ||
- image=docker_image.name, | ||
- ports=[{'internal': 80, 'external': 8000}], | ||
- ) | ||
+ stack.push( | ||
+ Container, | ||
+ 'nginxContainer', | ||
+ name='tutorial', | ||
+ image=docker_image.name, | ||
+ ports=[{'internal': 80, 'external': 8000}], | ||
+ ) | ||
- | ||
- | ||
-app = App() | ||
-MyStack(app, 'learn-cdktf-docker') | ||
- | ||
-app.synth() | ||
``` | ||
|
||
## Helicopyter | ||
```python | ||
from cdktf_cdktf_provider_docker.container import Container | ||
from cdktf_cdktf_provider_docker.image import Image | ||
from helicopyter import HeliStack | ||
|
||
def synth(stack: HeliStack): | ||
stack.provide('docker') | ||
|
||
docker_image = stack.push(Image, 'nginxImage', name='nginx:latest', keep_locally=False) | ||
|
||
stack.push( | ||
Container, | ||
'nginxContainer', | ||
name='tutorial', | ||
image=docker_image.name, | ||
ports=[{'internal': 80, 'external': 8000}], | ||
) | ||
``` | ||
|
||
## Uses | ||
* Containers for Gunicorn web servers and Celery workers | ||
* PostgreSQL database | ||
* Load balancers | ||
* Intranetworking (authenticating proxy) | ||
* Git repository configuration | ||
* Accounts and access to service providers |
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
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
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 |
---|---|---|
|
@@ -5,5 +5,8 @@ | |
}, | ||
"scripts": { | ||
"prettier": "prettier --write" | ||
}, | ||
"dependencies": { | ||
"cdk8s-cli": "^2.198.227" | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Imo this will give us relative pathing issues, depending on where one invokes
python
Can you do something like
pathlib.Path(__file__).parent
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I might not need to specify it. It was mindlessly copied over from cdktf, where it was specified to stop the library from creating an unused directory.