Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Transition to Terraform 0.12 for installer #1739

Merged
merged 17 commits into from
May 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
64c44cd
terraform: bump the vendored version to 0.12-rc.1
abhinavdahiya May 14, 2019
44777e3
terraform/plugins: update all providers to versions that use the upda…
abhinavdahiya May 14, 2019
3593c01
data/data/libvirt: upgrade libvirt templates to 0.12
abhinavdahiya May 10, 2019
37f7257
data/data/aws: upgrade aws templates to 0.12 language specification
abhinavdahiya May 10, 2019
3f1e732
data/data/aws: formatting fixes for templates
abhinavdahiya May 14, 2019
0b07018
terraform: update filenames to include json suffix to conform to rest…
abhinavdahiya May 10, 2019
2be7207
data/data/openstack: repeated arguments are not allowed in hcl2 (terr…
abhinavdahiya May 10, 2019
8dec748
data/data/openstack: upgrade openstack templates to 0.12 language spe…
abhinavdahiya May 10, 2019
4bfcaea
data/data/openstack: formatting fixes for templates
abhinavdahiya May 14, 2019
d68af18
data/data/config.tf: upgrade the template to 0.12 language specification
abhinavdahiya May 14, 2019
e7d9f33
data/data/config.tf: formatting fixes for template
abhinavdahiya May 14, 2019
dc22484
data/data/openstack: fix topology outputs to correct list type
abhinavdahiya May 10, 2019
0d0f295
data/data/aws: use floor function to convert float to int for indexin…
abhinavdahiya May 10, 2019
62b27a9
data/data/aws: fix list references
abhinavdahiya May 10, 2019
54233ef
data/data/libvirt: utilize dynamic blocks for srvs and dns
abhinavdahiya May 13, 2019
f16131f
terraform: change override directory for init to `.tf`
abhinavdahiya May 14, 2019
fb9a544
hack: update the tf-fmt to use 0.12-rc.1
abhinavdahiya May 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
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