AwsS3StorageServiceModule
Hierarchy
- AModule<AwsS3StorageServiceModuleSchema, AwsS3StorageService>
- AwsS3StorageServiceModule
Index
Constructors
Properties
Methods
Resources
Constructors
constructor
Parameters
moduleId: string
The ID this module is loaded under.
Returns AwsS3StorageServiceModule
Properties
readonlyinheritedmoduleId
The ID this module was loaded under. It scopes everything the module produces, so the same module class can be loaded more than once.
staticreadonlyinheritedMODULE_PACKAGE
The package the module is registered under, set by Module.
staticreadonlyinheritedMODULE_SCHEMA
The schema of the module's inputs, set by Module.
Methods
onInit
Creates the bucket service, registers the local files it uploads, and registers each access prefix in it that other modules may be granted access to.
Parameters
inputs: AwsS3StorageServiceModuleSchema
Returns Promise<AwsS3StorageService>
inheritedregisterHooks
To hook custom behavior into Octo's lifecycle for the duration of this module. Override it to return the callbacks you want run.
Returns { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }
optionalpostCommitHooks?: PostHookSignature[]
optionalpostModelActionHooks?: PostHookSignature[]
optionalpostResourceActionHooks?: PostHookSignature[]
optionalpreCommitHooks?: PreHookSignature[]
optionalpreModelActionHooks?: PreHookSignature[]
optionalpreResourceActionHooks?: PreHookSignature[]
registerMetadata
Resolves the account and region this bucket is created in. The region may be networked or serverless; the bucket only needs its AWS region ID.
Parameters
inputs: AwsS3StorageServiceModuleSchema
Returns Promise<{ awsAccountId: string; awsRegionId: string }>
AwsS3StorageServiceModulecreates a private S3 bucket for files, such as user uploads or a site CloudFront serves, with the key prefixes a server is granted throughAwsServerModule(accessPrefixes), CORS and lifecycle rules, and optionally a local directory uploaded into it.The bucket is closed to the public by default. To serve its files, pass it as an origin to
AwsCloudFrontServiceModule, which grants its distribution access. For a bucket that serves a website on its own, useAwsS3StaticWebsiteServiceModule. The bucket lives in a region created by any of the AWS region modules.S3 bills what the bucket holds and serves: storage per GB-month (about $0.023 for S3 Standard in us-east-1), each request (about $0.005 per 1,000 writes and $0.0004 per 1,000 reads), and data sent to the internet beyond the 100 GB a month AWS gives free. Served through
AwsCloudFrontServiceModule, the bucket sends to CloudFront for free and CloudFront bills the delivery instead. An empty bucket costs nothing.None for a change made in place: access prefixes, public access blocking, CORS rules, lifecycle rules and the uploaded files all update without interrupting the bucket. A replacement first deletes the bucket, which cannot happen while it holds an object octo did not upload.
TypeScript
Modules/Service/AwsS3StorageService
A bucket name is global across every AWS account: a name anyone already holds is refused. It is 3 to 63 lowercase letters, numbers, dots and hyphens.
S3 serves at least 3,500 writes and 5,500 reads a second for each key prefix, and one object holds up to 5 TB.
Objects are not versioned and the bucket is not replicated: an object overwritten or deleted, by octo or by an app, cannot be recovered.
Deleting the module, or a change that replaces the bucket, deletes every object in it, which octo cannot put back. The files uploaded from
directoryPathare uploaded again; anything else written to the bucket is gone. Terraform refuses to delete a bucket that still holds such an object, so the apply fails until it is emptied by hand.Changing
bucketNameorregionreplaces the bucket, because S3 can neither rename nor move one. Every other input changes it in place.Servicemodel.