Skip to content
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

aws configmap #3006

Open
Mieszko96 opened this issue Apr 11, 2024 · 5 comments
Open

aws configmap #3006

Mieszko96 opened this issue Apr 11, 2024 · 5 comments
Labels

Comments

@Mieszko96
Copy link

Mieszko96 commented Apr 11, 2024

hey in my current terraform i am using to manage aws configmap
i'm using module with version 19.20

resource "kubectl_manifest" "aws-auth-cm" {
  yaml_body = <<MANIFEST
apiVersion: v1
kind: ConfigMap
metadata:
  name: aws-auth
  namespace: kube-system
data:
%{if local.rancher2_import_enabled~}
  mapUsers: |
    - userarn: arn:aws:iam::${data.aws_caller_identity.current.account_id}:user/${var.rancher2_cloud_credentials_name}
      username: ${var.rancher2_cloud_credentials_name}
      groups:
      - system:masters
%{endif~}
%{if length(var.paas_eks_accounts) > 0~}
  mapAccounts: |
    ${replace(yamlencode(var.paas_eks_accounts), "\"", "")~}
%{endif~}
  mapRoles: |
    - groups:
      - system:bootstrappers
      - system:nodes
      rolearn: ${module.eks.eks_managed_node_groups["default"].iam_role_arn}
      username: system:node:{{EC2PrivateDNSName}}
%{if length(var.paas_eks_roles) > 0~}
    ${indent(4, replace(yamlencode(var.paas_eks_roles), "\"", ""))~}
%{endif~}
MANIFEST
  force_new = false
}

with eks_managed_node_groups and
create_aws_auth_configmap = false
manage_aws_auth_configmap = false

What i need to do to switch to
manage_aws_auth_configmap = true
and remove resource "kubectl_manifest" "aws-auth-cm"

What i tested.

scenario 1

removed resource "kubectl_manifest" "aws-auth-cm"
manage_aws_auth_configmap = false -> true
❌ configmap was deleted( we don't have configmap in EKS)

scenario 2
removed resource "kubectl_manifest" "aws-auth-cm"
create_aws_auth_configmap = true

❌ ✅ this scenario works, but if i use same code for brand new EKS it have error aws-auth already exist.
And i need solution for updated exisiting terraform and for brand new.

scenario 3
Also tried with moved block, but getting error

moved {
 from = kubectl_manifest.aws-auth-cm
 to   = module.eks.kubernetes_config_map_v1_data.aws_auth[0]
}

This statement declares a move from kubectl_manifest.aws-auth-cm to
module.eks.kubernetes_config_map.aws_auth[0], which is a resource instance of
a different type.

or

module.eks.kubernetes_config_map_v1_data.aws_auth[0], which is a resource
instance of a different type.

I don't mind if solution require removing state from terraform list

@Mieszko96
Copy link
Author

actually checking
https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/UPGRADE-20.0.md
it will be removed in 21.xx at all so maybe i should not do this.

But if you have opinion/suggestions please let me know

@kaykhan
Copy link

kaykhan commented Apr 16, 2024

@Mieszko96 Do you know if there new method to handle who has auth to use the cluster? is it access_entries?

@groovyghost
Copy link

@kaykhan
Copy link

kaykhan commented Apr 22, 2024

@kaykhan It has been moved to submodule https://registry.terraform.io/modules/terraform-aws-modules/eks/aws/20.8.5/submodules/aws-auth

This sub module is going to be removed in the next version (21) https://github.com/terraform-aws-modules/terraform-aws-eks/blob/master/docs/UPGRADE-20.0.md#%EF%B8%8F-upcoming-changes-planned-in-v210-%EF%B8%8F

So just curious how to handle it moving forward.

Im wondering if we should now be creating this resource ourselves. https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/config_map_v1

@bryantbiggs
Copy link
Member

its a separate sub-module and the code has not changed for this functionality for several years. Even though the code will be removed in v21, theres nothing stopping you from using the sub-module at v20 for years to come.

However, long term the strategy is to use cluster access entries

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants