Skip to content

Commit a491cac

Browse files
authored
terraform: update AWS LB permissions (#3681)
* bazel: add download rules for AWS LB policy * docs: add migration notice * terraform: re-download lb policy
1 parent a1e2474 commit a491cac

File tree

7 files changed

+79
-4
lines changed

7 files changed

+79
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
load("//bazel/sh:def.bzl", "sh_template")
2+
3+
sh_template(
4+
name = "pull_files",
5+
data = [
6+
"@com_github_kubernetes_sigs_aws_load_balancer_controller//:lb_policy",
7+
],
8+
substitutions = {
9+
"@@POLICY_SRC@@": "$(rootpath @com_github_kubernetes_sigs_aws_load_balancer_controller//:lb_policy)",
10+
},
11+
template = "pull_files.sh",
12+
visibility = ["//visibility:public"],
13+
)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
###### script header ######
4+
5+
lib=$(realpath @@BASE_LIB@@) || exit 1
6+
stat "${lib}" >> /dev/null || exit 1
7+
8+
# shellcheck source=../../../bazel/sh/lib.bash
9+
if ! source "${lib}"; then
10+
echo "Error: could not find import"
11+
exit 1
12+
fi
13+
14+
controller_policy_source="@@POLICY_SRC@@"
15+
16+
###### script body ######
17+
18+
controller_policy_real_source=$(realpath "${controller_policy_source}")
19+
20+
cd "${BUILD_WORKSPACE_DIRECTORY}" # needs to be done after realpath
21+
22+
targetDir="terraform/infrastructure/iam/aws/alb_policy.json"
23+
24+
cp "${controller_policy_real_source}" "${targetDir}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
"""A module defining the source of the AWS load balancer controller."""
2+
3+
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
4+
5+
def aws_load_balancer_controller_deps():
6+
http_archive(
7+
name = "com_github_kubernetes_sigs_aws_load_balancer_controller",
8+
urls = [
9+
"https://cdn.confidential.cloud/constellation/cas/sha256/0cb78cdff9742945c9968ac12c785164a052b52260d19d218bb28a8bec04a2fd",
10+
"https://github.com/kubernetes-sigs/aws-load-balancer-controller/archive/refs/tags/v2.11.0.tar.gz",
11+
],
12+
strip_prefix = "aws-load-balancer-controller-2.11.0",
13+
build_file_content = """
14+
filegroup(
15+
srcs = ["docs/install/iam_policy.json"],
16+
name = "lb_policy",
17+
visibility = ["//visibility:public"],
18+
)
19+
""",
20+
type = "tar.gz",
21+
sha256 = "0cb78cdff9742945c9968ac12c785164a052b52260d19d218bb28a8bec04a2fd",
22+
)

WORKSPACE.bzlmod

+4
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,10 @@ load("//3rdparty/bazel/com_github_medik8s_node_maintainance_operator:source.bzl"
234234

235235
node_maintainance_operator_deps()
236236

237+
load("//3rdparty/bazel/com_github_kubernetes_sigs_aws_load_balancer_controller:source.bzl", "aws_load_balancer_controller_deps")
238+
239+
aws_load_balancer_controller_deps()
240+
237241
# CI deps
238242
load("//bazel/toolchains:ci_deps.bzl", "ci_deps")
239243

bazel/ci/BUILD.bazel

+1
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,7 @@ multirun(
558558
commands = [
559559
":terraform_gen",
560560
"//3rdparty/bazel/com_github_medik8s_node_maintainance_operator:pull_files",
561+
"//3rdparty/bazel/com_github_kubernetes_sigs_aws_load_balancer_controller:pull_files",
561562
":go_generate",
562563
":proto_generate",
563564
],

docs/docs/reference/migration.md

+8-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,13 @@ done
3636
echo "All specified rules have been deleted."
3737
```
3838

39-
## Migrations to v2.19.0
39+
## Migrating from CLI versions before 2.21.1
40+
41+
### AWS
42+
43+
* AWS clusters that use `LoadBalancer` resources require more IAM permissions. Please upgrade your IAM roles using `constellation iam upgrade apply`. This will show necessary changes and apply them, if desired.
44+
45+
## Migrating from CLI versions before 2.19.0
4046

4147
### Azure
4248

@@ -46,7 +52,7 @@ echo "All specified rules have been deleted."
4652
If your Constellation has services of type `LoadBalancer`, please remove them before the upgrade and re-apply them
4753
afterward.
4854

49-
## Migrating from Azure's service principal authentication to managed identity authentication (during the upgrade to Constellation v2.8.0)
55+
## Migrating from CLI versions before 2.18.0
5056

5157
* The `provider.azure.appClientID` and `provider.azure.appClientSecret` fields are no longer supported and should be removed.
5258
* To keep using an existing UAMI, add the `Owner` permission with the scope of your `resourceGroup`.

terraform/infrastructure/iam/aws/alb_policy.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
"ec2:DescribeTags",
3030
"ec2:GetCoipPoolUsage",
3131
"ec2:DescribeCoipPools",
32+
"ec2:GetSecurityGroupsForVpc",
3233
"elasticloadbalancing:DescribeLoadBalancers",
3334
"elasticloadbalancing:DescribeLoadBalancerAttributes",
3435
"elasticloadbalancing:DescribeListeners",
@@ -39,7 +40,9 @@
3940
"elasticloadbalancing:DescribeTargetGroupAttributes",
4041
"elasticloadbalancing:DescribeTargetHealth",
4142
"elasticloadbalancing:DescribeTags",
42-
"elasticloadbalancing:DescribeTrustStores"
43+
"elasticloadbalancing:DescribeTrustStores",
44+
"elasticloadbalancing:DescribeListenerAttributes",
45+
"elasticloadbalancing:DescribeCapacityReservation"
4346
],
4447
"Resource": "*"
4548
},
@@ -188,7 +191,9 @@
188191
"elasticloadbalancing:DeleteLoadBalancer",
189192
"elasticloadbalancing:ModifyTargetGroup",
190193
"elasticloadbalancing:ModifyTargetGroupAttributes",
191-
"elasticloadbalancing:DeleteTargetGroup"
194+
"elasticloadbalancing:DeleteTargetGroup",
195+
"elasticloadbalancing:ModifyListenerAttributes",
196+
"elasticloadbalancing:ModifyCapacityReservation"
192197
],
193198
"Resource": "*",
194199
"Condition": {

0 commit comments

Comments
 (0)