necatiarslan / aws-s3

Aws S3 Extension for VsCode
Apache License 2.0
9 stars 6 forks source link

Environment Varible Credentials Support #9

Closed Digital-Grinnell closed 11 months ago

Digital-Grinnell commented 1 year ago

I'm trying to use this extension with an S3 bucket provisioned by someone else and I don't have access at the bucket level. My permissions apply to a specific folder (subdirectory) of the bucket only. I am able to successfully work in "my" folder using the AWS S3 CLI.

So, in this extension I can select and see the bucket itself, but I can't see anything within or browse to "my" folder. I've tried specifying the folder as part of the bucket name but when I do that I get no bucket to "select".

Just curious if I'm missing something here in my config or the extension's capabilities, or if this just isn't possible? Thanks.

necatiarslan commented 1 year ago

Can you use the search button next to the bucket, find your folder, and add this folder as a shortcut by clicking the star button ? This way you can add your folder under the bucket as a shortcut and open this folder.

let me know if it works

Digital-Grinnell commented 1 year ago

Thank you very much for the suggestion. Unfortunately, if I understand correctly I don't think I'm able to make that work either. When I open the bucket in VSCode and try to search for my institution's folder using the Key/Folder search field I get this message back:

api.GetS3ObjectList Error !!! | AccessDenied | Access Denied.

I tried entering the folder name in the other search fields, even though those don't seem to be right in this case, and I tried searching with/without leading/trailing slashes. I also tried searching one level deeper, but all attempts return the Access Denied message you see above.

GSA18 commented 1 year ago

this extension does not work

necatiarslan commented 1 year ago

Sorry to hear that, @GSA18 you had some issues setting up the extension. Can you give some detail on what did not work?

NickiForte commented 11 months ago

Could you provide some instructions in the readme on how to set this up? In particular, how to get it to use the temporary credentials created by mfa?

I only get the following error message:

api.GetBucketList Error !!! | CredentialsError | Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1

and I have tried exporting AWS_SDK_LOAD_CONFIG=1 in a terminal and then launching vscode from the same terminal, but it still does not work.

necatiarslan commented 11 months ago

@NickiForte Setting up the AWS credentials to access what should be done to access was itself. The extension uses these credentials as well. They are not a part of the extension.

These set up may be different for operating systems or versions. So please search "How to setup Aws CLI" on youtube to get a video help.

Here is one of them : https://www.youtube.com/watch?v=Rp-A84oh4G8 let me know if this works of more detail on your problem

NickiForte commented 11 months ago

I can assure you I have set up aws credentials correctly, I am perfectly able to access s3 from the terminal. I suspect just that this extension is not compatible with my setup. In the configuration file, i have

[profile my-profile] role_arn = my-role-arn credential_source = Environment

and then I have exported aws_access_key_id, aws_secret_access_key and aws_session_token as environmental variables.

I am able to select the profile my-profile, but when trying to open a bucket to which my-profile has access, I get the error mentioned above.

necatiarslan commented 11 months ago

Ok, got it. The extension does not support credentials in the environment variables. you should put them to your credentials file image

I highly recommend you to install the AWS Access extension I have developed to manage your aws access credentials. Let me know if this worked.

I may add env variable support as well in a few months.

NickiForte commented 11 months ago

Now I also tested

config: [profile my-profile] role_arn = my-role-arn source_profile = my-credentials-role region = eu-west-1 output = json

credentials: [my-credentials-role] aws_access_key_id = ... aws_secret_access_key = ... aws_session_token = ...

and tried to assume the my-profile role (which I need to access the bucket, it is not enough to assume the my-credentials-role profile), but I still got the same error message. If I try to assume my-credentials-role, I get a different error message that just says access denied, which I assume is because I need the my-profile role to access this specific bucket.

I think support for env variables would be a good idea.

necatiarslan commented 11 months ago

Nicki, I have did several fixes and added new features including renaming, coping and moving files. I did not publish it to extension marketplace yet.

Can you download and test v1.3 below ? I will publish it after your test.

https://github.com/necatiarslan/aws-s3/blob/main/vsix/aws-s3-vscode-extension-1.3.0.vsix

İf this did not work please share the logs from output window.

image

necatiarslan commented 11 months ago

I have published v1.3 with env variable support, pls try it

NickiForte commented 10 months ago

Thank you, now it does indeed recognise my environmental variables. However, it still does not work because when I try to select profile, I get the following error message:

image

And if I try to access a bucket without selecting the profile, I get the following:

image

As I have multiple profiles, I need to be able to specify profile_name to access the bucket. This also is the case from the terminal: aws s3 ls s3://my_bucket_name --profile myprofile Without the --profile flag, I also get the access denied error in the terminal.

necatiarslan commented 10 months ago

Thanks for the feedback, I realized that the extension is not supporting IAM roles as well. let me work on this and release a new version to fix it.

Can you email me at necatia@gmail.com to go on the discussion on email for better communication?

necatiarslan commented 10 months ago

Nicki, can you try to set the profile "export AWS_PROFILE=myprofile" as described below https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-role.html