Skip to content

Commit

Permalink
Updating to Terraform 0.13
Browse files Browse the repository at this point in the history
  • Loading branch information
jnonino committed Sep 4, 2020
1 parent 8e3dede commit 8a6cfbc
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 24 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Check valid versions on:
source = "cn-terraform/nomad/aws"
version = "2.0.2"

names_preffix = ${terraform.workspace}
names_prefix = ${terraform.workspace}

profile = var.profile
region = var.region
Expand Down
16 changes: 8 additions & 8 deletions iam.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@

## Create IAM role
resource "aws_iam_role" "ec2_describe_role" {
name = "${var.names_preffix}_ec2_describe_role"
name = "${var.names_prefix}_ec2_describe_role"
assume_role_policy = file("${path.module}/iam_files/iam_role_ec2_describe.json")
}

## Create IAM policy
resource "aws_iam_policy" "ec2_describe_policy" {
name = "${var.names_preffix}_ec2_describe_policy"
name = "${var.names_prefix}_ec2_describe_policy"
description = "Allows EC2 Instances to Describe Other EC2 Instances"
policy = file("${path.module}/iam_files/iam_policy_ec2_describe.json")
}

## Attach the policy to the role
resource "aws_iam_policy_attachment" "ec2_describe_attach_policy" {
name = "${var.names_preffix}_ec2_describe_attach"
name = "${var.names_prefix}_ec2_describe_attach"
roles = [aws_iam_role.ec2_describe_role.name]
policy_arn = aws_iam_policy.ec2_describe_policy.arn
}

## Create the instance profile
resource "aws_iam_instance_profile" "ec2_describe_instance_profile" {
name = "${var.names_preffix}_ec2_describe_instance_profile"
name = "${var.names_prefix}_ec2_describe_instance_profile"
role = aws_iam_role.ec2_describe_role.name
}

