Skip to content

Commit 3b393da

Browse files
committed
pkg/types/aws/machinepool: Drop IAM-role overrides
We're planning on dropping instance profiles in favor of the new credentials operator [1], because we want AWS access to have operator/pod/namespace granularity and not instance granularity. Many pods could be running on a given instance, and not all of them should have a given permission. While we're blocked from dropping these at the moment due to kubelet cloud-config+secrets [2], we can drop the user-facing knobs for this feature now. Then pivoting the internal approach once we get the kubelet sorted will be a non-breaking change. [1]: https://github.com/openshift/cloud-credential-operator [2]: #697 (comment)
1 parent 810b13a commit 3b393da

File tree

17 files changed

+30
-133
lines changed

17 files changed

+30
-133
lines changed

data/data/aws/bootstrap/main.tf

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,21 +32,12 @@ data "ignition_config" "redirect" {
3232
resource "aws_iam_instance_profile" "bootstrap" {
3333
name = "${var.cluster_name}-bootstrap-profile"
3434

35-
role = "${var.iam_role == "" ?
36-
join("|", aws_iam_role.bootstrap.*.name) :
37-
join("|", data.aws_iam_role.bootstrap.*.name)
38-
}"
39-
}
40-
41-
data "aws_iam_role" "bootstrap" {
42-
count = "${var.iam_role == "" ? 0 : 1}"
43-
name = "${var.iam_role}"
35+
role = "${aws_iam_role.bootstrap.name}"
4436
}
4537

