Skip to content

Commit

Permalink
Merge pull request #1739 from abhinavdahiya/terraform_0.12
Browse files Browse the repository at this point in the history
Transition to Terraform 0.12 for installer
  • Loading branch information
openshift-merge-robot authored May 16, 2019
2 parents 130101f + fb9a544 commit 1b3d3fe
Show file tree
Hide file tree
Showing 2,997 changed files with 249,943 additions and 1,045,152 deletions.
100 changes: 60 additions & 40 deletions data/data/aws/bootstrap/main.tf
Original file line number Diff line number Diff line change
@@ -1,29 +1,35 @@
resource "aws_s3_bucket" "ignition" {
acl = "private"

tags = "${merge(map(
"Name", "${var.cluster_id}-bootstrap",
), var.tags)}"
tags = merge(
{
"Name" = "${var.cluster_id}-bootstrap"
},
var.tags,
)

lifecycle {
ignore_changes = ["*"]
ignore_changes = all
}
}

resource "aws_s3_bucket_object" "ignition" {
bucket = "${aws_s3_bucket.ignition.id}"
bucket = aws_s3_bucket.ignition.id
key = "bootstrap.ign"
content = "${var.ignition}"
content = var.ignition
acl = "private"

server_side_encryption = "AES256"

tags = "${merge(map(
"Name", "${var.cluster_id}-bootstrap",
), var.tags)}"
tags = merge(
{
"Name" = "${var.cluster_id}-bootstrap"
},
var.tags,
)

lifecycle {
ignore_changes = ["*"]
ignore_changes = all
}
}

Expand All @@ -36,7 +42,7 @@ data "ignition_config" "redirect" {
resource "aws_iam_instance_profile" "bootstrap" {
name = "${var.cluster_id}-bootstrap-profile"

role = "${aws_iam_role.bootstrap.name}"
role = aws_iam_role.bootstrap.name
}

resource "aws_iam_role" "bootstrap" {
Expand All @@ -59,14 +65,17 @@ resource "aws_iam_role" "bootstrap" {
}
EOF

tags = "${merge(map(
"Name", "${var.cluster_id}-bootstrap-role",
), var.tags)}"
tags = merge(
{
"Name" = "${var.cluster_id}-bootstrap-role"
},
var.tags,
)
}

resource "aws_iam_role_policy" "bootstrap" {
name = "${var.cluster_id}-bootstrap-policy"
role = "${aws_iam_role.bootstrap.id}"
role = aws_iam_role.bootstrap.id

policy = <<EOF
{
Expand Down Expand Up @@ -97,61 +106,71 @@ resource "aws_iam_role_policy" "bootstrap" {
]
}
EOF

}

resource "aws_instance" "bootstrap" {
ami = "${var.ami}"
ami = var.ami

iam_instance_profile = "${aws_iam_instance_profile.bootstrap.name}"
instance_type = "${var.instance_type}"
subnet_id = "${var.subnet_id}"
user_data = "${data.ignition_config.redirect.rendered}"
vpc_security_group_ids = ["${var.vpc_security_group_ids}", "${aws_security_group.bootstrap.id}"]
iam_instance_profile = aws_iam_instance_profile.bootstrap.name
instance_type = var.instance_type
subnet_id = var.subnet_id
user_data = data.ignition_config.redirect.rendered
vpc_security_group_ids = flatten([var.vpc_security_group_ids, aws_security_group.bootstrap.id])
associate_public_ip_address = true

lifecycle {
# Ignore changes in the AMI which force recreation of the resource. This
# avoids accidental deletion of nodes whenever a new OS release comes out.
ignore_changes = ["ami"]
ignore_changes = [ami]
}

tags = "${merge(map(
"Name", "${var.cluster_id}-bootstrap",
), var.tags)}"
tags = merge(
{
"Name" = "${var.cluster_id}-bootstrap"
},
var.tags,
)

root_block_device {
volume_type = "${var.volume_type}"
volume_size = "${var.volume_size}"
iops = "${var.volume_type == "io1" ? var.volume_iops : 0}"
volume_type = var.volume_type
volume_size = var.volume_size
iops = var.volume_type == "io1" ? var.volume_iops : 0
}

volume_tags = "${merge(map(
"Name", "${var.cluster_id}-bootstrap-vol",
), var.tags)}"
volume_tags = merge(
{
"Name" = "${var.cluster_id}-bootstrap-vol"
},
var.tags,
)
}

