Skip to content

Commit

Permalink
Small improvements (#2)
Browse files Browse the repository at this point in the history
* Fix self-documenting make targets and add colors

* Be explicit about which provider version

* Test terraform

* Add more output

* Help Travis while testing
  • Loading branch information
atrakic authored and jessfraz committed Jan 2, 2019
1 parent ddc3023 commit b8edefe
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ aws-init:
-backend-config "region=$(AWS_REGION)" \
$(AWS_TERRAFORM_FLAGS)

.PHONY: terraform-validate
terraform-validate: ## Validate terraform scripts.
@cd $(AWS_DIR) && echo "$$(docker run --rm -it --entrypoint bash -w '/mnt' -v $$(pwd):/mnt r.j3ss.co/terraform -c 'terraform validate -check-variables=false . && echo [OK] terraform')"

.PHONY: aws-plan
aws-plan: aws-init ## Run terraform plan for Amazon.
@cd $(AWS_DIR) && terraform plan \
Expand Down Expand Up @@ -80,7 +84,7 @@ update-terraform: ## Update terraform binary locally from the docker container.
@terraform version

.PHONY: test
test: shellcheck ## Runs the tests on the repository.
test: terraform-validate shellcheck ## Runs the tests on the repository.

# if this session isn't interactive, then we don't want to allocate a
# TTY, which would fail, but if it is interactive, we do want to attach
Expand Down
4 changes: 4 additions & 0 deletions terraform/amazon/outputs.tf
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
output "alb_hostname" {
value = "${aws_alb.main.dns_name}"
}

output "container_definitions" {
value = "${local.container_definitions}"
}
18 changes: 11 additions & 7 deletions terraform/amazon/service.tf
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
resource "aws_ecs_task_definition" "app" {
family = "app"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = "${var.cpu}"
memory = "${var.memory}"

locals {
container_definitions = <<DEFINITION
[
{
Expand All @@ -25,6 +19,16 @@ resource "aws_ecs_task_definition" "app" {
DEFINITION
}

resource "aws_ecs_task_definition" "app" {
family = "app"
network_mode = "awsvpc"
requires_compatibilities = ["FARGATE"]
cpu = "${var.cpu}"
memory = "${var.memory}"

container_definitions = "${local.container_definitions}"
}

resource "aws_ecs_service" "main" {
name = "tf-ecs-service"
cluster = "${aws_ecs_cluster.main.id}"
Expand Down
1 change: 1 addition & 0 deletions terraform/amazon/vars.tf
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ variable "bucket" {
}

provider "aws" {
version = ">= 1.47.0"
access_key = "${var.access_key}"
secret_key = "${var.secret_key}"

Expand Down

0 comments on commit b8edefe

Please sign in to comment.