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
const fetchUser: (id: string) => IO<User> = | |
id => new IO(effects => effects.findById(id)); | |
const notifyUser: (user: User) => IO<void> = | |
id => new IO(effects => effects.notify(user)); | |
const exampleFunc: (id: string) => IO<void> = _do(function* (id) { | |
const user: User = yield fetchUser(id); | |
yield notifyUser(user); | |
log.info('User has been notified') |
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
export class IO<A>{ | |
private effect: Effect<A> | |
constructor(effect: Effect<A>) { | |
this.effect = effect | |
} | |
static of<T>(val: T) { | |
return new IO(() => Promise.resolve(val)) | |
} | |
map<B>(f: (val: A) => B): IO<B> { |
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_alb" "alb" { | |
subnets = ["${aws_subnet.pub_subnet_1.id}", "${aws_subnet.pub_subnet_2.id}"] | |
internal = false | |
security_groups = ["${aws_security_group.alb.id}"] | |
depends_on = ["aws_internet_gateway.app_igw", "aws_vpc_dhcp_options_association.dns_resolver"] | |
} | |
resource "aws_alb_target_group" "targ" { | |
port = 8080 | |
protocol = "HTTP" |
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
#### EC2 INSTANCES ################# | |
# bastion ############################ | |
resource "aws_instance" "bastion" { | |
ami = "${data.aws_ami.ubuntu.id}" | |
vpc_security_group_ids = [ | |
"${aws_security_group.bastion.id}" | |
] | |
instance_type = "${var.aws_instance_type}" | |
subnet_id = "${aws_subnet.pub_subnet_1.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
#provision public subnet 1 | |
resource "aws_subnet" "pub_subnet_1"{ | |
vpc_id = "${aws_vpc.app_vpc.id}" | |
cidr_block = "${var.aws_pub_subnet_1_cidr}" | |
tags { | |
Name = "public subnet" | |
} | |
availability_zone = "${data.aws_availability_zones.available.names[0]}" | |
} |
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
# WP SERVERS ############################ | |
resource "aws_instance" "wp" { | |
ami = "${data.aws_ami.ubuntu.id}" | |
vpc_security_group_ids = [ | |
"${aws_security_group.wp.id}" | |
] | |
instance_type = "${var.aws_instance_type}" | |
subnet_id = "${aws_subnet.wp_subnet.id}" | |
key_name = "${aws_key_pair.demo_keys.key_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
#provision wordpress subnet | |
resource "aws_subnet" "wp_subnet" { | |
vpc_id = "${aws_vpc.app_vpc.id}" | |
cidr_block = "${var.aws_wp_subnet_cidr}" | |
tags { | |
Name = "WordPress subnet" | |
} | |
availability_zone = "${data.aws_availability_zones.available.names[0]}" | |
} |
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
###### provision RDS | |
# make db subnet group | |
resource "aws_db_subnet_group" "db_subnet" { | |
name = "db_subnet" | |
subnet_ids = ["${aws_subnet.db_subnet_1.id}", "${aws_subnet.db_subnet_2.id}"] | |
} | |
resource "aws_db_instance" "wp-db" { | |
identifier = "wp-db" | |
instance_class = "db.t2.micro" |
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
#### DB subnets | |
resource "aws_subnet" "db_subnet_1" { | |
vpc_id = "${aws_vpc.app_vpc.id}" | |
cidr_block = "${var.aws_db_subnet_1_cidr}" | |
tags { | |
Name = "WordPress subnet 1" | |
} | |
availability_zone = "${data.aws_availability_zones.available.names[0]}" | |
} |
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 VPC #################################################################### | |
# provision app vpc | |
resource "aws_vpc" "app_vpc" { | |
cidr_block = "${var.aws_network_cidr}" | |
enable_dns_support = true | |
enable_dns_hostnames = true | |
tags { | |
Name = "WP Solution VPC" | |
} | |
} |
NewerOlder