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

Moving changes from dev to stage #17

Merged
merged 1 commit into from
Nov 15, 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
14 changes: 11 additions & 3 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,23 @@
"FQDN": "prod.schematic.io",
"CERTIFICATE_ARN": "arn:aws:acm:us-east-1:878654265857:certificate/d11fba3c-1957-48ba-9be0-8b1f460ee970",
"TAGS": {"CostCenter": "NO PROGRAM / 000000"},
"SCHEMATIC_CONTAINER_LOCATION": "ghcr.io/sage-bionetworks/schematic:v0.1.94-beta",
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this deploy to prod on this pr or does it wokr like the previous repo, where pushing to prod branch triggers deploy to prod.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where pushing to prod branch triggers deploy to prod.

That is correct. Only changes deployed to the "prod" branch will be deployed to prod. My thought behind having this configured like this is that ahead of time we could update these values. We can also limit the number of changes that might need to be separate in each long-lived branches to keep them all in sync. Meaning we can always move changes up from dev -> stage -> prod without much thought.

case "stage":
environment_variables = {
"VPC_CIDR": "10.254.193.0/24",
"FQDN": "stage.schematic.io",
"CERTIFICATE_ARN": "arn:aws:acm:us-east-1:878654265857:certificate/d11fba3c-1957-48ba-9be0-8b1f460ee970",
"TAGS": {"CostCenter": "NO PROGRAM / 000000"},
"SCHEMATIC_CONTAINER_LOCATION": "ghcr.io/sage-bionetworks/schematic:v24.11.2-rc",
}
case "dev":
environment_variables = {
"VPC_CIDR": "10.254.192.0/24",
"FQDN": "dev.schematic.io",
"CERTIFICATE_ARN": "arn:aws:acm:us-east-1:631692904429:certificate/0e9682f6-3ffa-46fb-9671-b6349f5164d6",
"TAGS": {"CostCenter": "NO PROGRAM / 000000"},
"SCHEMATIC_CONTAINER_LOCATION": "ghcr.io/sage-bionetworks/schematic:v24.11.2-rc",
}
case _:
valid_envs_str = ",".join(VALID_ENVIRONMENTS)
Expand Down Expand Up @@ -66,7 +69,10 @@
# client service. The services need to be created in this order to prevent an time period when the frontend
# client service is running and available the public, but a backend isn't.
load_balancer_stack = LoadBalancerStack(
cdk_app, f"{stack_name_prefix}-load-balancer", network_stack.vpc
scope=cdk_app,
construct_id=f"{stack_name_prefix}-load-balancer",
vpc=network_stack.vpc,
idle_timeout_seconds=300,
)

telemetry_environment_variables = {
Expand All @@ -80,16 +86,18 @@

app_service_props = ServiceProps(
container_name="schematic-app",
container_location="ghcr.io/sage-bionetworks/schematic:v0.1.94-beta",
container_location=environment_variables["SCHEMATIC_CONTAINER_LOCATION"],
container_port=443,
container_memory=1024,
container_memory=4096,
container_env_vars=telemetry_environment_variables,
container_secrets=[
ServiceSecret(
secret_name=f"{stack_name_prefix}-DockerFargateStack/{environment}/ecs",
environment_key="SECRETS_MANAGER_SECRETS",
)
],
auto_scale_min_capacity=3,
auto_scale_max_capacity=5,
)

app_service_stack = LoadBalancedServiceStack(
Expand Down
13 changes: 11 additions & 2 deletions src/load_balancer_stack.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,20 @@ class LoadBalancerStack(cdk.Stack):
"""

def __init__(
self, scope: Construct, construct_id: str, vpc: ec2.Vpc, **kwargs
self,
scope: Construct,
construct_id: str,
vpc: ec2.Vpc,
idle_timeout_seconds: int,
**kwargs
) -> None:
super().__init__(scope, construct_id, **kwargs)

self.alb = elbv2.ApplicationLoadBalancer(
self, "AppLoadBalancer", vpc=vpc, internet_facing=True
self,
"AppLoadBalancer",
vpc=vpc,
idle_timeout=cdk.Duration.seconds(idle_timeout_seconds),
internet_facing=True,
)
cdk.CfnOutput(self, "dns", value=self.alb.load_balancer_dns_name)
Loading