4638
resource "aws_iam_role" "bootstrap" {
47-
count = "${var.iam_role == "" ? 1 : 0}"
48-
name = "${var.cluster_name}-bootstrap-role"
49-
path = "/"
39+
name = "${var.cluster_name}-bootstrap-role"
40+
path = "/"
5041

5142
assume_role_policy = <<EOF
5243
{
@@ -68,9 +59,8 @@ EOF
6859
}
6960

7061
resource "aws_iam_role_policy" "bootstrap" {
71-
count = "${var.iam_role == "" ? 1 : 0}"
72-
name = "${var.cluster_name}-bootstrap-policy"
73-
role = "${aws_iam_role.bootstrap.id}"
62+
name = "${var.cluster_name}-bootstrap-policy"
63+
role = "${aws_iam_role.bootstrap.id}"
7464

7565
policy = <<EOF
7666
{

data/data/aws/bootstrap/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,6 @@ variable "cluster_name" {
88
description = "The name of the cluster."
99
}
1010

11-
variable "iam_role" {
12-
type = "string"
13-
default = ""
14-
description = "The name of the IAM role to assign to the bootstrap node."
15-
}
16-
1711
variable "ignition" {
1812
type = "string"
1913
description = "The content of the bootstrap ignition file."

data/data/aws/iam/main.tf

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,12 @@ locals {
55
resource "aws_iam_instance_profile" "worker" {
66
name = "${var.cluster_name}-worker-profile"
77

8-
role = "${var.worker_iam_role == "" ?
9-
join("|", aws_iam_role.worker_role.*.name) :
10-
join("|", data.aws_iam_role.worker_role.*.name)
11-
}"
12-
}
13-
14-
data "aws_iam_role" "worker_role" {
15-
count = "${var.worker_iam_role == "" ? 0 : 1}"
16-
name = "${var.worker_iam_role}"
8+
role = "${aws_iam_role.worker_role.name}"
179
}
1810

1911
resource "aws_iam_role" "worker_role" {
20-
count = "${var.worker_iam_role == "" ? 1 : 0}"
21-
name = "${var.cluster_name}-worker-role"
22-
path = "/"
12+
name = "${var.cluster_name}-worker-role"
13+
path = "/"
2314

2415
assume_role_policy = <<EOF
2516
{
@@ -41,9 +32,8 @@ EOF
4132
}
4233

4334
resource "aws_iam_role_policy" "worker_policy" {
44-
count = "${var.worker_iam_role == "" ? 1 : 0}"
45-
name = "${var.cluster_name}_worker_policy"
46-
role = "${aws_iam_role.worker_role.id}"
35+
name = "${var.cluster_name}_worker_policy"
36+
role = "${aws_iam_role.worker_role.id}"
4737

4838
policy = <<EOF
4939
{

data/data/aws/iam/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ variable "cluster_name" {
22
type = "string"
33
}
44

5-
variable "worker_iam_role" {
6-
type = "string"
7-
default = ""
8-
description = "IAM role to use for the instance profiles of worker nodes."
9-
}
10-
115
variable "tags" {
126
type = "map"
137
default = {}

data/data/aws/main.tf

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module "bootstrap" {
1515

1616
ami = "${var.aws_ec2_ami_override}"
1717
cluster_name = "${var.cluster_name}"
18-
iam_role = "${var.aws_master_iam_role_name}"
1918
ignition = "${var.ignition_bootstrap}"
2019
subnet_id = "${module.vpc.master_subnet_ids[0]}"
2120
target_group_arns = "${module.vpc.aws_lb_target_group_arns}"
@@ -40,7 +39,6 @@ module "masters" {
4039
), local.tags)}"
4140

4241
instance_count = "${var.master_count}"
43-
master_iam_role = "${var.aws_master_iam_role_name}"
4442
master_sg_ids = "${list(module.vpc.master_sg_id)}"
4543
root_volume_iops = "${var.aws_master_root_volume_iops}"
4644
root_volume_size = "${var.aws_master_root_volume_size}"
@@ -55,8 +53,7 @@ module "masters" {
5553
module "iam" {
5654
source = "./iam"
5755

58-
cluster_name = "${var.cluster_name}"
59-
worker_iam_role = "${var.aws_worker_iam_role_name}"
56+
cluster_name = "${var.cluster_name}"
6057

6158
tags = "${merge(map(
6259
"kubernetes.io/cluster/${var.cluster_name}", "owned",

data/data/aws/master/main.tf

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,12 @@ locals {
55
resource "aws_iam_instance_profile" "master" {
66
name = "${var.cluster_name}-master-profile"
77

8-
role = "${var.master_iam_role == "" ?
9-
join("|", aws_iam_role.master_role.*.name) :
10-
join("|", data.aws_iam_role.master_role.*.name)
11-
}"
12-
}
13-
14-
data "aws_iam_role" "master_role" {
15-
count = "${var.master_iam_role == "" ? 0 : 1}"
16-
name = "${var.master_iam_role}"
8+
role = "${aws_iam_role.master_role.name}"
179
}
1810

1911
resource "aws_iam_role" "master_role" {
20-
count = "${var.master_iam_role == "" ? 1 : 0}"
21-
name = "${var.cluster_name}-master-role"
22-
path = "/"
12+
name = "${var.cluster_name}-master-role"
13+
path = "/"
2314

2415
assume_role_policy = <<EOF
2516
{
@@ -41,9 +32,8 @@ EOF
4132
}
4233

4334
resource "aws_iam_role_policy" "master_policy" {
44-
count = "${var.master_iam_role == "" ? 1 : 0}"
45-
name = "${var.cluster_name}_master_policy"
46-
role = "${aws_iam_role.master_role.id}"
35+
name = "${var.cluster_name}_master_policy"
36+
role = "${aws_iam_role.master_role.id}"
4737

4838
policy = <<EOF
4939
{

data/data/aws/master/variables.tf

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ variable "kubeconfig_content" {
2929
default = ""
3030
}
3131

32-
variable "master_iam_role" {
33-
type = "string"
34-
default = ""
35-
description = "IAM role to use for the instance profiles of master nodes."
36-
}
37-
3832
variable "master_sg_ids" {
3933
type = "list"
4034
description = "The security group IDs to be applied to the master nodes."

data/data/aws/variables-aws.tf

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,31 +59,3 @@ variable "aws_region" {
5959
type = "string"
6060
description = "The target AWS region for the cluster."
6161
}
62-
63-
variable "aws_master_iam_role_name" {
64-
type = "string"
65-
default = ""
66-
67-
description = <<EOF
68-
(optional) Name of IAM role to use for the instance profiles of master nodes.
69-
The name is also the last part of a role's ARN.
70-
71-
Example:
72-
* Role ARN = arn:aws:iam::123456789012:role/openshift-installer
73-
* Role Name = openshift-installer
74-
EOF
75-
}
76-
77-
variable "aws_worker_iam_role_name" {
78-
type = "string"
79-
default = ""
80-
81-
description = <<EOF
82-
(optional) Name of IAM role to use for the instance profiles of worker nodes.
83-
The name is also the last part of a role's ARN.
84-
85-
Example:
86-
* Role ARN = arn:aws:iam::123456789012:role/openshift-installer
87-
* Role Name = openshift-installer
88-
EOF
89-
}

docs/user/aws/customization.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
The following options are available when using AWS:
44

5-
- `machines.platform.aws.iamRoleName` - the IAM role that will be assigned to the machines of this pool
65
- `machines.platform.aws.rootVolume.iops` - the reserved IOPS of the root volume
76
- `machines.platform.aws.rootVolume.size` - the size (in GiB) of the root volume
87
- `machines.platform.aws.rootVolume.type` - the storage type of the root volume
@@ -29,7 +28,6 @@ machines:
2928
- name: worker
3029
platform:
3130
aws:
32-
iamRoleName: elastictranscoder-access
3331
rootVolume:
3432
iops: 4000
3533
size: 500

pkg/asset/installconfig/installconfig.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (a *InstallConfig) Generate(parents asset.Parents) error {
5555

5656
a.Config = &types.InstallConfig{
5757
TypeMeta: metav1.TypeMeta{
58-
APIVersion: "v1beta1",
58+
APIVersion: "v1beta2",
5959
},
6060
ObjectMeta: metav1.ObjectMeta{
6161
Name: clusterName.ClusterName,

0 commit comments

Comments
 (0)