Skip to content

Instantly share code, notes, and snippets.

@elblivion
Last active February 16, 2016 20:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elblivion/e767aa9a697fe426b6c7 to your computer and use it in GitHub Desktop.
Save elblivion/e767aa9a697fe426b6c7 to your computer and use it in GitHub Desktop.
ECS service module
module "myapp" {
source = "modules/myapp_service"
environment = "${var.environment}"
ecs_cluster_id = "${module.ecs_cluster.cluster_id}"
}
variable "ecs_cluster_id" {}
variable "environment" {}
variable "count" { default = 1 }
variable "console_tag" { default = "latest" }
variable "hub_tag" { default = "latest" }
variable "registry" { default = "<our-id>.dkr.ecr.us-east-1.amazonaws.com" }
resource "template_file" "containers" {
template = "${path.module}/containers/myaapp.json.tpl"
vars = {
registry = "${var.registry}"
console_tag = "${var.console_tag}"
hub_tag = "${var.hub_tag}"
}
}
resource "aws_ecs_task_definition" "myapp" {
family = "myapp-${var.environment}"
container_definitions = "${template_file.containers.rendered}"
}
resource "aws_ecs_service" "myapp" {
name = "myapp-${var.environment}"
cluster = "${var.ecs_cluster_id}"
task_definition = "${aws_ecs_task_definition.myapp.arn}"
desired_count = "${var.count}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment