Greetings. I'm new to pulumi and Go. I'm trying to...
# golang
a
Greetings. I'm new to pulumi and Go. I'm trying to figure out how to add a random suffix to resource names. Something along the lines of:
Copy code
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {

		// Create a random ID for our EC2 instance name with keepers.
		randomId, err := random.NewRandomId(ctx, "instanceId", &random.RandomIdArgs{
			ByteLength: <http://pulumi.Int|pulumi.Int>(4),
			Keepers: pulumi.Map{
				"resource_type": pulumi.String("ec2_instance"),
				"name_prefix":   pulumi.String("my-prefix"),
			},
		})
		if err != nil {
			return err
		}

		// Create an EC2 instance with a name that includes the random ID.
		instanceName := pulumi.Sprintf("my-instance-%s", randomId.Hex)

		_, err = ec2.NewInstance(ctx, instanceName, &ec2.InstanceArgs{
			InstanceType: pulumi.String("t2.micro"),
			Ami:          pulumi.String("ami-0c55b159cbfafe1f0"), // Example AMI
			Tags: pulumi.StringMap{
				"Name": instanceName,
			},
		})
		if err != nil {
			return err
		}

		return nil
	})

}