Skip to content

Example code for getRouteTables doesn't work #622

@stooj

Description

@stooj

Describe what happened

The example code for aws.ec2.getRouteTables | Pulumi Registry doesn't work because of the loop control.

Sample program

using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Aws = Pulumi.Aws;

return await Deployment.RunAsync(() => 
{
    var rts = Aws.Ec2.GetRouteTables.Invoke(new()
    {
        VpcId = vpcId,
        Filters = new[]
        {
            new Aws.Ec2.Inputs.GetRouteTablesFilterInputArgs
            {
                Name = "tag:kubernetes.io/kops/role",
                Values = new[]
                {
                    "private*",
                },
            },
        },
    });

    var r = new List<Aws.Ec2.Route>();
    for (var rangeIndex = 0; rangeIndex < rts.Apply(getRouteTablesResult => getRouteTablesResult.Ids).Length; rangeIndex++)
    {
        var range = new { Value = rangeIndex };
        r.Add(new Aws.Ec2.Route($"r-{range.Value}", new()
        {
            RouteTableId = rts.Apply(getRouteTablesResult => getRouteTablesResult.Ids)[range.Value],
            DestinationCidrBlock = "10.0.0.0/22",
            VpcPeeringConnectionId = "pcx-0e9a7a9ecd137dc54",
        }));
    }
});

Log output

Error is:

error CS0019: Operator '<' cannot be applied to operands of type 'int' and 'method group' 

Affected Resource(s)

  • getRouteTables

Output of pulumi about

This would apply to any version, I think.

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction.
To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/codegenkind/bugSome behavior is incorrect or out of spec

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions