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
import akka.actor.Actor | |
import akka.actor.Props | |
import akka.event.Logging | |
class DudeA extends Actor { | |
val log = Logging(context.system, this) | |
def receive = { | |
case "hello" => sender() ! "Hallo, Grüß Dich!" | |
case _ => log.info("Hmm...") |
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
trait Actor { | |
final def sender(): ActorRef = context.sender() | |
} |
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
import urllib | |
import pg8000 | |
import boto3 | |
import os | |
import logging | |
IAM_ROLE = os.environ['IAM_ROLE'] | |
DB_NAME = os.environ['DB_NAME'] | |
DB_USER = os.environ['DB_USER'] | |
DB_PORT = os.environ['DB_PORT'] |
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
module "redshift_loader_lambda" { | |
source = "github.com/diogoaurelio/terraform-aws-lambda-module" | |
version = "v0.0.1" | |
aws_region = "${var.aws_region}" | |
environment = "${var.environment}" | |
project = "${var.project}" | |
lambda_unique_function_name = "${var.redshift_loader_lambda_unique_function_name}" |
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
################################################################################ | |
# Locals used for different Lambdas Environmental Variables | |
################################################################################ | |
locals { | |
redshift_loader_lambda_env_vars = { | |
ENVIRONMENT = "${var.environment}" | |
REGION = "${var.aws_region}" | |
IAM_ROLE = "${var.redshift_data_loader_lambda_iam_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
################################################################################ | |
# AWS Lambda IAM Policy document definitions | |
################################################################################ | |
data "aws_iam_policy_document" "this" { | |
statement { | |
effect = "Allow" | |
actions = [ | |
"s3:GetBucketLocation", |
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
# Redshift - check currently running queries; useful for misbehaving queries; | |
SELECT | |
userid | |
, query | |
, pid | |
, starttime | |
, left(text, 100) as query | |
FROM stv_inflight; |
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
my_string = """ | |
your string \n seperated \n by \n new \n lines. | |
""" | |
account_id = '12345678910' | |
region = 'eu-west-1' | |
parameter_name = 'some-secret-name' | |
key_id = 'your-key-id' |
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
# create the general function | |
def _amount_spent(quantity: int, price: float) -> float: | |
""" | |
Calculates the product between two variables | |
:param quantity: (float/int) | |
:param price: (float/int) | |
:return: | |
(float/int) | |
""" | |
return quantity * price |
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 tests.test_utils.test_spark import spark_session | |
from pyspark.sql import DataFrame, Row, SparkSession | |
from pyspark.sql.functions import col | |
from src.job import amount_spent_udf | |
def test_amount_spent_udf(spark_session: SparkSession) -> None: | |
input_df = spark_session.createDataFrame([ | |
Row(customer_name="Geoffrey", date="2016-04-22", category="Foo", product_name="Bar", quantity=1, price=2.00), |