Hi Team , I am new to Pulumi, running the Automati...
# general
l
Hi Team , I am new to Pulumi, running the Automation api to provision the ec2 machine and getting following error
Copy code
Created/Selected stack "dev"
Successfully installed AWS plugin
Successfully set config
Starting refresh
Failed to refresh stack: failed to refresh stack: code: 1
, stdout:
, stderr: Error: unknown command "history" for "pulumi"
Run 'pulumi --help' for usage.
An error occurred: unknown command "history" for "pulumi"

: failed to get stack history: exit status 1
exit status 1
Any idea what is this error related to
l
Looks like you are using v2 of the pulumi SDK with v3 of the CLI. You will need to use v3 with v3.
l
I see ,
thanks
So Just update the go mod file with the v3 sdk right ?
l
and the import paths in your go program
There are a few examples in this repo that you can work off of https://github.com/pulumi/automation-api-examples/blob/main/go/inline_program/main.go#L9
l
Thanks
I am also using , Do i need to replace with v3 for aws as well, in some examples I see v4 for the aws ec2
Copy code
"<http://github.com/pulumi/pulumi-aws/sdk/v2/go/aws|github.com/pulumi/pulumi-aws/sdk/v2/go/aws>"
"<http://github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ec2|github.com/pulumi/pulumi-aws/sdk/v2/go/aws/ec2>"
l
You should be using v4 for pulumi-aws. Latest is best 🙂
Only the Pulumi CLI and core Pulumi libs share version numbers. The others may have version dependencies, but you can't figure them out from the numbers.
l
Thanks
Now getting following error . wondering how can I solve
stderr: error: PULUMI_ACCESS_TOKEN must be set for login during non-interactive CLI sessions
l
Sounds like you have not authenticated your pulumi CLI.
The getting started should walk you through getting this set up https://www.pulumi.com/docs/get-started/
l
Do I still need Pulumi cli , if I am using automation api
Can I not Authenticate using code
Usecase I am working wont have access to the cli
l
You do need the pulumi CLI to use automation API. The automation API is an interface to the pulumi engine embedded in the CLI
👍 1
l
I made the change to v3 sdk and now getting the following error
./main.go:84:54: cannot use ctx (type *"<http://github.com/pulumi/pulumi/sdk/v3/go/pulumi|github.com/pulumi/pulumi/sdk/v3/go/pulumi>".Context) as type *"<http://github.com/pulumi/pulumi/sdk/v2/go/pulumi|github.com/pulumi/pulumi/sdk/v2/go/pulumi>".Context in argument to "<http://github.com/pulumi/pulumi-aws/sdk/v3/go/aws|github.com/pulumi/pulumi-aws/sdk/v3/go/aws>".GetAvailabilityZones
Code was working fine on v2 sdk
b
Hi @late-energy-66663 Your types are still not correct here - can you show me the contents of your main.go and I can help?
it looks to me like you need to bump pulumi-aws to v4
l
Thanks Paul,
I will share the content shortly
can I send here
b
sure
jsut rememebr to use code blocks
l
Sure
b
your issue is this
<http://github.com/pulumi/pulumi-aws/sdk/v3|github.com/pulumi/pulumi-aws/sdk/v3> v3.38.1 // indirect
if you are using Pulumi v3 sdk you need to ensure there are not references to
pulumi-aws/sdk/v3
it needs to be a v4 version
so you've still got a reference somewhere
l
so should I remove the line
<http://github.com/pulumi/pulumi-aws/sdk/v3|github.com/pulumi/pulumi-aws/sdk/v3> v3.38.1 // indirect
and replace with github.com/pulumi/pulumi-aws/sdk/v4 v4.6.0 // indirect
which is already there in go mod
b
I think firstly, you need to make sure the dependencies are all satisfied -
go mod tidy
should do that for you from the root of your project
l
Sure
Thanks @broad-dog-22463, Looks Good
Appreciate for the help
b
Very good 🙂 Nps at all!