aws / aws-toolkit-jetbrains

AWS Toolkit for JetBrains - a plugin for interacting with AWS from JetBrains IDEs
https://plugins.jetbrains.com/plugin/11349-aws-toolkit
Apache License 2.0
754 stars 220 forks source link

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

Open drakejin opened 2 years ago

drakejin commented 2 years ago

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.

abrooksv commented 2 years ago

You can leverage this to bridge the gap.

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

drakejin commented 2 years ago

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.

rli commented 2 years ago

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.

drakejin commented 2 years ago

@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.

abrooksv commented 2 years ago

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?

drakejin commented 2 years ago

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

abrooksv commented 2 years ago

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

drakejin commented 2 years ago

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.

abrooksv commented 2 years ago

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 commented 2 years ago

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

kiiadi commented 2 years ago

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.

drakejin commented 2 years ago

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

abrooksv commented 2 years ago

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.

kiiadi commented 2 years ago

Sounds awesome! Thanks.

drakejin commented 2 years ago

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.*
abrooksv commented 2 years ago

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

kiiadi commented 2 years ago

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:

jchannon commented 2 years ago

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

drakejin commented 2 years ago

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....