I am getting an instanceProfile not found error wi...
# python
c
I am getting an instanceProfile not found error with the following script. What error am i making? import pulumi import pulumi_aws as aws import pulumi_eks as eks import os from provider_and_vpc import aws_provider, vpc from subnets_and_db import subnet1, subnet2 # Create additional subnets for EKS nodes eks_subnet1 = aws.ec2.Subnet("my-eks-subnet1", vpc_id=vpc.id, cidr_block="10.0.3.0/24", availability_zone="us-east-1c", tags={'Name': 'pulumi-eks-subnet1'}, opts=pulumi.ResourceOptions(provider=aws_provider)) eks_subnet2 = aws.ec2.Subnet("my-eks-subnet2", vpc_id=vpc.id, cidr_block="10.0.4.0/24", availability_zone="us-east-1d", tags={'Name': 'pulumi-eks-subnet2'}, opts=pulumi.ResourceOptions(provider=aws_provider)) # Create IAM Role for EKS Node Group eks_node_group_role = aws.iam.Role("eksNodeGroupRole", assume_role_policy="""{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "Service": "ec2.amazonaws.com" }, "Action": "sts:AssumeRole" } ] }""", opts=pulumi.ResourceOptions(provider=aws_provider)) # Attach the necessary policies to the role aws.iam.RolePolicyAttachment("eksNodeGroupPolicyAttachment", role=eks_node_group_role.name, policy_arn="arnawsiam:awspolicy/AmazonEKSWorkerNodePolicy", opts=pulumi.ResourceOptions(provider=aws_provider)) aws.iam.RolePolicyAttachment("eksCNIPluginPolicyAttachment", role=eks_node_group_role.name, policy_arn="arnawsiam:awspolicy/AmazonEKS_CNI_Policy", opts=pulumi.ResourceOptions(provider=aws_provider)) aws.iam.RolePolicyAttachment("eksRegistryPolicyAttachment", role=eks_node_group_role.name, policy_arn="arnawsiam:awspolicy/AmazonEC2ContainerRegistryReadOnly", opts=pulumi.ResourceOptions(provider=aws_provider)) # Create IAM Instance Profile for the EKS Node Group Role instance_profile = aws.iam.InstanceProfile("eksInstanceProfile", role=eks_node_group_role.name, opts=pulumi.ResourceOptions(provider=aws_provider)) # Create EKS Cluster cluster = eks.Cluster("my-cluster", vpc_id=vpc.id, public_subnet_ids=[subnet1.id, subnet2.id], private_subnet_ids=[eks_subnet1.id, eks_subnet2.id], instance_roles=[eks_node_group_role], opts=pulumi.ResourceOptions(provider=aws_provider)) # Create EKS Managed Node Group node_group = eks.ManagedNodeGroup("my-node-group", cluster=cluster.core, node_role_arn=eks_node_group_role.arn, subnet_ids=[eks_subnet1.id, eks_subnet2.id], scaling_config=aws.eks.NodeGroupScalingConfigArgs( desired_size=2, min_size=1, max_size=3 ), opts=pulumi.ResourceOptions(provider=aws_provider)) pulumi.export('eks_cluster_name', cluster.core.cluster.name) [8:32 PM] Saumya Garg Here is the exception information: Exception: an instanceProfile is required 123 error: Error: an instanceProfile is required 124 at /snapshot/eks/bin/nodegroup.js16319 125 at /snapshot/eks/node_modules/@pulumi/pulumi/output.js26035 126 at Generator.next (<anonymous>) 127 at /snapshot/eks/node_modules/@pulumi/pulumi/output.js2171 128 at new Promise (<anonymous>) 129 at __awaiter (/snapshot/eks/node_modules/@pulumi/pulumi/output.js1712) 130 at applyHelperAsync (/snapshot/eks/node_modules/@pulumi/pulumi/output.js23912) 131 at /snapshot/eks/node_modules/@pulumi/pulumi/output.js19363 132 at processTicksAndRejections (nodeinternal/process/task queues95:5)
d
Did not test myself but since there hasn't been much response, this is one LLM has to offer on this subject. Hope it provides solution but at least gives you some pointers. Cheers -- The error you're encountering is because the EKS Managed Node Group requires an instance profile, but it seems like it might not be correctly linked to your node group configuration. Here’s how you can fix it: 1. Ensure the instance profile is created correctly and linked to the EKS Managed Node Group. 2. The
instance_roles
argument of the
eks.Cluster
should use the instance profile role. 3. Ensure that the
instance_profile
is passed correctly to the
ManagedNodeGroup
. Here’s the corrected script:
Copy code
`python
import pulumi
import pulumi_aws as aws
import pulumi_eks as eks
import os
from provider_and_vpc import aws_provider, vpc
from subnets_and_db import subnet1, subnet2`