Expand All @@ -38,27 +38,27 @@ resource "aws_iam_instance_profile" "ec2_describe_instance_profile" {

## Create IAM role
resource "aws_iam_role" "push_to_ecr_role" {
name = "${var.names_preffix}_push_to_ecr_role"
name = "${var.names_prefix}_push_to_ecr_role"
assume_role_policy = file("${path.module}/iam_files/iam_role_ec2_describe.json")
}

## Create IAM policy to allow the push of docker images to ECR
resource "aws_iam_policy" "push_to_ecr_policy" {
name = "${var.names_preffix}_push_to_ecr_policy"
name = "${var.names_prefix}_push_to_ecr_policy"
description = "Allow EC2 instances to push docker images to ECR registry"
policy = file("${path.module}/iam_files/iam_policy_push_to_ecr.json")
}

## Attach the policy to the role
resource "aws_iam_policy_attachment" "push_to_ecr_attach_policy" {
name = "${var.names_preffix}_push_to_ecr_attach"
name = "${var.names_prefix}_push_to_ecr_attach"
roles = [aws_iam_role.push_to_ecr_role.name]
policy_arn = aws_iam_policy.push_to_ecr_policy.arn
}

## Create an instance profile
resource "aws_iam_instance_profile" "ecr_role_instance_profile" {
name = "${var.names_preffix}_push_to_ecr_instance_profile"
name = "${var.names_prefix}_push_to_ecr_instance_profile"
role = aws_iam_role.push_to_ecr_role.name
}

8 changes: 4 additions & 4 deletions load_balancer.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
#------------------------------------------------------------------------------
## ELB
resource "aws_elb" "consul_elb" {
name = "${var.names_preffix}-consul-elb"
name = "${var.names_prefix}-consul-elb"
security_groups = [aws_security_group.elb_security_group.id]
subnets = data.aws_subnet.subnets.*.id
internal = true
cross_zone_load_balancing = true
tags = {
Name = "${var.names_preffix}_consul_elb"
Name = "${var.names_prefix}_consul_elb"
}
listener {
instance_port = "8500"
Expand Down Expand Up @@ -37,13 +37,13 @@ resource "aws_route53_record" "consul_elb_dns" {
#------------------------------------------------------------------------------
## ELB
resource "aws_elb" "nomad_elb" {
name = "${var.names_preffix}-nomad-elb"
name = "${var.names_prefix}-nomad-elb"
security_groups = [aws_security_group.elb_security_group.id]
subnets = data.aws_subnet.subnets.*.id
internal = true
cross_zone_load_balancing = true
tags = {
Name = "${var.names_preffix}_nomad_elb"
Name = "${var.names_prefix}_nomad_elb"
}
listener {
instance_port = "4646"
Expand Down
6 changes: 3 additions & 3 deletions nomad-client.tf
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ resource "aws_launch_configuration" "nomad_client_lc" {
aws_autoscaling_attachment.nomad_asg_attachment,
aws_security_group.instances_security_group,
]
name = "${var.names_preffix}_nomad_client_lc"
name = "${var.names_prefix}_nomad_client_lc"
image_id = var.client_ami_id
instance_type = var.client_instance_type
iam_instance_profile = aws_iam_instance_profile.ecr_role_instance_profile.name
Expand All @@ -34,7 +34,7 @@ resource "aws_launch_configuration" "nomad_client_lc" {
#------------------------------------------------------------------------------
resource "aws_autoscaling_group" "nomad_client_asg" {
depends_on = [aws_launch_configuration.nomad_client_lc]
name = "${var.names_preffix}_nomad_client_asg"
name = "${var.names_prefix}_nomad_client_asg"
launch_configuration = aws_launch_configuration.nomad_client_lc.name
vpc_zone_identifier = var.subnets_ids
min_size = var.client_asg_min_size
Expand All @@ -43,7 +43,7 @@ resource "aws_autoscaling_group" "nomad_client_asg" {
tags = [
{
key = "Name"
value = "${var.names_preffix}_nomad_client_asg"
value = "${var.names_prefix}_nomad_client_asg"
propagate_at_launch = true
},
]
Expand Down
8 changes: 4 additions & 4 deletions paas-server.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ data "template_file" "server_user_data" {
region = var.region
desired_servers = var.server_asg_desired_capacity
domain = var.domain_name
asg_name = "${var.names_preffix}_server_asg"
asg_name = "${var.names_prefix}_server_asg"
nomad_version = var.nomad_version
}
}
Expand All @@ -21,7 +21,7 @@ resource "aws_launch_configuration" "server_lc" {
aws_security_group.instances_security_group,
aws_iam_instance_profile.ec2_describe_instance_profile,
]
name = "${var.names_preffix}_server_lc"
name = "${var.names_prefix}_server_lc"
image_id = var.server_ami_id
instance_type = var.server_instance_type
iam_instance_profile = aws_iam_instance_profile.ec2_describe_instance_profile.name
Expand All @@ -37,7 +37,7 @@ resource "aws_launch_configuration" "server_lc" {
#------------------------------------------------------------------------------
resource "aws_autoscaling_group" "server_asg" {
depends_on = [aws_launch_configuration.server_lc]
name = "${var.names_preffix}_server_asg"
name = "${var.names_prefix}_server_asg"
launch_configuration = aws_launch_configuration.server_lc.name
vpc_zone_identifier = var.subnets_ids
min_size = var.server_asg_min_size
Expand All @@ -46,7 +46,7 @@ resource "aws_autoscaling_group" "server_asg" {
tags = [
{
key = "Name"
value = "${var.names_preffix}_server_asg"
value = "${var.names_prefix}_server_asg"
propagate_at_launch = true
},
]
Expand Down
4 changes: 2 additions & 2 deletions security_groups.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ resource "aws_security_group" "instances_security_group" {
description = "Open ports on instances"
vpc_id = var.vpc_id
tags = {
Name = "${var.names_preffix}_instances_security_group"
Name = "${var.names_prefix}_instances_security_group"
}
}

Expand Down Expand Up @@ -91,7 +91,7 @@ resource "aws_security_group" "elb_security_group" {
description = "Open ports on Load Balanacers"
vpc_id = var.vpc_id
tags = {
Name = "${var.names_preffix}_elb_security_group"
Name = "${var.names_prefix}_elb_security_group"
}
}

Expand Down
4 changes: 2 additions & 2 deletions variables.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
variable "names_preffix" {
description = "Preffix for Resources Names"
variable "names_prefix" {
description = "prefix for Resources Names"
}

#------------------------------------------------------------------------------
Expand Down

0 comments on commit 8a6cfbc

Please sign in to comment.