https://pulumi.com logo
Title
l

late-energy-66663

06/03/2021, 10:52 PM
Hi Team , I am new to Pulumi, running the Automation api to provision the ec2 machine and getting following error
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

lemon-agent-27707

06/03/2021, 10:59 PM
Looks like you are using v2 of the pulumi SDK with v3 of the CLI. You will need to use v3 with v3.
l

late-energy-66663

06/03/2021, 10:59 PM
I see ,
thanks
So Just update the go mod file with the v3 sdk right ?
l

lemon-agent-27707

06/03/2021, 11:00 PM
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

late-energy-66663

06/03/2021, 11:02 PM
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
"<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

little-cartoon-10569

06/03/2021, 11:32 PM
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

late-energy-66663

06/04/2021, 12:03 AM
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

lemon-agent-27707

06/04/2021, 12:34 AM
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

late-energy-66663

06/04/2021, 12:35 AM
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

lemon-agent-27707

06/04/2021, 12:38 AM
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

late-energy-66663

06/04/2021, 11:33 AM
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

broad-dog-22463

06/04/2021, 11:56 AM
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

late-energy-66663

06/04/2021, 12:02 PM
Thanks Paul,
I will share the content shortly
can I send here
b

broad-dog-22463

06/04/2021, 12:07 PM
sure
jsut rememebr to use code blocks
l

late-energy-66663

06/04/2021, 12:13 PM
Sure
b

broad-dog-22463

06/04/2021, 12:30 PM
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

late-energy-66663

06/04/2021, 12:33 PM
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

broad-dog-22463

06/04/2021, 12:35 PM
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

late-energy-66663

06/04/2021, 12:35 PM
Sure
Thanks @broad-dog-22463, Looks Good
Appreciate for the help
b

broad-dog-22463

06/04/2021, 1:14 PM
Very good 🙂 Nps at all!