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

Switch to private NLB with session manager jump host #11

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,5 @@ dmypy.json
deploy/
test/
**/.DS_Store

cdk.out
25 changes: 23 additions & 2 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,10 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
# Creates a security group for AWS RDS
sg_rds = ec2.SecurityGroup(scope=self, id='SGRDS', vpc=vpc, security_group_name='sg_rds')
# Adds an ingress rule which allows resources in the VPC's CIDR to access the database.
sg_rds.add_ingress_rule(peer=ec2.Peer.ipv4('10.0.0.0/24'), connection=ec2.Port.tcp(port))
sg_rds.add_ingress_rule(
peer=ec2.Peer.ipv4(vpc.vpc_cidr_block),
connection=ec2.Port.tcp(port)
)

database = rds.DatabaseInstance(
scope=self,
Expand Down Expand Up @@ -130,7 +133,8 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
id='MLFLOW',
service_name=service_name,
cluster=cluster,
task_definition=task_definition
task_definition=task_definition,
public_load_balancer=False
)

# Setup security group
Expand All @@ -148,10 +152,27 @@ def __init__(self, scope: Construct, id: str, **kwargs) -> None:
scale_in_cooldown=Duration.seconds(60),
scale_out_cooldown=Duration.seconds(60)
)

# ==================================================
# =================== JUMP HOST ======================
# ==================================================
jump = ec2.Instance(self, "JumpHost",
vpc=vpc,
instance_type=ec2.InstanceType.of(ec2.InstanceClass.M5, ec2.InstanceSize.LARGE),
machine_image=ec2.AmazonLinuxImage(
generation=ec2.AmazonLinuxGeneration.AMAZON_LINUX_2
),
block_devices=[ec2.BlockDevice(
device_name= '/dev/xvda',
volume=ec2.BlockDeviceVolume.ebs(50)
)]
)

# ==================================================
# =================== OUTPUTS ======================
# ==================================================
CfnOutput(scope=self, id='LoadBalancerDNS', value=fargate_service.load_balancer.load_balancer_dns_name)
CfnOutput(scope=self, id='JumpHostInstanceID', value=jump.instance_id)


app = App()
Expand Down
2 changes: 1 addition & 1 deletion container/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
FROM python:3.8.0

RUN pip install \
mlflow==1.28.0 \
mlflow==2.0.1 \
pymysql==1.0.2 \
boto3 && \
mkdir /mlflow/
Expand Down
2 changes: 1 addition & 1 deletion lab/3_deploy_model.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"metadata": {},
"outputs": [],
"source": [
"!pip install -q mlflow==1.28.0"
"!pip install -q mlflow==1.30.0"

Choose a reason for hiding this comment

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

Here you havent upgrade to 2.0.1. I have

]
},
{
Expand Down
2 changes: 1 addition & 1 deletion lab/source_dir/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
mlflow==1.28.0
mlflow==1.30.0

Choose a reason for hiding this comment

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

Same as above there is version mismatch between the client SDK and the tracking server

Choose a reason for hiding this comment

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

side note: mlflow 2.0.1 requires python >= 3.8. The SKLearn image from SageMaker runs on python 3.7 which will make the install fail :(

Choose a reason for hiding this comment

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

you can update the SKLearn framework to framework_version='1.0-1', and it should work. I am testing it currently

Choose a reason for hiding this comment

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

ok, is a little more complicated, since there has been a major change in how MLFlow now deploys to SageMaker, so upgrading the SDK client requires more work

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
aws-cdk-lib==2.8.0
aws-cdk-lib==2.47.0
constructs==10.0.34