I am trying to create a VPC with Pulumi crosswalk and then use the output's vpc_id to pass as argument to fetch security groups. However, being natively async, vpc object is supposedly being queried before creation causing it to throw an error:
Exception: invoke of aws:ec2/getSecurityGroup:getSecurityGroup failed: invocation of aws:ec2/getSecurityGroup:getSecurityGroup returned an error: invoking aws:ec2/getSecurityGroup:getSecurityGroup: 1 error occurred: * multiple Security Groups matched; use additional constraints to reduce matches to a single Security Group
I am unable to figure out the following:
- Why does it say there are multiple matches when there aren't?
- Why does it throw an error in preview? Does preview also make an AWS call?
- how to put a hold on the query until VPC is created, considering 'depends_on' won't work for get_security_group method? Is there a Pulumi way to handle this situation?
Following is the code snippet:
vpc = awsx.ec2.Vpc("pulumi-test",cidr_block='10.2.0.0/16',subnet_specs=[
awsx.ec2.SubnetSpecArgs(
type=awsx.ec2.SubnetType.PRIVATE,
cidr_mask=26,
),
awsx.ec2.SubnetSpecArgs(
type=awsx.ec2.SubnetType.PUBLIC,
cidr_mask=26,
)
], number_of_availability_zones=1)
security_group = aws.ec2.get_security_group(vpc_id=vpc.vpc_id)