AwsS3StaticWebsiteServiceModule
Hierarchy
- AModule<AwsS3StaticWebsiteServiceModuleSchema, AwsS3StaticWebsiteService>
- AwsS3StaticWebsiteServiceModule
Index
Constructors
Properties
Methods
Resources
Constructors
constructor
Parameters
moduleId: string
The ID this module is loaded under.
Returns AwsS3StaticWebsiteServiceModule
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, and registers the local directory whose files it serves.
Parameters
Returns Promise<AwsS3StaticWebsiteService>
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.
Parameters
Returns Promise<{ awsAccountId: string; awsRegionId: string }>
AwsS3StaticWebsiteServiceModulecreates a public S3 bucket served as a website over plain HTTP and uploads a local directory into it (directoryPath); a site on HTTPS from a private bucket isAwsS3StorageServiceModulebehindAwsCloudFrontServiceModule.The bucket is public and served over plain HTTP on its S3 website endpoint. It lives in a region created by
AwsServerlessRegionModule. To serve files through CloudFront instead, useAwsS3StorageServiceModule, whose bucket is closed and fronted byAwsCloudFrontServiceModule.S3 bills what the bucket holds and serves: storage per GB-month (about $0.023 for S3 Standard in us-east-1), each request a visitor's browser makes (about $0.0004 per 1,000), and data sent to the internet beyond the 100 GB a month AWS gives free. An idle site costs only its storage.
Changing a file uploads it again in place, and visitors see the new file once it lands. A replacement deletes the bucket before creating it again, so the site answers nothing until the new bucket holds its files.
TypeScript
Modules/Service/AwsS3StaticWebsiteService
The website endpoint serves plain HTTP only, never HTTPS. For HTTPS or a domain of your own, serve the files from
AwsS3StorageServiceModulethroughAwsCloudFrontServiceModuleinstead.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.
The index document is
index.htmland the error documenterror.html; neither name can be changed.Nothing octo cannot put back: every file in the bucket is uploaded from
directoryPath, and a new bucket is filled from it again. A file put into the bucket any other way is lost, and blocks the bucket's deletion until removed by hand.Changing
bucketNameorregionreplaces the bucket, because S3 can neither rename nor move one.Servicemodel.