Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
80 changes: 80 additions & 0 deletions modules/aws/iam/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
locals {
arn = "aws"
}

resource "aws_iam_instance_profile" "worker" {
name = "${var.cluster_name}-worker-profile"

role = "${var.worker_iam_role == "" ?
join("|", aws_iam_role.worker_role.*.name) :
join("|", data.aws_iam_role.worker_role.*.name)
}"
}

data "aws_iam_role" "worker_role" {
count = "${var.worker_iam_role == "" ? 0 : 1}"
name = "${var.worker_iam_role}"
}

resource "aws_iam_role" "worker_role" {
count = "${var.worker_iam_role == "" ? 1 : 0}"
name = "${var.cluster_name}-worker-role"
path = "/"

assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Action": "sts:AssumeRole",
"Principal": {
"Service": "ec2.amazonaws.com"
},
"Effect": "Allow",
"Sid": ""
}
]
}
EOF
}

resource "aws_iam_role_policy" "worker_policy" {
count = "${var.worker_iam_role == "" ? 1 : 0}"
name = "${var.cluster_name}_worker_policy"
role = "${aws_iam_role.worker_role.id}"

policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "ec2:Describe*",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "ec2:AttachVolume",
"Resource": "*"
},
{
"Effect": "Allow",
"Action": "ec2:DetachVolume",
"Resource": "*"
},
{
"Action": "elasticloadbalancing:*",
"Resource": "*",
"Effect": "Allow"
},
{
"Action" : [
"s3:GetObject"
],
"Resource": "arn:${local.arn}:s3:::*",
"Effect": "Allow"
}
]
}
EOF
}
9 changes: 9 additions & 0 deletions modules/aws/iam/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
variable "cluster_name" {
type = "string"
}

variable "worker_iam_role" {
type = "string"
default = ""
description = "IAM role to use for the instance profiles of worker nodes."
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ spec:
spec:
containers:
- name: machine-api-operator
image: quay.io/coreos/machine-api-operator:225ff56
image: quay.io/coreos/machine-api-operator:b6a04c2
command:
- "/machine-api-operator"
resources:
Expand Down
7 changes: 7 additions & 0 deletions steps/infra/aws/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ module "masters" {
user_data_igns = "${var.tectonic_ignition_masters}"
}

module "iam" {
source = "../../../modules/aws/iam"

cluster_name = "${var.tectonic_cluster_name}"
worker_iam_role = "${var.tectonic_aws_worker_iam_role_name}"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's an extra space here which terraform fmt wants to remove. I'll file a fixup and try and figure out why our CI tests missed it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll file a fixup...

Filed as #269.

}

module "dns" {
source = "../../../modules/dns/route53"

Expand Down