You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -61,7 +63,7 @@ The policy will look something like this:
61
63
"s3:ListBucket"
62
64
],
63
65
"Resource": [
64
-
"arn:aws:s3:::<bucket-name>/",
66
+
"arn:aws:s3:::<bucket-name>",
65
67
"arn:aws:s3:::<bucket-name>/*"
66
68
]
67
69
}
@@ -73,35 +75,34 @@ Replace `<AWS-account-ID>` with your AWS account ID and `<role-name>` with the I
73
75
You can refer to [Amazon S3's Policies and Permissions documentation](https://docs.aws.amazon.com/AmazonS3/latest/userguide/access-policy-language-overview.html) for more ways to customize access to the bucket.
74
76
75
77
<Calloutwarning>
76
-
In order to make calls to your S3 bucket from your application, you must also set up a CORS Policy for your S3 bucket. This applies only to manually-configured S3 buckets. Learn more about [setting up a CORS Policy for your S3 bucket](/[platform]/build-a-backend/storage/extend-s3-resources/#for-manually-configured-s3-resources).
78
+
In order to make calls to your manually configured S3 bucket from your application, you must also set up a [CORS Policy](/[platform]/build-a-backend/storage/extend-s3-resources/#for-manually-configured-s3-resources) for the bucket.
77
79
</Callout>
78
80
79
81
### Specify S3 bucket in Amplify's backend config
80
82
81
-
Next, use the `addOutput` method from the backend definition object to define a custom S3 bucket by specifying the name and region of the bucket in your **amplify/backend.ts** file. More options can be specified if more granular control over your custom S3 bucket is needed.
82
-
83
-
Afterwards, set up the appropriate resources and IAM policies to be attached to the backend.
83
+
Next, use the `addOutput` method from the backend definition object to define a custom S3 bucket by specifying the name and region of the bucket in your `amplify/backend.ts` file. You must also set up the appropriate resources and IAM policies to be attached to the backend.
84
84
85
85
<Callout>
86
86
87
-
**Important**
88
-
89
-
You cannot use both a storage backend configured through Amplify and a custom S3 bucket at the same time.
87
+
**Important:** You cannot use both a storage backend configured through Amplify and a custom S3 bucket at the same time.
90
88
91
89
If you specify a custom S3 bucket, no sandbox storage resource will be created. The provided custom S3 bucket will be used, even in the sandbox environment.
92
90
93
91
</Callout>
94
92
95
-
Below is an example of configuring the backend to define a custom S3 bucket where only authenticated (i.e. signed in) users have full access to a folder called `public/`:
93
+
Below are several examples of configuring the backend to define a custom S3 bucket:
96
94
95
+
<BlockSwitcher>
96
+
<Blockname="Authenticated Users">
97
+
Below is an example of expanding the original backend object to grant all authenticated (i.e. signed in) users with full access to files under `public/`:
From there, you can further configure the backend to add custom authorization rules for different user types.
158
-
159
-
<Callout>
160
-
The custom authorization rules defined in the examples below are able to be combined and follow the same rules used when working with Amplify-defined storage. For more information about the access types and access definition rules supported by Amplify, please refer to our documentation on [customizing authorization rules](/[platform]/build-a-backend/storage/authorization/).
161
-
</Callout>
162
-
163
-
<BlockSwitcher>
165
+
</Block>
164
166
<Blockname="Guest Users">
165
167
Below is an example of expanding the original backend object to grant all guest (i.e. not signed in) users read access to files under `public/`:
Below is an example of expanding the original backend object to have an `admin/` folder that only users belonging to the "admin" user group can manage:
237
+
Below is an example of expanding the original backend object to have an `admin/` folder that authenticated users can read, but only users belonging to the "admin" user group can manage:
While Amplify Storage uses the reserved token `entity_id` to represent the user's identity ID, that token is not available when configuring external buckets. Instead, you must use [the IAM role `${cognito-identity.amazonaws.com:sub}`](https://docs.aws.amazon.com/cognito/latest/developerguide/iam-roles.html#trust-policies-classic) to specify the user's identity ID.
317
+
Amplify allows scoping file access to individual users via the user's identity ID. To specify the user's identity ID, you can use the token `${cognito-identity.amazonaws.com:sub}`.
298
318
299
319
Below is an example of expanding the original backend object to define read access for guests to the `public/` folder, as well as defining a `protected/` folder where anyone can view uploaded files, but only the file owner can modify/delete them:
The custom authorization rules defined in the examples are able to be combined, and follow the same rules used when working with Amplify-defined storage. For more information about the access types and access definition rules supported by Amplify, please refer to our documentation on [customizing authorization rules](/[platform]/build-a-backend/storage/authorization/).
To ensure the local **amplify_outputs.json** file is up-to-date, you can run [the npx ampx generate outputs command](/[platform]/reference/cli-commands/#npx-ampx-generate-outputs) or download the latest **amplify_outputs.json** from the Amplify console as shown below.
475
+
To ensure the local `amplify_outputs.json` file is up-to-date, you can run [the `npx ampx generate outputs` command](/[platform]/reference/cli-commands/#npx-ampx-generate-outputs) or download the latest `amplify_outputs.json` from the Amplify console as shown below.
To ensure the local **amplify_outputs.dart** file is up-to-date, you can run [the npx ampx generate outputs command](/[platform]/reference/cli-commands/#npx-ampx-generate-outputs).
485
+
To ensure the local `amplify_outputs.dart` file is up-to-date, you can run [the `npx ampx generate outputs` command](/[platform]/reference/cli-commands/#npx-ampx-generate-outputs).
448
486
449
487
</InlineFilter>
450
488
@@ -453,11 +491,11 @@ Now that you've configured the necessary permissions, you can start using the st
453
491
454
492
## Use storage resources without an Amplify backend
455
493
456
-
While using the Amplify Backend is the easiest way to get started, existing storage resources can also be integrated with Amplify Storage.
494
+
While using the Amplify backend is the easiest way to get started, existing storage resources can also be integrated with Amplify Storage.
457
495
458
496
In addition to manually configuring your storage options, you will also need to ensure Amplify Auth is properly configured in your project and associated IAM roles have the necessary permissions to interact with your existing bucket. Read more about [using existing auth resources without an Amplify backend](/[platform]/build-a-backend/auth/use-existing-cognito-resources/#use-auth-resources-without-an-amplify-backend).
459
497
460
-
### Using Amplifyconfigure
498
+
### Using `Amplify.configure`
461
499
Existing storage resource setup can be accomplished by passing the resource metadata to `Amplify.configure`. This will configure the Amplify Storage client library to interact with the additional resources. It's recommended to add the Amplify configuration step as early as possible in the application lifecycle, ideally at the root entry point.
0 commit comments