Ce contenu n'est pas disponible dans la langue sélectionnée.
Chapter 7. Bucket policies in the Multicloud Object Gateway
OpenShift Data Foundation supports AWS S3 bucket policies. Bucket policies allow you to grant users access permissions for buckets and the objects in them.
7.1. Introduction to bucket policies Copier lienLien copié sur presse-papiers!
Bucket policies are an access policy option available for you to grant permission to your AWS S3 buckets and objects. Bucket policies use JSON-based access policy language. For more information about access policy language, see AWS Access Policy Language Overview.
The bucket policy configuration may take up to 120 seconds to take effect after it is applied.
7.2. Using bucket policies in Multicloud Object Gateway Copier lienLien copié sur presse-papiers!
Prerequisites
- A running OpenShift Data Foundation Platform.
- Access to the Multicloud Object Gateway (MCG), see Chapter 2, Accessing the Multicloud Object Gateway with your applications
- A valid Multicloud Object Gateway user account. See Creating a user in the Multicloud Object Gatewayfor instructions to create a user account.
Procedure
To use bucket policies in the MCG:
Create the bucket policy in JSON format.
For example:
{ "Version": "NewVersion", "Statement": [ { "Sid": "Example", "Effect": "Allow", "Principal": { "AWS": "john.doe@example.com" }, "Action": [ "s3:GetObject" ], "Resource": [ "arn:aws:s3:::john_bucket" ] } ] }Replace
john.doe@example.comwith a valid Multicloud Object Gateway user account.Using AWS S3 client, use the
put-bucket-policycommand to apply the bucket policy to your S3 bucket:# aws --endpoint ENDPOINT --no-verify-ssl s3api put-bucket-policy --bucket MyBucket --policy file://BucketPolicy-
Replace
ENDPOINTwith the S3 endpoint. -
Replace
MyBucketwith the bucket to set the policy on. -
Replace
BucketPolicywith the bucket policy JSON file. Add
--no-verify-sslif you are using the default self signed certificates.For example:
# aws --endpoint https://s3-openshift-storage.apps.gogo44.noobaa.org --no-verify-ssl s3api put-bucket-policy -bucket MyBucket --policy file://BucketPolicyFor more information on the
put-bucket-policycommand, see the AWS CLI Command Reference for put-bucket-policy.NoteThe principal element specifies the user that is allowed or denied access to a resource, such as a bucket. Currently, Only NooBaa accounts can be used as principals. In the case of object bucket claims, NooBaa automatically create an account
obc-account.<generated bucket name>@noobaa.io.NoteBucket policy conditions are not supported.
-
Replace
Additional resources
- There are many available elements for bucket policies with regard to access permissions.
- For details on these elements and examples of how they can be used to control the access permissions, see AWS Access Policy Language Overview.
- For more examples of bucket policies, see AWS Bucket Policy Examples.
-
OpenShift Data Foundation version 4.17 introduces the bucket policy elements
NotPrincipal,NotAction, andNotResource. For more information on these elements, see IAM JSON policy elements reference.
7.3. Creating a user in the Multicloud Object Gateway Copier lienLien copié sur presse-papiers!
Prerequisites
- A running OpenShift Data Foundation Platform.
Download the Multicloud Object Gateway (MCG) command-line interface binary from the customer portal and make it executable.
NoteChoose the correct product variant according to your architecture. Available platforms are Linux(x86_64), Windows, and Mac OS.
Procedure
Execute the following command to create an MCG user account:
$ noobaa account create <noobaa-account-name> [--allow_bucket_create=true] [--default_resource=''] [--force_md5_etag=false] [--gid=-1] [--new_buckets_path='/'] [--nsfs_account_config=false] [--nsfs_only=true] [--uid=-1]<allow_bucket_create>- Specify if this account be allowed to create new buckets.
<default_resource>- Specify the default resource on which new buckets are created.
<force_md5_etag>-
Specify if
md5 etagcalculation be enabled for the account. <gid_number>- Specify the NSFS GID.
<new_buckets_path>- Specify the path where the new buckets are created.
<nsfs_account_config>- Specify if NSFS account needs to be created.
<nsfs_only>- Set if this account is used only for NSFS.
<uid_number>- Specify the NSFS UID.