This file contains hidden or 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
| { | |
| "Version": "2012-10-17", | |
| "Statement": [ | |
| { | |
| "Sid": "VisualEditor0", | |
| "Effect": "Allow", | |
| "Action": "s3:PutObject", | |
| "Resource": "arn:aws:s3:::lambda-zip-code/*" | |
| } | |
| ] |
This file contains hidden or 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_cloudwatch_metric_alarm" "lambda_alarm" { | |
| for_each = length(keys(local.alarms_dimensions)) > 0 ? local.alarms_dimensions : {} | |
| alarm_name = "${each.key}-alarm" | |
| comparison_operator = "GreaterThanThreshold" | |
| evaluation_periods = 1 | |
| metric_name = "Errors" | |
| namespace = "AWS/Lambda" | |
| period = "60" | |
| statistic = "Sum" |
This file contains hidden or 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
| locals { | |
| name_dash = "${var.name}-${var.environment}" | |
| # Lambda with Alarms | |
| alarms_dimensions = { | |
| "${var.name}-${var.environment}-lambda-1" = { | |
| FunctionName = "${var.name}-${var.environment}-lambda-1" | |
| }, | |
| "lambda-2" = { | |
| FunctionName = "lambda-y" | |
| }, |
This file contains hidden or 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_sns_topic" "sns_alarms" { | |
| name = "${local.name_dash}-sns-alarms" | |
| tags = { | |
| Product = local.name_dash | |
| } | |
| } | |
| resource "aws_sns_topic_subscription" "lambda_alarm" { | |
| topic_arn = aws_sns_topic.sns_alarms.arn |
This file contains hidden or 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
| import sys | |
| sys.path.insert(0, 'package/') | |
| import json | |
| import requests | |
| import os | |
| import logging | |
| logger = logging.getLogger() | |
| logger.setLevel(logging.INFO) | |
This file contains hidden or 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_instance" "private_server" { | |
| ami = var.image_ami | |
| associate_public_ip_address = false | |
| disable_api_termination = true | |
| instance_type = var.instance_type | |
| key_name = var.key_name | |
| vpc_security_group_ids = [aws_security_group.private_sg.id] | |
| subnet_id = element(tolist(data.aws_subnet_ids.private.ids), 0) | |
| iam_instance_profile = aws_iam_instance_profile.ec2_instance_profile.name |
This file contains hidden or 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_security_group" "private_sg" { | |
| name = "${var.name}-private-sg" | |
| description = "Security Group for Private EC2 instance" | |
| vpc_id = data.aws_vpc.selected.id | |
| egress { | |
| from_port = 0 | |
| to_port = 0 | |
| protocol = "-1" | |
| cidr_blocks = ["0.0.0.0/0"] |
This file contains hidden or 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 airflow import DAG | |
| from airflow.models import Variable | |
| from airflow.contrib.operators.ecs_operator import ECSOperator | |
| import copy | |
| from datetime import timedelta, datetime | |
| # Airflow Variables | |
| awsRegionName = Variable.get('AwsRegionName') | |
| awsCluster = Variable.get('AwsCluster') | |
| awsTaskDefinition = Variable.get('AwsTaskDefinition') |
This file contains hidden or 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
| def splitDataFrameList(df,target_column,separator): | |
| ''' df = dataframe to split, | |
| target_column = the column containing the values to split | |
| separator = the symbol used to perform the split | |
| returns: a dataframe with each entry for the target column separated, with each element moved into a new row. | |
| The values in the other columns are duplicated across the newly divided rows. | |
| ''' | |
| def splitListToRows(row,row_accumulator,target_column,separator): | |
| split_row = row[target_column].split(separator) |
This file contains hidden or 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 python:3.8.0 | |
| RUN pip install \ | |
| mlflow==1.18.0 \ | |
| psycopg2 \ | |
| boto3 && \ | |
| mkdir /mlflow/ | |
| EXPOSE 5000 |