Skip to content

Commit

Permalink
(Chore) terraform 0.12 syntax fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Stretch96 committed Aug 2, 2019
1 parent 530d3c8 commit e092651
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions consul_agent.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
data "template_file" "consul" {
template = "${file("${path.module}/templates/consul.json")}"

vars {
vars = {
env = "${aws_ecs_cluster.cluster.name}"
image = "${var.consul_image}"
registrator_image = "${var.registrator_image}"
Expand All @@ -20,7 +20,7 @@ resource "aws_ecs_task_definition" "consul" {
family = "consul-agent-${aws_ecs_cluster.cluster.name}"
container_definitions = "${data.template_file.consul.rendered}"
network_mode = "host"
task_role_arn = "${aws_iam_role.consul_task.arn}"
task_role_arn = "${aws_iam_role.consul_task[0].arn}"

volume {
name = "consul-config-dir"
Expand All @@ -35,19 +35,19 @@ resource "aws_ecs_task_definition" "consul" {

resource "aws_cloudwatch_log_group" "consul" {
count = "${var.enable_agents ? 1 : 0}"
name = "${aws_ecs_task_definition.consul.family}"
name = "${aws_ecs_task_definition.consul[0].family}"

tags {
tags = {
VPC = "${data.aws_vpc.vpc.tags["Name"]}"
Application = "${aws_ecs_task_definition.consul.family}"
Application = "${aws_ecs_task_definition.consul[0].family}"
}
}

resource "aws_ecs_service" "consul" {
count = "${var.enable_agents ? 1 : 0}"
name = "consul-agent-${aws_ecs_cluster.cluster.name}"
cluster = "${aws_ecs_cluster.cluster.id}"
task_definition = "${aws_ecs_task_definition.consul.arn}"
task_definition = "${aws_ecs_task_definition.consul[0].arn}"
desired_count = "${var.servers}"
deployment_minimum_healthy_percent = "60"

Expand Down
2 changes: 1 addition & 1 deletion iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,6 @@ resource "aws_iam_role" "consul_task" {
resource "aws_iam_role_policy" "consul_ecs_task" {
count = "${var.enable_agents ? 1 : 0}"
name_prefix = "${replace(format("%.102s", replace("tf-agentTaskPol-${var.name}-", "_", "-")), "/\\s/", "-")}"
role = "${aws_iam_role.consul_task.id}"
role = "${aws_iam_role.consul_task[0].id}"
policy = "${data.aws_iam_policy_document.consul_task_policy.json}"
}
14 changes: 7 additions & 7 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ data "aws_ami" "ecs_ami" {
data "template_file" "user_data" {
template = "${file("${path.module}/templates/user_data.tpl")}"

vars {
vars = {
additional_user_data_script = "${var.additional_user_data_script}"
cluster_name = "${aws_ecs_cluster.cluster.name}"
docker_storage_size = "${var.docker_storage_size}"
Expand All @@ -30,7 +30,7 @@ resource "aws_launch_configuration" "ecs" {
instance_type = "${var.instance_type}"
key_name = "${var.key_name}"
iam_instance_profile = "${aws_iam_instance_profile.ecs_profile.name}"
security_groups = ["${concat(list(aws_security_group.ecs.id), var.security_group_ids)}"]
security_groups = "${concat(list(aws_security_group.ecs.id), var.security_group_ids)}"
associate_public_ip_address = "${var.associate_public_ip_address}"
spot_price = "${var.spot_bid_price}"

Expand Down Expand Up @@ -60,16 +60,16 @@ locals {

resource "aws_autoscaling_group" "ecs" {
name_prefix = "asg-${aws_launch_configuration.ecs.name}-"
vpc_zone_identifier = ["${var.subnet_id}"]
vpc_zone_identifier = "${var.subnet_id[0]}"
launch_configuration = "${aws_launch_configuration.ecs.name}"
min_size = "${var.min_servers}"
max_size = "${var.max_servers}"
desired_capacity = "${var.servers}"
termination_policies = ["OldestLaunchConfiguration", "ClosestToNextInstanceHour", "Default"]
load_balancers = ["${var.load_balancers}"]
enabled_metrics = ["${var.enabled_metrics}"]
load_balancers = "${var.load_balancers}"
enabled_metrics = "${var.enabled_metrics}"

tags = ["${local.ecs_asg_tags}"]
tags = "${local.ecs_asg_tags}"

lifecycle {
create_before_destroy = true
Expand Down Expand Up @@ -106,7 +106,7 @@ resource "aws_security_group" "ecs" {
cidr_blocks = ["0.0.0.0/0"]
}

tags {
tags = {
Name = "ecs-sg-${var.name}"
}
}
Expand Down

0 comments on commit e092651

Please sign in to comment.