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

Use unique app+project configuration for sample apps #1006

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions pkg/k2/language_host/python/samples/fastapi_postgres/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@

# Create the Application instance
app = klotho.Application(
"my-app",
project=os.getenv("PROJECT_NAME", "my-project"), # Default to 'my-project' or the environment variable value
environment=os.getenv("KLOTHO_ENVIRONMENT", "default"), # Default to 'default' or the environment variable value
default_region=os.getenv("AWS_REGION", "us-east-1"), # Default to 'us-east-1' or the environment variable value
"app",
project=os.getenv("PROJECT_NAME", "fastapi_postgres"),
)

# Generate an absolute path to the directory containing the infra.py file /Dockerfile
Expand Down
11 changes: 2 additions & 9 deletions pkg/k2/language_host/python/samples/func/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@

# Create the Application instance
app = klotho.Application(
"my-app",
project=os.getenv(
"PROJECT_NAME", "my-project"
), # Default to 'my-project' or the environment variable value
environment=os.getenv("KLOTHO_ENVIRONMENT", "default"),
# Default to 'default' or the environment variable value
default_region=os.getenv(
"AWS_REGION", "us-west-2"
), # Default to 'us-east-1' or the environment variable value
"app",
project=os.getenv("PROJECT_NAME", "func"),
)

dir = Path(__file__).parent.absolute()
Expand Down
8 changes: 3 additions & 5 deletions pkg/k2/language_host/python/samples/func_dynamo/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@

# Create the Application instance
app = klotho.Application(
"my-dynamo-app",
project=os.getenv("PROJECT_NAME", "my-project"),
environment=os.getenv("KLOTHO_ENVIRONMENT", "default"),
default_region=os.getenv("AWS_REGION", "us-west-2"),
"app",
project=os.getenv("PROJECT_NAME", "func_dynamo"),
)

dir = Path(__file__).parent.absolute()
Expand Down Expand Up @@ -39,4 +37,4 @@
code=str(dir),
)

my_function.bind(dynamodb)
my_function.bind(dynamodb)
20 changes: 18 additions & 2 deletions pkg/k2/language_host/python/samples/starter/infra-api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import infra
import os
from pathlib import Path

import klotho
import klotho.aws as aws

app = klotho.Application(
"api",
project=os.getenv("PROJECT_NAME", "starter"),
)

dir = Path(__file__).parent.absolute()

container = aws.Container(
"my-container",
dockerfile=str(dir / "Dockerfile"),
context=str(dir),
)

api = aws.Api("my-api")
api.route_to("/", infra.container)
api.route_to("/", container)
14 changes: 2 additions & 12 deletions pkg/k2/language_host/python/samples/starter/infra-binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,13 @@
import klotho
import klotho.aws as aws

# Create the Application instance
app = klotho.Application(
"binding-app",
project=os.getenv(
"PROJECT_NAME", "my-project"
), # Default to 'my-project' or the environment variable value
environment=os.getenv("KLOTHO_ENVIRONMENT", "default"),
# Default to 'default' or the environment variable value
default_region=os.getenv(
"AWS_REGION", "us-west-2"
), # Default to 'us-east-1' or the environment variable value
"binding",
project=os.getenv("PROJECT_NAME", "starter"),
)

# Create a Bucket resource
bucket = aws.Bucket("my-bucket", force_destroy=True)

# Create a Container resource with a binding to the Bucket resource
container = aws.Container(
"my-container", dockerfile="Dockerfile", bindings=[bucket.use_read_only()]
)
8 changes: 3 additions & 5 deletions pkg/k2/language_host/python/samples/starter/infra-dynamodb.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@

# Create the Application instance
app = klotho.Application(
"my-dynamo-app",
project=os.getenv("PROJECT_NAME", "my-project"),
environment=os.getenv("KLOTHO_ENVIRONMENT", "default"),
default_region=os.getenv("AWS_REGION", "us-west-2"),
"dynamodb",
project=os.getenv("PROJECT_NAME", "starter"),
)

dir = Path(__file__).parent.absolute()

dynamodb = aws.DynamoDB("my-dynamodb", attributes=[{"Name": "id", "Type": "S"}], hash_key="id")
dynamodb = aws.DynamoDB("my-dynamodb", attributes=[{"Name": "id", "Type": "S"}], hash_key="id")
11 changes: 2 additions & 9 deletions pkg/k2/language_host/python/samples/starter/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,8 @@

# Create the Application instance
app = klotho.Application(
"my-app",
project=os.getenv(
"PROJECT_NAME", "my-project"
), # Default to 'my-project' or the environment variable value
environment=os.getenv("KLOTHO_ENVIRONMENT", "default"),
# Default to 'default' or the environment variable value
default_region=os.getenv(
"AWS_REGION", "us-west-2"
), # Default to 'us-east-1' or the environment variable value
"basic",
project=os.getenv("PROJECT_NAME", "starter"),
)

dir = Path(__file__).parent.absolute()
Expand Down
Loading