Skip to content

Commit 736735f

Browse files
authored
use a bucket policy to grant permissions to access the bucket (#1734)
1 parent 3f141fe commit 736735f

File tree

1 file changed

+37
-7
lines changed

1 file changed

+37
-7
lines changed

modules/ROOT/partials/aws-s3-credentials.adoc

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
. Ensure that the AWS CLI is installed and configured with the necessary credentials.
2-
.. Install the AWS CLI by following the instructions in the AWS official documentation -- link:https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html[Install the AWS CLI version 2].
3-
.. Use `aws configure` command to set your `aws_access_key_id` and `aws_secret_access_key` from AWS.
4-
.. Create an S3 bucket and a directory to store the backup files using the AWS CLI:
1+
2+
. Install the AWS CLI by following the instructions in the AWS official documentation -- link:https://docs.aws.amazon.com/cli/latest/userguide/install-cliv2.html[Install the AWS CLI version 2].
3+
. Create an S3 bucket and a directory to store the backup files using the AWS CLI:
54
+
65
[source,shell]
76
----
@@ -10,7 +9,7 @@ aws s3api put-object --bucket myBucket --key myDirectory/
109
----
1110
+
1211
For more information on how to create a bucket and use the AWS CLI, see the AWS official documentation -- link:https://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3-commands.html#using-s3-commands-prereqs[Use Amazon S3 with the AWS CLI] and link:https://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3.html[Use high-level (s3) commands with the AWS CLI].
13-
.. Verify that the `~/.aws/config` is correct by running the following command:
12+
. Verify that the `~/.aws/config` file is correct by running the following command:
1413
+
1514
[source,shell]
1615
----
@@ -21,9 +20,12 @@ The output should look like this:
2120
[result,shell]
2221
----
2322
[default]
24-
region=eu-north-1
23+
region=us-east-1
2524
----
26-
.. Verify that the `~/.aws/credentials` is correct:
25+
. Configure the access to your AWS S3 bucket by setting the `aws_access_key_id` and `aws_secret_access_key` in the `~/.aws/credentials` file and, if needed, using a bucket policy.
26+
For example:
27+
28+
.. Use `aws configure set aws_access_key_id aws_secret_access_key` command to set your IAM credentials from AWS and verify that the `~/.aws/credentials` is correct:
2729
+
2830
[source,shell]
2931
----
@@ -36,4 +38,32 @@ The output should look like this:
3638
[default]
3739
aws_access_key_id=this.is.secret
3840
aws_secret_access_key=this.is.super.secret
41+
----
42+
43+
.. Additionally, you can use a resource-based policy to grant access permissions to your S3 bucket and the objects in it.
44+
Create a policy document with the following content and attach it to the bucket.
45+
Note that both resource entries are important to be able to download and upload files.
46+
+
47+
[source, json]
48+
----
49+
{
50+
"Version": "2012-10-17",
51+
"Id": "Neo4jBackupAggregatePolicy",
52+
"Statement": [
53+
{
54+
"Sid": "Neo4jBackupAggregateStatement",
55+
"Effect": "Allow",
56+
"Action": [
57+
"s3:ListBucket",
58+
"s3:GetObject",
59+
"s3:PutObject",
60+
"s3:DeleteObject"
61+
],
62+
"Resource": [
63+
"arn:aws:s3:::myBucket/*",
64+
"arn:aws:s3:::myBucket"
65+
]
66+
}
67+
]
68+
}
3969
----

0 commit comments

Comments
 (0)