Use existing AWS resources
If you are using the Amplify CLI, an existing Amazon S3 bucket can be used with the Amplify Libraries by running:
1amplify import storage
For more details, see how to Use an existing S3 bucket or DynamoDB table.
If you are using Amplify CLI you can first import and configure the CLI generated amplifyconfiguration.json
file and then you can manually configure Storage like this:
1import { Amplify } from 'aws-amplify';2import amplifyconfig from './amplifyconfiguration.json';3
4Amplify.configure(amplifyconfig);5Amplify.configure({6 ...Amplify.getConfig(),7 Storage: {8 S3: {9 region: '[REGION]', // (required) - Amazon S3 bucket region10 bucket: '[BUCKET NAME]' // (required) - Amazon S3 bucket URI11 }12 }13});
- bucket: Name of the bucket to use for storage
- region: AWS Region where the bucket is provisioned (e.g. us-east-1)
Note that before you can add an AWS resource to your application, the application must have the Amplify libraries installed. If you need to perform this step, see Install Amplify Libraries.
Configure S3 Object Lock
You can configure the S3 Object Lock parameter of the bucket using the isObjectLockEnabled
configuration field. By default, isObjectLockEnabled
is set to false
. If you want to perform a put
operation against a bucket with Object Lock enabled through the console you must first set isObjectLockEnabled
to true.
1Amplify.configure(existingConfig, {2 Storage: {3 S3: {4 isObjectLockEnabled: true //OPTIONAl - Object Lock parameter5 }6 }7});