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
# i. Download sample data and extract features and label (fraud/nonfraud). | |
... | |
# ii. Convert the n-dimensional arrays into RecordIO format (a highly efficient data format). | |
import sagemaker.amazon.common as smac | |
buf = io.BytesIO() | |
smac.write_numpy_to_dense_tensor(buf, features, labels) | |
... | |
# iii. Store the RecordIO data into S3 bucket. |
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
cd /home/ec2-user/SageMaker | |
aws s3 cp s3://${function_bucket_name}-${aws_region}/fraud-detection-using-machine-learning/${function_version}/notebooks/sagemaker_fraud_detection.ipynb . | |
sed -i 's/fraud-detection-end-to-end-demo/${s3_bucket_name_1}/g' sagemaker_fraud_detection.ipynb |
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
aws_region="<region>" | |
aws_profile="<profile>" | |
function_bucket_name="<bucket-for-lambda-function>" | |
function_version="<version>" | |
s3_bucket_name_1="<bucket-1>" | |
s3_bucket_name_2="<bucket-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
terraform { | |
backend "s3" { | |
bucket = "<bucket-name>" | |
key = "fraud-detection/terraform.tfstate" | |
region = "<region>" | |
} | |
} |
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
# cloudwatch_event.tf | |
resource "aws_cloudwatch_event_rule" "fraud_detection_scheduled_rule" { | |
name = "fraud-detection-scheduled-rule" | |
schedule_expression = "rate(1 minute)" | |
... | |
} | |
# iam_lambda.tf | |
resource "aws_iam_role" "fraud_detection_lambda_role" { | |
name = "fraud-detection-lambda-role" | |
... |
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
linear_predictor = linear.deploy(initial_instance_count=1, | |
endpoint_name="fraud-detection-endpoint", | |
instance_type='ml.m4.xlarge') |
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
# iam_sagemaker.tf | |
resource "aws_iam_role" "sm_notebook_instance_role" { | |
name = "sm-notebook-instance-role" | |
... | |
} | |
resource "aws_iam_policy" "sm_notebook_instance_policy" { | |
name = "sm-notebook-instance-policy" | |
description = "Policy for the Notebook Instance to manage training jobs, models and endpoints" | |
... | |
} |
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
resource "aws_sagemaker_notebook_instance" "basic" { | |
name = "FraudDetectionNotebookInstance" | |
role_arn = "${aws_iam_role.sm_notebook_instance_role.arn}" | |
instance_type = "ml.t2.medium" | |
lifecycle_config_name = "${aws_sagemaker_notebook_instance_lifecycle_configuration.basic_lifecycle.name}" | |
} | |
resource "aws_sagemaker_notebook_instance_lifecycle_configuration" "basic_lifecycle" { | |
name = "BasicNotebookInstanceLifecycleConfig" | |
on_start = "${base64encode(data.template_file.instance_init.rendered)}" | |
} |
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
FROM amazonlinux:latest | |
WORKDIR / | |
RUN yum update -y | |
RUN yum group install "Development Tools" -y | |
RUN yum install -y git zip wget | |
RUN wget https://releases.hashicorp.com/terraform/0.11.7/terraform_0.11.7_linux_amd64.zip && unzip terraform_0.11.7_linux_amd64.zip | |
RUN chmod +x terraform | |
COPY . . | |
RUN chmod +x /run.sh | |
CMD ["/run.sh"] |
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
Serverless | Non-serverless | ||
---|---|---|---|
Compute | AWS Lambda; Azure Functions; Google Cloud Functions ... | AWS EC2; AWS ECS; Azure VMs ... | |
File Storage | AWS S3; Azure Storage; Google Cloud Storage ... | Hosted Network File System ... | |
Database Storage | Parse; Firebase; AWS DynamoDB; AWS Aurora Serverless ... | AWS RDS; Hosted NoSQL; ... | |
Event Stream | AWS Kinesis; Azure Event Hubs; Google Cloud Pub/Sub ... | Hosted Kafka; Message Queue ... | |
Authentication | Auth0; AWS Cognito; Azure App Service Authentication ... | Hosted Authentication logic ... | |
Workflows | AWS Step Function; Azure Logic Apps ... | Hosted Workflow Management ... |