-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhance S3 to support EC2 instance roles #19790
Comments
Using above file as |
But a flag like |
@kesselb thank you very much for providing that config snippet. Apart from putting that file into the config directory, do I need to do anything to tell NC to use it? I've commented out the objectstore block in
|
Hmm ... it looks like there may be a problem with the suggested code. If I uncomment the objectstore block with the hardcoded access details, I still have a broken NC service until I rename the new file out of the way. That suggests that NC is trying to use that file but not getting what it needs. I've installed the AWS CLI on the server and confirmed that the implicit instance role is granting the permissions I need, so the instance role itself is working. |
Hmm :( You adjusted the |
Yes, I did but thanks for checking. I changed the bucket name and removed Is there any debugging I can add to try and see what is happening/going wrong? |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
@c-reiter You don't have a similar problem. That enhancement request is about reading the credentials for S3 from a EC2 instance profile. It's not about B2 or Minio. If you found a reproducible bug feel free to create a new issue or use https://help.nextcloud.com for questions in general but do not spam unrelated issues with your problems. |
@kesselb I'm sorry to have caused any inconvenience, I thought that the problems were related because of the "OCP\Files\NotPermittedException" from Nextcloud. It was never my intention to spam. Thank's for telling me the mistake |
This won't work as it doesn't use the session token. Also unclear how long these params are used (will have to take into account the expiration also).
|
Sorry for the commit noise, but I have a PR up which adds this seamlessly. Let's you omit the key/secret in the parameter file altogether and will pick it up (fallback) as either environment variables or instance profile. This is the important part:
Should be helpful both on EC2 or ECS using IAM roles or also when using environment variables from Secrets in k8s. |
Resolves #19790, Provides Support for IAM Credentials
Includes support for either leveraging environment variables passed to the PHP runtime or IAM instance profile present on the host being used. The default and first choice is still the parameter file as documented. See also: https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials_provider.html#chaining-providers Signed-off-by: Stephen Cuppett <steve@cuppett.com>
Is your feature request related to a problem? Please describe.
At the moment, when you configure NC to support S3 as primary object storage, you need to specify the access key ID and secret access key. This, in turn, requires the creation of a user on IAM. The drawback to this is that the keys get stale over time which becomes a security vulnerability.
Describe the solution you'd like
If NC is running on an AWS EC2 instance, it should be possible to use the instance role to gain the appropriate credentials. The code could try to use this mechanism automatically if
config.php
is missing the keys.https://docs.aws.amazon.com/aws-sdk-php/v2/guide/credentials.html#instance-profile-credentials
Describe alternatives you've considered
Creating a user and then manually rotating the keys regularly but this requires the config file to get updated and NC to be restarted.
The text was updated successfully, but these errors were encountered: