Skip to content

Commit 8b01b8c

Browse files
authored
Merge pull request #1346 from spack/remove-drift-detection
Remove drift detection job and permissions
2 parents 53649d7 + 74a8845 commit 8b01b8c

3 files changed

Lines changed: 2 additions & 165 deletions

File tree

.github/workflows/terraform-drift-detection.yaml

Lines changed: 0 additions & 81 deletions
This file was deleted.

terraform/modules/spack_aws_k8s/eks.tf

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,24 +38,8 @@ module "eks" {
3838
}
3939
}
4040
}
41-
},
42-
# Only create github_actions access entry on production cluster, since that's
43-
# the only one we run the TF drift detection job on.
44-
var.deployment_name == "prod" ? {
45-
github_actions_drift_detection = {
46-
kubernetes_groups = []
47-
principal_arn = aws_iam_role.github_actions_readonly[0].arn
48-
49-
policy_associations = {
50-
cluster = {
51-
policy_arn = "arn:aws:eks::aws:cluster-access-policy/AmazonEKSAdminViewPolicy"
52-
access_scope = {
53-
type = "cluster"
54-
}
55-
}
56-
}
57-
}
58-
} : {})
41+
}
42+
)
5943

6044
# NOTE: Additional configuration of these addons (like in the vpc-cni addon below) won't necessarily
6145
# take immediate effect, as it is configuring the addon, not anything in the cluster directly.

terraform/modules/spack_aws_k8s/github_actions_iam.tf

Lines changed: 0 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -10,72 +10,6 @@ resource "aws_iam_openid_connect_provider" "github_actions" {
1010
thumbprint_list = [data.tls_certificate.github_actions.certificates.0.sha1_fingerprint]
1111
}
1212

13-
resource "aws_iam_role" "github_actions_readonly" {
14-
count = var.deployment_name == "prod" ? 1 : 0
15-
16-
name = "GitHubActionsReadonlyRole"
17-
description = "Managed by Terraform. IAM Role that a GitHub Actions runner can assume to authenticate with AWS."
18-
19-
assume_role_policy = jsonencode({
20-
"Version" : "2012-10-17",
21-
"Statement" : [
22-
{
23-
"Effect" : "Allow",
24-
"Principal" : {
25-
"Federated" : aws_iam_openid_connect_provider.github_actions[0].arn
26-
},
27-
"Action" : "sts:AssumeRoleWithWebIdentity",
28-
"Condition" : {
29-
"StringLike" : {
30-
"token.actions.githubusercontent.com:sub" : "repo:spack/spack-infrastructure:ref:refs/heads/main",
31-
"token.actions.githubusercontent.com:aud" : "sts.amazonaws.com"
32-
}
33-
}
34-
},
35-
{
36-
"Action" : "sts:AssumeRole",
37-
"Principal" : {
38-
# Unfortunately, we need to do this until https://github.com/hashicorp/terraform-provider-aws/issues/27034 is resolved.
39-
# This trust statement allows the role to assume itself, which is necessary for the GitHub Actions session user to run terraform plan.
40-
"AWS" : "arn:aws:sts::${data.aws_caller_identity.current.account_id}:assumed-role/GitHubActionsReadonlyRole/GitHubActions"
41-
},
42-
"Effect" : "Allow",
43-
},
44-
]
45-
})
46-
}
47-
48-
# The `ReadOnlyAccess` managed policy doesn't include secretsmanager, so we explicitly grant it here.
49-
resource "aws_iam_role_policy" "github_actions_readonly" {
50-
count = var.deployment_name == "prod" ? 1 : 0
51-
52-
name = "read-secrets"
53-
role = aws_iam_role.github_actions_readonly[0].id
54-
55-
policy = jsonencode({
56-
"Version" : "2012-10-17",
57-
"Statement" : [
58-
{
59-
"Effect" : "Allow",
60-
"Action" : [
61-
"secretsmanager:GetSecretValue"
62-
],
63-
"Resource" : "*"
64-
}
65-
]
66-
})
67-
}
68-
69-
# This policy grants the GitHub Actions role read-only access to most resources in the AWS account.
70-
# There are some exceptions, such as secretsmanager (see inline_policy above)
71-
resource "aws_iam_role_policy_attachment" "github_actions_readonly" {
72-
count = var.deployment_name == "prod" ? 1 : 0
73-
74-
role = aws_iam_role.github_actions_readonly[0].name
75-
policy_arn = "arn:aws:iam::aws:policy/ReadOnlyAccess"
76-
}
77-
78-
7913
# Allow github actions run from the develop branch of spack/spack to put objects into the source mirror
8014
resource "aws_iam_role" "github_actions_put_to_source_mirror" {
8115
count = var.deployment_name == "prod" ? 1 : 0

0 commit comments

Comments
 (0)