Skip to content

Commit

Permalink
Merge pull request #14 from NASA-IMPACT/issue-57/deploy-features-to-prod
Browse files Browse the repository at this point in the history
feat: modify to include bootstrap_qualifier configuration
  • Loading branch information
botanical authored Dec 12, 2024
2 parents 8f1b4e8 + 8edd443 commit f02b4ab
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
9 changes: 7 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from aws_cdk import (
App,
App,
Stack,
Aspects,
aws_iam
)
from constructs import Construct
from constructs import Construct

from config import veda_app_settings
from features_api.infrastructure.construct import FeaturesAPILambdaConstruct
Expand All @@ -14,6 +14,11 @@
from domain.infrastructure.construct import DomainConstruct

app = App()
if veda_app_settings.bootstrap_qualifier:
app.node.set_context(
"@aws-cdk/core:bootstrapQualifier", veda_app_settings.bootstrap_qualifier
)

class VedaStack(Stack):
"""CDK stack for the veda-backend stack."""

Expand Down
25 changes: 15 additions & 10 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from pydantic import Field, StringConstraints
from pydantic_settings import BaseSettings

from typing import Optional, List
from typing import Optional, List

AwsSubnetId=Annotated[str, StringConstraints(pattern=r"^subnet-[a-z0-9]{17}$")]

Expand All @@ -14,15 +14,15 @@ class vedaAppSettings(BaseSettings):
"veda-features-api",
description="Optional app name used to name stack and resources",
)

stage: str = Field(
...,
description=(
"Deployment stage used to name stack and resources, "
"i.e. `dev`, `staging`, `prod`"
),
)

cdk_default_account: Optional[str] = Field(
None,
description="When deploying from a local machine the AWS account id is required to deploy to an exiting VPC",
Expand All @@ -31,25 +31,30 @@ class vedaAppSettings(BaseSettings):
None,
description="When deploying from a local machine the AWS region id is required to deploy to an exiting VPC",
)

vpc_id: Optional[str] = Field(
None,
description=(
"Resource identifier of VPC, if none a new VPC with public and private "
"subnets will be provisioned."
),
)

permissions_boundary_policy_name: Optional[str] = Field(
None,
description="Name of IAM policy to define stack permissions boundary",
)

subnet_ids: Optional[List[AwsSubnetId]] = Field( # type: ignore
[],
description="The subnet ids of subnets associated with the VPC to be used for the database and lambda function.",
)


bootstrap_qualifier: Optional[str] = Field(
None,
description="Custom bootstrap qualifier override if not using a default installation of AWS CDK Toolkit to synthesize app.",
)

def cdk_env(self) -> dict:
"""Load a cdk environment dict for stack"""

Expand All @@ -60,15 +65,15 @@ def cdk_env(self) -> dict:
}
else:
return {}

def stage_name(self) -> str:
"""Force lowercase stage name"""
return self.stage.lower()

class Config:
"""model config."""

env_file = ".env"
extra = "allow"

veda_app_settings = vedaAppSettings()

0 comments on commit f02b4ab

Please sign in to comment.