pulumi / pulumi-aws

An Amazon Web Services (AWS) Pulumi resource package, providing multi-language access to AWS
Apache License 2.0
459 stars 155 forks source link

Issue based on generated docs #2468

Open georgettica opened 1 year ago

georgettica commented 1 year ago

Hello!

Issue details

As a developer, I wanted to touch the peering connections in python. I went to the pulumi website and code I copy pasted was not valid.

thus a PR was created to modify the exact code that needs to be configured to make the peering more correct

This issue was created after the https://github.com/pulumi/pulumi-aws/pull/2451

Affected area/feature

When copy pasting code, this documentation was not clear for me and not usable, so I checked it. Also maybe a longer for this code is in order

mikhailshilkov commented 1 year ago

@georgettica Could you please extend the description to explain the issue in details? I.e. reference the example, show what is wrong about it, etc. Thank you!

georgettica commented 1 year ago

Yes, I just wrote the original one in the PR, will port it here so we can discuss it further

georgettica commented 1 year ago

@mikhailshilkov the main description was modified and I can the errors I got from running the sample code on my machine

mikhailshilkov commented 1 year ago

code I copy pasted was not valid.

@georgettica Could you please add the code itself to the issue and specify what is not correct about it? This helps us triage the issue further. Thank you!

georgettica commented 1 year ago

the updated code is in the following collapsable seciton

click this to see the code ```go package main import ( "github.com/pulumi/pulumi-aws/sdk/v5/go/aws" "github.com/pulumi/pulumi-aws/sdk/v5/go/aws/ec2" "github.com/pulumi/pulumi/sdk/v3/go/pulumi" ) func main() { pulumi.Run(func(ctx *pulumi.Context) error { awsPeer, err := aws.NewProvider(ctx, "peer", &aws.ProviderArgs{ Region: pulumi.String("us-west-2"), }) if err != nil { return err } main, err := ec2.NewVpc(ctx, "main", &ec2.VpcArgs{ CidrBlock: pulumi.String("10.0.0.0/16"), }) if err != nil { return err } peerVpc, err := ec2.NewVpc(ctx, "peerVpc", &ec2.VpcArgs{ CidrBlock: pulumi.String("10.1.0.0/16"), }, pulumi.Provider(awsPeer)) if err != nil { return err } peerCallerIdentity, err := aws.GetCallerIdentity(ctx, nil, nil) if err != nil { return err } peerVpcPeeringConnection, err := ec2.NewVpcPeeringConnection(ctx, "peerVpcPeeringConnection", &ec2.VpcPeeringConnectionArgs{ VpcId: main.ID(), PeerVpcId: peerVpc.ID(), PeerOwnerId: pulumi.String(peerCallerIdentity.AccountId), PeerRegion: pulumi.String("us-west-2"), AutoAccept: pulumi.Bool(false), Tags: pulumi.StringMap{ "Side": pulumi.String("Requester"), }, }) if err != nil { return err } _, err = ec2.NewVpcPeeringConnectionAccepter(ctx, "peerVpcPeeringConnectionAccepter", &ec2.VpcPeeringConnectionAccepterArgs{ VpcPeeringConnectionId: peerVpcPeeringConnection.ID(), AutoAccept: pulumi.Bool(true), Tags: pulumi.StringMap{ "Side": pulumi.String("Accepter"), }, }, pulumi.Provider(awsPeer)) if err != nil { return err } return nil }) } ```

and the fixes were:

georgettica commented 1 year ago

@mikhailshilkov please look at the previous message where I answered your questions