Hey all! I am trying to use a resource imported fr...
# general
b
Hey all! I am trying to use a resource imported from another project but I get the error
'dependsOn' was passed a value that was not a Resource.
I'm unable to find any helpful explanation where the error comes from and most important how to solve it.
👀 1
c
s
the type signature is
dependsOn?: Input<Input<Resource>[]> | Input<Resource>;
so just a resource should work
c
@steep-portugal-37539 Yes. I suspect @bored-barista-23480 did pass an ARN as Output<string>
👍 1
b
That's what I find strange (and didn't make clear in my post, sorry for that): I did not explicitly set any
dependsOn
option. I'm just trying to use imported resources as an input.
c
uh? never seen that. you have code you can share?
b
It's really not that complicated. I tried to boil it down (don't confuse
cluster
and
clusher
). First project:
Copy code
def createSubnet(number: int, vpc: aws.ec2.Vpc) -> aws.ec2.Subnet:

    return aws.ec2.Subnet(f"SATORI-subnet-{number}",
        vpc_id                  = vpc.id,
        cidr_block              = getSubnetCIDR(number),
        availability_zone       = aws.get_region().name + availabilityZones[number],
        map_public_ip_on_launch = True,
        tags                    = {
            "<http://kubernetes.io/role/elb|kubernetes.io/role/elb>" : "1",
            f"<http://kubernetes.io/cluster/{clusterName}|kubernetes.io/cluster/{clusterName}>" : "shared"
        }
    )

def createNodeRole(name: str) -> aws.iam.Role:
    role = aws.iam.Role(name,
        assume_role_policy = json.dumps({
            "Version": "2012-10-17",
            "Statement": [
                {
                    "Sid": "AllowAssumeRole",
                    "Effect": "Allow",
                    "Principal": {
                        "Service": "<http://ec2.amazonaws.com|ec2.amazonaws.com>"
                    },
                    "Action": "sts:AssumeRole"
                }
            ]
        })
    )

    for i, policy in enumerate(managedPolicyARNs):
        aws.iam.RolePolicyAttachment(f'{name}-policy-{i}',
            aws.iam.RolePolicyAttachmentArgs(
                policy_arn = policy,
                role       = role,
            )
        )

    return role

# do stuff

subnets = [ createSubnet(number, vpc) for number in range(3) ]

clusherNodeRole   = iam.createNodeRole(f"SATORI-clusher-role")

# do stuff

cluster = eks.Cluster("SATORI-cluster",
    name                    = clusterName,
    skip_default_node_group = True,
    create_oidc_provider    = True,
    subnet_ids              = [ subnet.id for subnet in subnets ],
    vpc_id                  = vpc.id,
    instance_roles          = [ clusherNodeRole, backendNodeRole, \
        frontendNodeRole, accessoryNodeRole ]
)

# do stuff...

pulumi.export("subnetIds", map(lambda sn: sn.id, subnets))
pulumi.export("clusherNodeRole", clusherNodeRole)
pulumi.export("clusterCore", cluster.core)
Second project:
Copy code
clusterCore      = initStack.get_output("clusterCore")
subnetIds        = initStack.get_output("subnetIds")
clusherNodeRole  = initStack.get_output("clusherNodeRole")

backendNodeGroup = eks.ManagedNodeGroup("clusher-node-group",
        cluster          = clusterCore,
        node_role        = "clusherNodeRole",
        instance_types   = [ backendType ],
        node_group_name  = "clusher-node-group",
        subnet_ids       = subnetIds
        ],
        labels           = {
            "nodeType" : "clusher"
        },
        scaling_config   = aws.eks.NodeGroupScalingConfigArgs(
            desired_size = config.backendSize["desiredSize"],
            min_size     = config.backendSize["minimumSize"],
            max_size     = config.backendSize["maximumSize"]
        ),
        tags             = {
            "<http://k8s.io/cluster-autoscaler/MyCluster|k8s.io/cluster-autoscaler/MyCluster>" : "owned",
            "<http://k8s.io/cluster-autoscaler/enabled|k8s.io/cluster-autoscaler/enabled>"   : "TRUE"
        }
    )