`# Create additional subnets for EKS nodes
eks_subnet1 = aws.ec2.Subnet("my-eks-subnet1",
                             vpc_id=vpc.id,
                             cidr_block="10.0.3.0/24",
                             availability_zone="us-east-1c",
                             tags={'Name': 'pulumi-eks-subnet1'},
                             opts=pulumi.ResourceOptions(provider=aws_provider))`

`eks_subnet2 = aws.ec2.Subnet("my-eks-subnet2",
                             vpc_id=vpc.id,
                             cidr_block="10.0.4.0/24",
                             availability_zone="us-east-1d",
                             tags={'Name': 'pulumi-eks-subnet2'},
                             opts=pulumi.ResourceOptions(provider=aws_provider))`

`# Create IAM Role for EKS Node Group
eks_node_group_role = aws.iam.Role("eksNodeGroupRole",
                                   assume_role_policy="""{
                                       "Version": "2012-10-17",
                                       "Statement": [
                                           {
                                               "Effect": "Allow",
                                               "Principal": {
                                                   "Service": "<http://ec2.amazonaws.com|ec2.amazonaws.com>"
                                               },
                                               "Action": "sts:AssumeRole"
                                           }
                                       ]
                                   }""",
                                   opts=pulumi.ResourceOptions(provider=aws_provider))`

`# Attach the necessary policies to the role
aws.iam.RolePolicyAttachment("eksNodeGroupPolicyAttachment",
                             role=eks_node_group_role.name,
                             policy_arn="arn:aws:iam::aws:policy/AmazonEKSWorkerNodePolicy",
                             opts=pulumi.ResourceOptions(provider=aws_provider))`

`aws.iam.RolePolicyAttachment("eksCNIPluginPolicyAttachment",
                             role=eks_node_group_role.name,
                             policy_arn="arn:aws:iam::aws:policy/AmazonEKS_CNI_Policy",
                             opts=pulumi.ResourceOptions(provider=aws_provider))`

`aws.iam.RolePolicyAttachment("eksRegistryPolicyAttachment",
                             role=eks_node_group_role.name,
                             policy_arn="arn:aws:iam::aws:policy/AmazonEC2ContainerRegistryReadOnly",
                             opts=pulumi.ResourceOptions(provider=aws_provider))`

`# Create IAM Instance Profile for the EKS Node Group Role
instance_profile = aws.iam.InstanceProfile("eksInstanceProfile",
                                           role=eks_node_group_role.name,
                                           opts=pulumi.ResourceOptions(provider=aws_provider))`

`# Create EKS Cluster
cluster = eks.Cluster("my-cluster",
                      vpc_id=vpc.id,
                      public_subnet_ids=[subnet1.id, subnet2.id],
                      private_subnet_ids=[eks_subnet1.id, eks_subnet2.id],
                      instance_roles=[eks_node_group_role],
                      opts=pulumi.ResourceOptions(provider=aws_provider))`

`# Create EKS Managed Node Group
node_group = eks.ManagedNodeGroup("my-node-group",
                                  cluster=cluster.core,
                                  node_role_arn=eks_node_group_role.arn,
                                  subnet_ids=[eks_subnet1.id, eks_subnet2.id],
                                  scaling_config=aws.eks.NodeGroupScalingConfigArgs(
                                      desired_size=2,
                                      min_size=1,
                                      max_size=3
                                  ),
                                  instance_profile=instance_profile.name,
                                  opts=pulumi.ResourceOptions(provider=aws_provider))`

`pulumi.export('eks_cluster_name', cluster.core.cluster.name)
`
Make sure the
instance_profile
is included in the
ManagedNodeGroup
configuration. The key addition is
instance_profile=instance_profile.name
in the
ManagedNodeGroup
creation. This should resolve the
instanceProfile not found
error.
c
i get a different error when i try that
Will post that as well
So i am wondering if it is a python library mantainence issue. I started making progress manually in this deployment and want to get back to IaC when these things get figured out. I believe in pulumi so want to bring these errors to light and work to fix them instead of giving up