简体   繁体   English

将 IAM 角色附加到实例配置文件时出错

[英]Error Attaching IAM Role to an Instance Profile

I am trying to attach an IAM role to an instance profile for aws karpenter to be able to provision nodes on my behalf.我正在尝试将 IAM 角色附加到 aws karpenter 的实例配置文件,以便能够代表我预置节点。 I have already created the role, role-karpenter , from the console.我已经从控制台创建了角色role-karpenter

Below is the terraform script:下面是 terraform 脚本:

data "aws_iam_role" "karpenter_node_group_role" {
  name = "role-karpenter"
}

resource "aws_iam_instance_profile" "karpenter" {
  name = "KarpenterNodeInstanceProfile"
  role = data.aws_iam_role.karpenter_node_group_role.name
}

This is the Error I am getting:这是我得到的错误:

removing role arn:aws:iam::xxxx:role/role-karpenter from IAM instance profile KarpenterNodeInstanceProfile-cluster: ValidationError: The specified value for roleName is invalid. It must contain only alphanumeric characters and/or the following: +=,.@_-
│   status code: 400, request id: 7e631745-e7cb-4542-b19f-2b3872c8cbc3

Options I have tried: I have used all these different terraform attribute references for the role我尝试过的选项:我已经为角色使用了所有这些不同的 terraform 属性引用

# name attribute
role = data.aws_iam_role.karpenter_node_group_role.name

# id attribute
role = data.aws_iam_role.karpenter_node_group_role.id

# arn attribute
role = data.aws_iam_role.karpenter_node_group_role.arn

The fix for me was to remove the resource from the state file and rerun it again我的解决方法是从 state 文件中删除资源并重新运行它

terraform state rm module.eks.aws_iam_instance_profile.karpenter

Then然后

terraform plan && terraform apply

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM