Skip to main content

AwsServerModule

AwsServerModule declares a server's identity: what its code may reach, through grants to buckets (s3), tables (dynamodb), functions (lambda) or raw iamStatements, and its securityGroupRules.

It creates nothing and knows nothing about where the code runs. The execution that runs the code, on ECS or on Lambda, reads the server and creates everything its runtime needs, including the IAM role holding these grants.

@cost

Nothing: it creates no resources. The execution running the server creates the IAM role holding its grants.

@downtime

None: a changed grant updates the execution's IAM role in place, and the code gets it within seconds.

@example

TypeScript

import { type Account, type Service, stub } from '@quadnix/octo';
import { AwsServerModule } from '@quadnix/octo-aws-cdk/modules/server/aws-server';
import { AwsServerAccessPermission } from '@quadnix/octo-aws-cdk/modules/server/aws-server/schema';

octo.loadModule(AwsServerModule, 'my-server-module', {
account: stub<Account>('${{my-account-module.model.account}}'),
dynamodb: [{
access: AwsServerAccessPermission.READ_WRITE,
service: stub<Service>('${{my-table-module.model.service}}'),
}],
iamStatements: [{
actions: ['ses:SendEmail', 'ses:SendRawEmail'],
resources: ['arn:aws:ses:us-east-1:123456789012:identity/example.com'],
}],
s3: [{
accessPrefixes: [{
access: AwsServerAccessPermission.READ_WRITE,
accessPrefix: 'uploads',
}],
service: stub<Service>('${{my-storage-module.model.service}}'),
}],
securityGroupRules: [{
CidrBlock: '0.0.0.0/0',
Egress: false,
FromPort: 443,
ToPort: 443,
IpProtocol: 'tcp'
}],
serverKey: 'backend-server',
});
@group

Modules/Server/AwsServer

@limit

A grant names a model octo builds, through s3, dynamodb and lambda; iamStatements takes raw statements for what octo does not build. Lambda ignores securityGroupRules, which only an ECS execution applies.

@limit

A lambda grant reaches only a function of another app.

@limit

An S3 allowWrite grant includes deleting objects: no grant lets a server put objects without deleting them.

@limit

A DynamoDB grant covers the table and all its indexes, never one index.

@losesData

Nothing.

@replaces

Nothing of its own: changing serverKey gives the code a new identity, and each execution running it a new IAM role.

@see

Hierarchy

Index

Constructors

constructor

  • Parameters

    • moduleId: string

      The ID this module is loaded under.

    Returns AwsServerModule

Properties

readonlyinheritedmoduleId

moduleId: string

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

MODULE_PACKAGE: string

The package the module is registered under, set by Module.

staticreadonlyinheritedMODULE_SCHEMA

MODULE_SCHEMA: any

The schema of the module's inputs, set by Module.

Methods

onInit

  • onInit(inputs: AwsServerModuleSchema): Promise<(AwsServer | AwsServerDynamoDBAccessOverlay | AwsServerLambdaAccessOverlay | AwsServerS3AccessOverlay)[]>
  • Creates the server, and anchors what it may reach. Each bucket prefix, table and function it may reach is also joined to the server by a grant overlay, which creates nothing; an IAM statement names nothing in the graph, and is only anchored. A prefix or table granted more than once is granted once, with the access of all its grants.


    Parameters

    Returns Promise<(AwsServer | AwsServerDynamoDBAccessOverlay | AwsServerLambdaAccessOverlay | AwsServerS3AccessOverlay)[]>

inheritedregisterHooks

  • registerHooks(): { postCommitHooks?: PostHookSignature[]; postModelActionHooks?: PostHookSignature[]; postResourceActionHooks?: PostHookSignature[]; preCommitHooks?: PreHookSignature[]; preModelActionHooks?: PreHookSignature[]; preResourceActionHooks?: PreHookSignature[] }
  • To hook custom behavior into Octo's lifecycle for the duration of this module. Override it to return the callbacks you want run.

    @see

    Techniques for Hooks.


    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 the app this server belongs to.


    Parameters

    Returns Promise<{ account: Account; app: App }>