Hi all, I am a bit confused on how to specify in w...
# aws
a
Hi all, I am a bit confused on how to specify in which VPC a Neptune cluster must be created. In the AWS interface I get a pulldown and I can select a VPC. With the Go SDK, I have not found a way to do it?
Oh, the AI showed me. This seems to work:
Copy code
package main

import (
    "<http://github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2|github.com/pulumi/pulumi-aws/sdk/v4/go/aws/ec2>"
    "<http://github.com/pulumi/pulumi-aws/sdk/v4/go/aws/neptune|github.com/pulumi/pulumi-aws/sdk/v4/go/aws/neptune>"
    "<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>"
)

func() {
    pulumi.Run(func(ctx *pulumi.Context) error {
        // Create a new VPC
        vpc, err := ec2.NewVpc(ctx, "testVpc", &ec2.VpcArgs{
            CidrBlock: pulumi.String("10.0.0.0/16"),
        })
        if err != nil {
            return err
        }

        // Create a new Subnet within the VPC
        subnet, err := ec2.NewSubnet(ctx, "testSubnet", &ec2.SubnetArgs{
            VpcId:     vpc.ID(),
            CidrBlock: pulumi.String("10.0.1.0/24"),
        })
        if err != nil {
            return err
        }

        // Create a Neptune Subnet Group using the created subnet
        neptuneSubnetGroup, err := neptune.NewSubnetGroup(ctx, "testNeptuneSubnetGroup", &neptune.SubnetGroupArgs{
            SubnetIds: pulumi.StringArray{
                subnet.ID(),
            },
            Description: pulumi.String("Neptune Subnet Group created by Pulumi"),
        })

        // Create a Neptune Cluster in the VPC
        _, err = neptune.NewCluster(ctx, "neptuneCluster", &neptune.ClusterArgs{
            Engine:               pulumi.String("neptune"),
            NeptuneSubnetGroupName:      neptuneSubnetGroup.Name,
        })
        if err != nil {
            return err
        }

        // Export the IDs of the created resources
        ctx.Export("vpcId", vpc.ID())
        ctx.Export("subnetId", subnet.ID())
        ctx.Export("neptuneSubnetGroupId", neptuneSubnetGroup.ID())

        return nil
    })
}
s
Yeah, you can create a new VPC (which is what it looks like your code does); that’s probably easiest. Alternately, if you absolutely must use an existing VPC, the Go SDK has a
LookupVpc
function to let you “get” information for an existing VPC.
a
Thanks! Creating a new VPC was what I was after. I want to set up identical infra for different customers in separate VPC's.
s
Perfect, looks like you’re good to go!