Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page is specific to S3 remote types (eg acacia and AWS) it does not apply to the more specialised banksia service.

If you need more sophisticated policies and lifecycles, you can use the generated ones shown here as a starting point but will have to use awscli to add any customisations.

Setup

An acacia project can be added to your list of pshell remotes by using an arbitrary remote name (eg project123) and supplying the access/secret pair after you select the remote and login. An example is given below:

Code Block
pshell:/> remote add project123 s3 https://projects.pawsey.org.au
pshell:/> remote project123
 
project123:/>login
Access: xyz
Secret: ***

Info

The info command on a bucket.

Policies

Simple S3 policies can also be automatically created for you, noting that:

  1. Policies are attached to buckets and are a list of statements about actions allowed or denied for that bucket only.
  2. Policies override the default project permissions so care should be taken not to lock yourself out of the bucket.
  3. Any DENY in a policy statement counts as a negative permission overall for that action, even if there is also an ALLOW elsewhere.
  4. Policies only grant visibility of objects in a bucket, not visibility of the bucket itself.

Examples 


Here we pawsey0002:/>policy

p0002-sfx

+r user1,user2,user3,user4 Setting bucket=p0002-sfx, perm=+r, for user(s)='user1,user2,user3,user4' pawsey0002:/>info p0002-sfx bucket : p0002-sfx owner : pawsey0002 objects : 6 size : 174

.

03 GB === Policy === { "Id": "generated-policy", "Statement": [ { "Sid": "2022Sep08", "Effect": "Allow", "Principal": { "AWS": [ "arn:aws:iam:::user/user1", "arn:aws:iam:::user/user2", "arn:aws:iam:::user/user3", "arn:aws:iam:::user/user4", ] }, "Action": [ "s3:ListBucket", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::p0002-sfx", "arn:aws:s3:::p0002-sfx/*" ] } ] }

Note: if a user (eg user1) attempts to list buckets they will see nothing. However, if they attempt to list objects inside the bucket it will show the objects inside p0002-sfx/ - see Note 4.

title
Panelexpand
titleExample 1
Examples...

Example1 - give a list of Pawsey usernames (user1, user2, user3, and user4) readonly access to a project bucket called p0002-sfx.

Code Block
Expand
titleShow the generated S3 policy...
Code Block
Panel

Example 2

Here we want to revoke user3 from having read access to the bucket.

pawsey0002:/>info p0002-sfx bucket : p0002-sfx owner : pawsey0002 objects : 6 size : 174.03 GB === Policy === { "Id": "generated-policy", "Statement": [ { "Sid": "2022Sep08", "Effect": "Allow", "Principal": { "AWS": [ "arn:aws:iam:::user/
user1
"
,
"arn:aws:iam:::user/
user2
"
,
"arn:aws:iam:::user/
user3
"
,
"arn:aws:iam:::user/user4", ] }, "Action": [ "s3:ListBucket", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::p0002-sfx", "arn:aws:s3:::p0002-sfx/*" ] }, { "Sid": "2022Sep08_10:28:44", "Effect": "Deny", "Principal": { "AWS": [ "arn:aws:iam:::user/user3" ] }, "Action": [ "s3:ListBucket", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::p0002-sfx", "arn:aws:s3:::p0002-sfx/*" ] } ] }
Code Block
pawsey0002:/>policy p0002-sfx -+r user1,user2,user3,user4
Setting bucket=p0002-sfx, perm=-+r, for user(s)='user3'
Expand
titleShow the generated policy...
Code Block

This works as the combined effect of having both ALLOW and DENY for user3 acts as an overall DENY - see Note 3.

Panel
titleExample 3
This illustrates an alternative method for achieving the same overall result as in example2. Here we remove all policies on the bucket first, before adding back just the users we want
user4' 


Example 2 - revoke user3 from having read access to the bucket.

Code Block
pawsey0002:/>policy p0002-sfx -
Deleting all policies on bucket=p0002-sfx

pawsey0002:>policy p0002-sfx +r user1,user2,user4r user3
Setting bucket=p0002-sfx, perm=+-r, for user(s)='user1,user2,user4'

Note that the generated policy will look different to example2 and will actually be similar to example1 with user3 omitted from the list.

Panel
titleExample 4
This will grant
user3'


Example 3 -  grant read and write permission on a bucket.

Code Block
pawsey0002:/>policy p0002-sfx +rw seanuser1
Setting bucket=p0002-sfx, perm=+rw, for user(s)='seanuser1'
Expand
titleShow the S3 policy...
Code Block
pawsey0002:/>info p0002-sfx
              bucket : p0002-sfx
               owner : pawsey0002
             objects : 6
                size : 174.03 GB
 === Policy === 
{
    "Id": "generated-policy",
    "Statement": [
        {
            "Sid": "2022Sep08",
            "Effect": "Allow",
            "Principal": {
                "AWS": [
                    "arn:aws:iam:::user/sean",
                ]
            },
            "Action": [
                "s3:ListBucket",
                "s3:GetObject",
                "s3:PutObject",
                "s3:DeleteObject"
            ],
            "Resource": [
                "arn:aws:s3:::p0002-sfx",
                "arn:aws:s3:::p0002-sfx/*"
            ]
        }
    ]
}
Panel
titleExample 5


Revoking read and write access works in the same way as the previous examples for readonly access.

Code Blockpolicy p0002-sfx -w sean

Example 4 - make the objects in p0002-sfx readonly and publicly accessible.

Code Block
pawsey0002:/>policy p0002-sfx +r *
Setting bucket=p0002-sfx, perm=-w+r, for user(s)='sean'
Alternatively:
None


Example 5 - remove all policies on a bucket.

Code Block
pawsey0002:/>policy p0002-sfx -
Deleting all policies on bucket=p0002-sfx


...

pawsey0002:/>policy p0002-sfx +r * Setting bucket=p0002-sfx, perm=+r, for user(s)=None



Panel
titleExample 6

This will make the objects in p0002-sfx readonly and publicly accessible.

Code Block

Lifecycles

Simple S3 bucket lifecycles can also be automatically created for you affecting multi-part uploads and versioning.

Note

Remember to use the pshell command "info mybucket" to check if there are any current lifecycle rules as you may overwrite them with the following examples.


Show the S3 policypawsey0002:/>info p0002-sfx bucket : p0002-sfx owner : pawsey0002 objects : 6 size : 174.03 GB === Policy === { "Id": "generated-policy", "Statement": [ { "Sid": "2022Sep08", "Effect": "Allow", "Action": [ "s3:ListBucket", "s3:GetObject" ], "Resource": [ "arn:aws:s3:::p0002-sfx", "arn:aws:s3:::p0002-sfx/*" ], "Principal": "*" } ] }

Example 1 - a basic bucket lifecycle that cleans up failed multi-part uploads after 7 days.

Expand
title
Examples...
Code Block
Code Block
pshell> lifecycle mybucket +m 7


Example 2 - a basic bucket lifecycle that turns on versioning and deletes expired non-current objects after 30 days.

Code Block
pshell> lifecycle mybucket +v 30