https://pulumi.com logo
Title
g

glamorous-fall-57889

03/21/2023, 7:58 AM
Hi Folks, I've discovered what seems to be a bug (perhaps I'm not creating the code in a "friendly" way), it looks to be some kind of race condition. I thought I'd post here before creating an issue in Github. Code:
"""An AWS Python Pulumi program"""
import iam
import pulumi
from pulumi import automation as auto
import pulumi_aws as aws
import sys


def pulumi_function():
    
    main_vpc = aws.ec2.Vpc(resource_name="main-vpc", cidr_block="10.0.0.0/16")

     
    subnet_ids = []
    for index, zone in enumerate(aws.get_availability_zones().names):
        vpc_subnet=aws.ec2.Subnet(f"subnet_{zone}", 
                                      vpc_id=main_vpc.id, cidr_block=f"10.0.{index}.0/24",
                                      availability_zone=zone)
        subnet_ids.append(vpc_subnet.id)
 
    eks_cluster = aws.eks.Cluster('eks-cluster', role_arn=iam.eks_role.arn,tags={'Name': 'pulumi-eks-cluster','Owner': 'xxx' },
    vpc_config=aws.eks.ClusterVpcConfigArgs(
        # public_access_cidrs=['0.0.0.0/0'],
        subnet_ids=subnet_ids
    ),
    )




    # pulumi.export('vpc_id', main_vpc.id)

destroy = False
args = sys.argv[1:]
if len(args) > 0:
    if args[0] == "destroy":
        destroy = True


project_name = "eks_project"
stack_name = "dev"

stack = auto.create_or_select_stack(stack_name=stack_name,
                                    project_name=project_name,
                                    program=pulumi_function)

print(f"Successfully initialized stack: {stack_name}")


if destroy:
    print("destroying stack...")
    stack.destroy(on_output=print)
    print("stack destroy complete")
    sys.exit()


stack.set_config("aws:region", auto.ConfigValue(value="eu-west-2"))
stack.up(on_output=print)
Error I get when I run (via python not the Pulumi CLI):
(venv) xxxx@xxxxs-MBP pulumi % python __main__.py        
Successfully initialized stack: dev
Updating (dev):

 +  pulumi:pulumi:Stack eks_project-dev creating (0s)
 +  aws:ec2:Vpc main-vpc creating (0s)
 +  pulumi:pulumi:Stack eks_project-dev creating (0s) error: python inline source runtime error: Task <Task pending name='Task-235' coro=<register_resource.<locals>.do_register() running at /Users/xxxx/projects/pulumi/venv/lib/python3.9/site-packages/pulumi/runtime/resource.py:811> cb=[<TaskWakeupMethWrapper object at 0x1065e2e50>()]> got Future <Future pending> attached to a different loop
 +  pulumi:pulumi:Stack eks_project-dev creating (0s) error: an unhandled error occurred: python inline source runtime error: Task <Task pending name='Task-235' coro=<register_resource.<locals>.do_register() running at /Users/xxxx/projects/pulumi/venv/lib/python3.9/site-packages/pulumi/runtime/resource.py:811> cb=[<TaskWakeupMethWrapper object at 0x1065e2e50>()]> got Future <Future pending> attached to a different loop
@ updating....
 +  aws:ec2:Vpc main-vpc created (1s)
@ updating.......
 +  pulumi:pulumi:Stack eks_project-dev **creating failed (0.49s)** 2 errors
There is more stack trace / diagnostics here