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
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
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 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 { | |
// to make type Receive known in subclasses without import | |
type Receive = Actor.Receive | |
// [...] | |
//#receive | |
def receive: Actor.Receive | |
// [...] | |
} |
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 MyActor extends Actor { | |
val log = Logging(context.system, this) | |
var myMutatedVar: Int = 0 | |
def receive = { | |
case "test" => log.info("received test") | |
case "mutate" => myMutatedVar += 1; log.info(s"Mutated var to: $myMutatedVar") |
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
variable "role_name" {} | |
variable "role_policy_file" {} | |
resource "aws_iam_role" "role" { | |
name = "${var.role_name}" | |
assume_role_policy = "${file("${path.module}/policies/${var.role_policy_file}")}" | |
} | |
output "role_arn" { | |
value = "${aws_iam_role.role.arn}" |
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
def get_temp_credentials(role=DEFAULT_INSTANCE_ROLE): | |
""" Retrieves temp AWS credentials """ | |
query_uri = 'http://169.254.169.254/latest/meta-data/iam/security-credentials/{}'.format(role) | |
print('Querying AWS for credentials - {}'.format(query_uri)) | |
try: | |
sts_credentials = requests.get(query_uri).json() | |
if isinstance(sts_credentials, dict) and \ | |
sts_credentials.get('Code') == 'Success': | |
print('Successfully retrieved temp AWS credentials.') | |
return sts_credentials |
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
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Action": "sts:AssumeRole", | |
"Principal": { | |
"Service": "ec2.amazonaws.com" | |
}, | |
"Effect": "Allow", | |
"Sid": "" |
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 boto3 | |
def role_arn_to_session(**args): | |
""" | |
Usage : | |
session = role_arn_to_session( | |
RoleArn='arn:aws:iam::012345678901:role/example-role', | |
RoleSessionName='ExampleSessionName') | |
client = session.client('sqs') | |
""" |