aws-toolkit-jetbrains icon indicating copy to clipboard operation
aws-toolkit-jetbrains copied to clipboard

Experimental Features, To support to select credentials at Run/Debug configuration about Golang

Open drakejin opened this issue 3 years ago • 19 comments

Is your feature request related to a problem? Please describe.

image image

I make a golang application with aws-vault. There is a solution about making application on intelliJ with aws-vault. just exec like this command. It's the only way to run intelliJ with aws authentication.

aws-vault exec someprofile -- idea {project-directory}

But, It has a problem. I cannot notice when expired aws-vault authentication. At that time, I have to turn off all about process IDEA and exec that command again aws-vault exec blahprofile -- idea {project-directory}. So I use the configuration about choose aws profile credentials at Run/Debug configuration menu.

Thanks your service all the time. have a nice day.

drakejin avatar Nov 04 '21 14:11 drakejin

You can leverage this to bridge the gap.

https://github.com/99designs/aws-vault/blob/master/USAGE.md#using-credential_process

abrooksv avatar Nov 04 '21 14:11 abrooksv

Sorry, I can't understand. How can I adopt this credential_process when using Run/Debug configuration? I want to use breakpoints and see some values.

drakejin avatar Nov 04 '21 14:11 drakejin

By using a credential profile backed by a credential_process, the toolkit can automatically request new credentials from the credential process when the temporary credentials are about to expire. aws-vault exec sets environment variables on the given process, which is fine for short-lived commands but is undesirable for use-cases such as IDEs, since there is no good way to swap out the environment variables of a running process.

rli avatar Nov 04 '21 14:11 rli

@abrooksv Hm.. Still I don't get it. credential_process how can I use for 'the bridge'?

I no meant to how to use AWS toolkit. I already set up to get aws credentials on AWS toolkit. using credential_process.

Hm... In my case, My company has a 4 aws accounts by purpose and stage, So, I want choose for credentials for running GO application. Therefore, I need to select aws credentials without turn off my IDEA process.

drakejin avatar Nov 04 '21 15:11 drakejin

Okay, I think I understand what you are asking.

You want to be able to leverage the experimental feature for run configs that you showed in your screenshot for Java, but for Go-based run configs?

abrooksv avatar Nov 04 '21 15:11 abrooksv

Sorry for late comment. For Go-based run configs.

That experimental feature is really useful using java. I want to use the feature when using golang too

drakejin avatar Nov 08 '21 18:11 drakejin

Okay, we are limited by the API exposed by JetBrains for each run config. Last I checked it was not possible to mutate the Go-based run configs

abrooksv avatar Nov 08 '21 18:11 abrooksv

Okay, I'll take this issue to JetBrains repository, Would you link me the code for injecting aws credentials at Run/Debug configuration?

I need to understand how AWS Toolkit inject aws credentials.

drakejin avatar Nov 09 '21 12:11 drakejin

In Java, we use this extension point: https://github.com/JetBrains/intellij-community/blob/master/java/execution/impl/src/com/intellij/execution/RunConfigurationExtension.java

In Python, we use this one: https://github.com/JetBrains/intellij-community/blob/master/python/src/com/jetbrains/python/run/PythonRunConfigurationExtension.java

abrooksv avatar Nov 09 '21 16:11 abrooksv

Hmmm.. There may actually be a Go one now: com.goide.execution.extension.GoRunConfigurationExtension

abrooksv avatar Nov 09 '21 16:11 abrooksv

This should actually be pretty straight-forward to implement. We have a language agnostic wrapper (see AwsConnectionRunConfigurationExtension ) that does 99% of the functionality that we we just use in the Python/Java Run Configurations. Take a look at the JavaAwsConnectionExtension for an example usage.

I'd be happy to review a PR for the functionality - did you want to have a go at implementing this?

Similar to the Java / Python ones we'd want to gate this behind a ToolkitExperiment see software.aws.toolkits.jetbrains.core.execution.JavaAwsConnectionExperiment for an example.

And we'd need integration tests similar to the Java/Python ones.

kiiadi avatar Nov 11 '21 00:11 kiiadi

My pleasure, I'd love to. Is it okay making a PR after 3 weeks later?

I'm in end of deadline about company project. after that I'll start to make a PR

drakejin avatar Nov 11 '21 07:11 drakejin

My pleasure, I'd love to. Is it okay making a PR after 3 weeks later?

I'm in end of deadline about company project. after that I'll start to make a PR

Yes, that sounds fine. We appreciate the effort.

abrooksv avatar Nov 11 '21 16:11 abrooksv

Sounds awesome! Thanks.

kiiadi avatar Nov 11 '21 16:11 kiiadi

It's my first time contributing on intelliJ plugins. I don't know how work it is.

I ask something.

  1. This API com.goide.execution.GoRunConfigurationBlahBlah is only implemented on GoLand except IntelliJ?
  2. I've looked around this project, com.goide.* It was not imported yet. How can I use this?
    • com.goide.* is about GoLand.
  3. If I were import com.goide.*, is it possible to control about Go Run Configuration?
  4. Should I request a API to Jetbrains. To control go run configuration
    • ex) API GoRunConfigurationBlahBlah is in module com.intellj.execution.*

drakejin avatar Nov 13 '21 07:11 drakejin

Goland is the Go plugin + IntelliJ platform. The Go API is be accessible from our jetbrains-ultimate subproject. See software.aws.toolkits.jetbrains.services.lambda.go packages for existing Go code.

You can run :jetbrains-ultimate:runIde to get IntelliJ Ultimate with Go plugin already configured for testing.

Everything you need should already be present from JetBrains.

The extension point for plugin.xml usage is com.goide.runConfigurationExtension, the abstract class is com.goide.execution.extension.GoRunConfigurationExtension

abrooksv avatar Nov 15 '21 17:11 abrooksv

And the implementation you create should be wired in the ext-go.xml - this means it will only be loaded if the required go-plugin dependency is present (e.g. you're running IntelliJ Ultimate with the Go plugin, or you're running GoLand)

It's very similar to how the Python/Java ones are implemented in:

kiiadi avatar Nov 17 '21 17:11 kiiadi

Any update for getting the toolkit working in Goland/Go?

jchannon avatar Feb 22 '22 19:02 jchannon

Oh.. my.. I'm Sorry @jchannon

I've totally forgot this. I didn't start yet. If you want to make yourself I'll give you turn....

drakejin avatar Mar 03 '22 09:03 drakejin