resource "aws_lb_target_group_attachment" "bootstrap" {
count = "${var.target_group_arns_length}"
count = var.target_group_arns_length

target_group_arn = "${var.target_group_arns[count.index]}"
target_id = "${aws_instance.bootstrap.private_ip}"
target_group_arn = var.target_group_arns[count.index]
target_id = aws_instance.bootstrap.private_ip
}

resource "aws_security_group" "bootstrap" {
vpc_id = "${var.vpc_id}"
vpc_id = var.vpc_id

timeouts {
create = "20m"
}

tags = "${merge(map(
"Name", "${var.cluster_id}-bootstrap-sg",
), var.tags)}"
tags = merge(
{
"Name" = "${var.cluster_id}-bootstrap-sg"
},
var.tags,
)
}

resource "aws_security_group_rule" "ssh" {
type = "ingress"
security_group_id = "${aws_security_group.bootstrap.id}"
security_group_id = aws_security_group.bootstrap.id

protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
Expand All @@ -161,10 +180,11 @@ resource "aws_security_group_rule" "ssh" {

resource "aws_security_group_rule" "bootstrap_journald_gateway" {
type = "ingress"
security_group_id = "${aws_security_group.bootstrap.id}"
security_group_id = aws_security_group.bootstrap.id

protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
from_port = 19531
to_port = 19531
}

25 changes: 13 additions & 12 deletions data/data/aws/bootstrap/variables.tf
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
variable "ami" {
type = "string"
type = string
description = "The AMI ID for the bootstrap node."
}

variable "cluster_id" {
type = "string"
type = string
description = "The identifier for the cluster."
}

variable "ignition" {
type = "string"
type = string
description = "The content of the bootstrap ignition file."
}

variable "instance_type" {
type = "string"
type = string
description = "The instance type of the bootstrap node."
}

variable "subnet_id" {
type = "string"
type = string
description = "The subnet ID for the bootstrap node."
}

variable "tags" {
type = "map"
type = map(string)
default = {}
description = "AWS tags to be applied to created resources."
}

variable "target_group_arns" {
type = "list"
type = list(string)
default = []
description = "The list of target group ARNs for the load balancer."
}
Expand All @@ -40,30 +40,31 @@ variable "target_group_arns_length" {
}

variable "volume_iops" {
type = "string"
type = string
default = "100"
description = "The amount of IOPS to provision for the disk."
}

variable "volume_size" {
type = "string"
type = string
default = "30"
description = "The volume size (in gibibytes) for the bootstrap node's root volume."
}

variable "volume_type" {
type = "string"
type = string
default = "gp2"
description = "The volume type for the bootstrap node's root volume."
}

variable "vpc_id" {
type = "string"
type = string
description = "VPC ID is used to create resources like security group rules for bootstrap machine."
}

variable "vpc_security_group_ids" {
type = "list"
type = list(string)
default = []
description = "VPC security group IDs for the bootstrap node."
}

15 changes: 10 additions & 5 deletions data/data/aws/iam/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ locals {
resource "aws_iam_instance_profile" "worker" {
name = "${var.cluster_id}-worker-profile"

role = "${aws_iam_role.worker_role.name}"
role = aws_iam_role.worker_role.name
}

resource "aws_iam_role" "worker_role" {
Expand All @@ -28,14 +28,17 @@ resource "aws_iam_role" "worker_role" {
}
EOF

tags = "${merge(map(
"Name", "${var.cluster_id}-worker-role",
), var.tags)}"
tags = merge(
{
"Name" = "${var.cluster_id}-worker-role"
},
var.tags,
)
}

resource "aws_iam_role_policy" "worker_policy" {
name = "${var.cluster_id}-worker-policy"
role = "${aws_iam_role.worker_role.id}"
role = aws_iam_role.worker_role.id

policy = <<EOF
{
Expand All @@ -49,4 +52,6 @@ resource "aws_iam_role_policy" "worker_policy" {
]
}
EOF

}

5 changes: 3 additions & 2 deletions data/data/aws/iam/variables.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
variable "cluster_id" {
type = "string"
type = string
}

variable "tags" {
type = "map"
type = map(string)
default = {}
description = "AWS tags to be applied to created resources."
}

Loading

0 comments on commit 1b3d3fe

Please sign in to comment.