-
Notifications
You must be signed in to change notification settings - Fork 1
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
Allow EKS cluster creation when multiple AWS profile are defined #13
Conversation
@@ -11,7 +12,7 @@ provider "kubernetes" { | |||
|
|||
exec { | |||
api_version = "client.authentication.k8s.io/v1beta1" | |||
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name, "--region", var.AWS_REGION] | |||
args = ["eks", "get-token", "--cluster-name", module.eks.cluster_name, "--region", var.AWS_REGION, "--profile", var.AWS_PROFILE] |
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.
This means the profile will take precedence over AWS_*
s which were used by Terraform for creating AWS resources. Two approaches could well be using different users/roles. Is that possible to make the profile optional?
FYI, https://registry.terraform.io/providers/hashicorp/aws/latest/docs
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.
Further tested the PR today and found the profile will also take precedence in provider "aws" so that's probably fine. But if TF_VAR_AWS_REGION
is set to eu-west-1 whilst the default profile has region
set to eu-west-2, the following error will occur:
│ Error: Have got the following error while validating the existence of the ConfigMap "aws-auth": Unauthorized
│
│ with module.eks.kubernetes_config_map_v1_data.aws_auth[0],
│ on .terraform/modules/eks/main.tf line 553, in resource "kubernetes_config_map_v1_data" "aws_auth":
│ 553: resource "kubernetes_config_map_v1_data" "aws_auth" {
This makes me think the configuration is better to be set via either env vars alone or a profile alone but not both. Any thoughts?
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'm not sure what the best practice to handle terraform variables but I'm using tfvar files at the moment to store the configuration which also includes AWS variables, I think as long as it's possible to specify a profile via tfvar files the rest shouldn't be an issue and we can implement it differently.
Another finding is the limit on the length of the name_prefix for a node group. If the cluster name is set to "dev-radar-base-cluster" which used to work, the following errors will occur:
|
I don't know where |
That part must have come from the eks module and longer names could violate the AWS rule on naming the Node IAM role. I can see the "Security group name" column does contain the cluster name although that's probably not ideal. |
7fd2490
to
b4939d8
Compare
Fixed the conflicts and things seems to be working now. |
@baixiac this PR is also ready for review |
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.
LGTM
Aiming to fix #5.
Also added the cluster prefix to the node groups so they'd be easier to distinguish EC2 servers list. Note: This will delete and recreate node groups, might cause slight disruptions.