Introduction
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. Please refer to Acacia access and identities and Using policies for more details.
Setup
An acacia project can be added to your list of pshell remotes by creating using an arbitrary remote name (eg project123) and then supplying the access/secret pair after you select the remote and login. An example is given below:. After this, the usual file and folder commands will be available.
Expand |
---|
|
Code Block |
---|
pshell:/> remote add project123 s3 https://projects.pawsey.org.au
pshell:/> remote project123
project123:/>login
Access: xyz
Secret: *** |
|
Policies
Simple S3 policies can also be automatically created for you, noting that:
- Policies are attached to buckets and are a list of statements about actions allowed or denied for that bucket only.
- Policies override the default project permissions , so you must also grant those permissions to the project itself or you may so care should be taken not to lock yourself out of the bucket.
- Any DENY in a policy statement counts as a negative permission overall for that action, even if there is also an ALLOW elsewhere.
- Policies only grant visibility of objects in a bucket, not visibility of the bucket itself.
Note |
---|
You can use the pshell command "info mybucket" to examine the active policies on that bucket. |
...
Expand |
---|
|
Here we | Example 1 | Example1 - give a list of Pawsey |
| usernames (user1, user2, user3, and user4) readonly access to a project bucket called p0002-sfx. |
pawsey0002p0002sfxbucket +r user1,user2,user3,user4
Setting bucket= | p0002sfxbucket, perm=+r, for user(s)='user1,user2,user3,user4' | | Expand |
---|
title | Show the generated 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_10:21:17",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam:::user/user1",
"arn:aws:iam:::user/user2",
"arn:aws:iam:::user/user3",
"arn:aws:iam:::user/user4",
"arn:aws:iam::0519d807c3a549c0b73cdc8244d6a0c5:root"
]
},
"Action": [
"s3:ListBucket",
"s3:GetObject"
],
"Resource": [
"arn:aws:s3:::p0002-sfx",
"arn:aws:s3:::p0002-sfx/*"
]
}
]
} |
Note | that the project actor (0519d807c3a549c0b73cdc8244d6a0c5root) was automatically added to the permission list - see Note 2.Also, (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 | p0002sfx
| Here we want to - revoke user3 from having read access |
| to the bucket. |
pawsey0002p0002sfxbucket -r user3
Setting bucket= | p0002sfxbucket, perm=-r, for user(s)='user3' |
|
Expandpanel |
---|
title | Show the generated policy...Example 3 - grant read and write permission |
---|
|
Code Block |
---|
pawsey0002project123:/>info>policy p0002my-sfxbucket +rw bucket : p0002-sfx
owner : pawsey0002
objects : 6
size : 174.03 GB
=== Policy ===
{
"Id": "generated-policy",
"Statement": [
{
"Sid": "2022Sep08_10:21:17",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam:::user/user1",
"arn:aws:iam:::user/user2",
"arn:aws:iam:::user/user3",
"arn:aws:iam:::user/user4",
"arn:aws:iam::0519d807c3a549c0b73cdc8244d6a0c5:root"
]
},
"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/*"
]
}
]
} |
|
This works as the combined effect of having both ALLOW and DENY for user3 acts as an overall DENY - see Note 3. The policy engine never automatically adds the project (0519d807c3a549c0b73cdc8244d6a0c5:root) to DENY statements, as this would also lock the project out. |
Panel |
---|
|
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. Code Block |
---|
pawsey0002:/>policy p0002-sfx -
Deleting all policies on bucket=p0002-sfx
pawsey0002:>policy p0002-sfx +r user1,user2,user4
Setting bucket=p0002-sfxuser1
Setting bucket=my-bucket, perm=+rw, for user(s)='user1' |
|
Panel |
---|
title | Example 4 - make a bucket readonly and publicly accessible |
---|
|
Code Block |
---|
project123:/>policy my-bucket +r *
Setting bucket=my-bucket, 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.
| 4This will grant read and write permission 5 - remove all policies on a bucket |
| . |
pawsey0002p0002-sfx +rw sean
Settingmy-bucket -
Deleting all policies on bucket= | p0002-sfx, perm=+rw, for user(s)='sean'
|
|
Lifecycles
Simple S3 bucket lifecycles can also be automatically created for you affecting multi-part uploads and versioning.
Note |
---|
Use the pshell command "info mybucket" to check if there are any current lifecycle rules as the following may overwrite them. |
Expand |
---|
| Show the S3 policy |
Panel |
---|
title | Example 1 - enable multi-part and expired version cleanup after 30 days |
---|
|
|
Revoking read and write access works in the same way as the previous examples for readonly access. Code Block |
---|
policy p0002-sfx -w sean
Setting bucket=p0002-sfx, perm=-w, for user(s)='sean' |
Alternatively: Code Block |
---|
pawsey0002:/>policy p0002-sfx -
Deleting all policies on bucket=p0002-sfx Code Block |
---|
pawsey0002:/>info p0002-sfx
bucket : p0002-sfx
owner : pawsey0002
objects : 6
size : 174.03 GB
=== Policy ===
{
"Id": "generated-policy",
"Statement": [
{
"Sid": "2022Sep08_11:12:28",
"Effect": "Allow",
"Principal": {
"AWS": [
"arn:aws:iam:::user/sean",
"arn:aws:iam::0519d807c3a549c0b73cdc8244d6a0c5:root"
]
},
"Action": [
"s3:ListBucket",
"s3:GetObject",
"s3:PutObject",
"s3:DeleteObject"
],
"Resource": [
"arn:aws:s3:::p0002-sfx",
"arn:aws:s3:::p0002-sfx/*"
]
}
]
} |
|
|
Panel |
---|
|
pshell> lifecycle my-bucket +mv |
|
Panel |
---|
title | Example 2 - clean up incomplete multi-part uploads after 7 days |
---|
|
Code Block |
---|
pshell> lifecycle my-bucket +m 7 |
|
Panel |
---|
title | Example 3 - turn on versioning and delete expired non-current objects after 30 days |
---|
|
Code Block |
---|
pshell> lifecycle my-bucket +v 30 |
|
If versioning is enabled on a bucket, then you will have the option to review and restore deleted objects in the window before the lifecycle cleanup policy permanently removes them. Panel |
---|
title | Example 4 - Reviewing deleted objects |
---|
|
Code Block |
---|
pshell> lifecycle my-bucket --review
Reviewing deletions: bucket=my-bucket, prefix=
* folder1/my_file.txt |
|
Panel |
---|
title | Example 5 - Restoring an object |
---|
|
Code Block |
---|
pshell> lifecycle my-bucket/folder1 --restore
Restoring deletions: bucket=my-bucket, prefix=folder1
restoring: folder1/my_file.txt
Restored object count: 1 |
|
|