Created
March 29, 2017 21:30
-
-
Save travisjeffery/909a58c4dc873239c79f9e8cbee49e66 to your computer and use it in GitHub Desktop.
Terraform example
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" "example-service-balancer" { | |
| name = "example-service-balancer" | |
| description = "Allows traffic from the VPC" | |
| vpc_id = "${module.vpc.vpc_id}" | |
| ingress { | |
| from_port = 80 | |
| to_port = 80 | |
| protocol = "tcp" | |
| cidr_blocks = ["10.0.0.0/8"] | |
| } | |
| egress { | |
| from_port = 0 | |
| to_port = 0 | |
| protocol = "-1" | |
| cidr_blocks = ["0.0.0.0/0"] | |
| } | |
| tags { | |
| Name = "example-service-balancer" | |
| } | |
| } | |
| resource "aws_elb" "example-service" { | |
| name = "example-service" | |
| internal = true | |
| cross_zone_load_balancing = true | |
| subnets = ["${split(",", module.vpc.private_subnets)}"] | |
| security_groups = ["${aws_security_group.example-service-balancer.id}"] | |
| idle_timeout = 30 | |
| connection_draining = true | |
| connection_draining_timeout = 15 | |
| listener { | |
| lb_port = 80 | |
| lb_protocol = "tcp" | |
| instance_port = 5001 | |
| instance_protocol = "tcp" | |
| } | |
| health_check { | |
| healthy_threshold = 2 | |
| unhealthy_threshold = 2 | |
| timeout = 5 | |
| interval = 30 | |
| target = "TCP:5001" | |
| } | |
| tags { | |
| Name = "example-service" | |
| Environment = "production" | |
| } | |
| } | |
| resource "aws_route53_record" "example-service" { | |
| zone_id = "${aws_route53_zone.local.id}" | |
| name = "example-service.confluent.local" | |
| type = "A" | |
| alias { | |
| name = "${aws_elb.example-service.dns_name}" | |
| zone_id = "${aws_elb.example-service.zone_id}" | |
| evaluate_target_health = false | |
| } | |
| } | |
| resource "aws_ecs_task_definition" "example-service" { | |
| family = "example-service" | |
| container_definitions = <<EOF | |
| [ | |
| { | |
| "cpu": 512, | |
| "command": [ | |
| "--rpc-addr=0.0.0.0:3000" | |
| ], | |
| "entryPoint": [], | |
| "environment": [], | |
| "essential": true, | |
| "image": "confluent/example-service:v1.0.0", | |
| "links": [], | |
| "memory": 512, | |
| "mountPoints": [], | |
| "name": "example-service", | |
| "portMappings": [ | |
| { | |
| "containerPort": 3000, | |
| "hostPort": 5001 | |
| } | |
| ], | |
| "volumesFrom": [] | |
| } | |
| ] | |
| EOF | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment