-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
feat: Add security groups and policies to worker launcher template #933
Conversation
Modified aws_security_group.workers to not depend on aws_eks_cluster.this as it would cause circular dependency. This should prevent SGs from being destroyed until after cluster is destroyed.
aws_autoscaling_groups.workers already depends on aws_launch_configuration.workers and aws_launch_configuration.workers is where the security group dependencies are set, makes the most sense here instead of at the ASG level.
depends_on = [ | ||
aws_security_group_rule.workers_egress_internet, | ||
aws_security_group_rule.workers_ingress_self, | ||
aws_security_group_rule.workers_ingress_cluster, | ||
aws_security_group_rule.workers_ingress_cluster_kubelet, | ||
aws_security_group_rule.workers_ingress_cluster_https, | ||
aws_security_group_rule.workers_ingress_cluster_primary, | ||
aws_security_group_rule.cluster_primary_ingress_workers, | ||
aws_iam_role_policy_attachment.workers_AmazonEKSWorkerNodePolicy, | ||
aws_iam_role_policy_attachment.workers_AmazonEKS_CNI_Policy, | ||
aws_iam_role_policy_attachment.workers_AmazonEC2ContainerRegistryReadOnly, | ||
aws_iam_role_policy_attachment.workers_additional_policies | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please duplicate this on the aws_launch_template
in workers_launch_template.tf
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've made the change, however, now I am thinking it might be a better approach to do this rather than copy/pasting the code. This should also help cover future scenarios.
worker_security_group_id = var.worker_create_security_group ? null_resource.worker_security_group_setup.worker_security_group_id : var.worker_security_group_id
resource "null_resource" "worker_security_group_setup" {
worker_security_group_id = join("", aws_security_group.workers.*.id)
depends_on = [
aws_security_group_rule.workers_egress_internet,
aws_security_group_rule.workers_ingress_self,
aws_security_group_rule.workers_ingress_cluster,
aws_security_group_rule.workers_ingress_cluster_kubelet,
aws_security_group_rule.workers_ingress_cluster_https,
aws_security_group_rule.workers_ingress_cluster_primary,
aws_security_group_rule.cluster_primary_ingress_workers,
aws_iam_role_policy_attachment.workers_AmazonEKSWorkerNodePolicy,
aws_iam_role_policy_attachment.workers_AmazonEKS_CNI_Policy,
aws_iam_role_policy_attachment.workers_AmazonEC2ContainerRegistryReadOnly,
aws_iam_role_policy_attachment.workers_additional_policies
]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know your thoughts on this when you have time, thanks!
…h_template aws_launch_template also depends on worker_security_group_id
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, been a bit busy lately. Finally found time to spin up a test cluster. This all appears to work correctly.
Thank you for your PR
…roup rules and IAM policies (terraform-aws-modules#933) In order to ensure proper ordering when running terraform destroy. This will block Terraform from removing up security group rules before the cluster has finished its clean up chores.
I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further. |
PR o'clock
References #934
Add
workers_egress_internet
security group (and all other security groups and policies) as dependencies to the worker launch config.Description
In order to ensure proper ordering when running terraform destroy, I need to be able to establish an explicit dependency on the exposed resource because that resource allows pods to communicate with the control plane. Without being able to declare the dependency, terraform will likely destroy the rule early, which will prevent other resources from proper destruction. This makes the workers depend on the SGs and policies without exposing the internals.
Checklist