Functions Component
Deploys one or more serverless functions from a single component definition. Each function item gets its own dedicated execution identity (IAM role / service account) — permissions are never shared between functions. Code is loaded from a storage bucket, allowing you to manage deployable artifacts independently of the infrastructure config.
Component Fields
Field | Type | Required | Default | Description |
|---|---|---|---|---|
type | string | required | — | Must be "functions" |
name | string | required | — | Unique component name. Used as a logical group identifier — individual function names are derived from each item's name field. |
codeStorage | string | required | — | Name of the storage component where deployment packages are located. All function items in this group use the same storage bucket. |
codePath | string | required | — | Path within the storage bucket to the deployment package shared by all function items (e.g. releases/app-functions/app-functions-1.0.0.jar). All functions in this group are loaded from this single artifact. |
functions | array | required | — | List of function item definitions. Must contain at least one entry. |
references | array of strings | optional | — | Legacy — use links instead. Names of components all functions in this group can access. Prefer using the links array with full link objects (e.g., FUNCTION_TO_DATABASE, FUNCTION_TO_STORAGE, FUNCTION_TO_EMAIL, FUNCTION_TO_SMS, FUNCTION_TO_EVENT_BUS, FUNCTION_TO_AUTHENTICATION). |
Multiple functions components can be declared in the same region — for example, one group for API handlers and another for background workers, each pointing to a different storage bucket or code path. Component names must be unique across the entire configuration.
Function Item Fields
Each entry in the functions array defines one deployed function.
Field | Type | Required | Default | Description |
|---|---|---|---|---|
name | string | required | — | Unique name for this function. The globally unique cloud resource name is derived as {application}-{name}. Must be unique across all function items in the entire configuration. |
handler | string | required | — | Entry point within the shared code package. AWS: com.example.Handler::handleRequest. Azure/GCP: class or function name. |
runtime | string | optional | "java21" | Runtime identifier. AWS: java21, nodejs22.x, python3.12, rust (compiles to the provided.al2023 custom runtime, handler should be bootstrap). Azure: java17, node20. GCP: java21, nodejs20. |
memoryMb | integer | optional | 512 | Memory allocation in MB. AWS: 128–10240. Azure: 128–1536. GCP: 128–8192. |
timeoutSeconds | integer | optional | 30 | Maximum execution time. AWS max: 900. Azure max: 230 (Consumption). GCP max: 540. |
environment | object | optional | — | Environment variables injected at runtime. Values support ${variable} substitution. |
concurrency | integer | optional | — | Reserved/maximum concurrency. AWS: reserved concurrency. GCP: max instances. |
schedule | string | optional | — | An EventBridge rate(...) or cron(...) expression that invokes this function on a schedule. See Scheduled Functions below. (AWS) |
references | array of strings | optional | — | Per-function references. Merged with the component-level references for this function's effective permissions. |
The codeStorage component must be defined in the same configuration and deployed before the functions. The plugin resolves the storage bucket name at deploy time and passes the S3/blob/GCS URI directly to the cloud provider's function deployment API. Use the storage component's uploads array to push your build artifacts into the bucket as part of the same deploy.
Cloud Resources Created
Per function item:
- Lambda Function — named {application}-{item.name}. Code loaded from the S3 URI s3://{codeStorage-bucket}/{codePath}.
- IAM Execution Role — dedicated role with least-privilege policies. Named {application}-{item.name}-role.
- CloudWatch Log Group — /aws/lambda/{application}-{item.name} with 14-day retention.
- EventBridge Rule (only when the function declares a schedule) — a scheduled rule named {application}-{item.name}-schedule targeting the function, plus a lambda:InvokeFunction permission for events.amazonaws.com. Removed on undeploy.
Per function item:
- Function App — Consumption plan (serverless), provisioned via azure-resourcemanager-appservice with an auto-created backing storage account. String-valued providerSettings are applied as app settings. Creation is idempotent — an already-existing app is treated as success.
- System-Assigned Managed Identity — one per function. Role assignments to referenced resources are created automatically.
- Application Insights — linked for monitoring.
Per function item:
- Cloud Function (2nd gen) — named {application}-{item.name}, provisioned via google-cloud-functions (v2, GEN_2 environment). String-valued providerSettings are applied as environment variables. Creation is idempotent — an already-existing function is treated as success. The plugin awaits the create long-running operation (bounded).
- Service Account — dedicated service account per function. Named {application}-{item.name}-sa. IAM bindings to referenced resources are created automatically.
JSON Example
{
"type": "functions",
"name": "app-functions",
"codeStorage": "deploy-artifacts",
"codePath": "releases/app-functions/app-functions-1.0.0.jar",
"references": ["app-db", "transactional-email"],
"functions": [
{
"name": "api-handler",
"handler": "com.example.ApiHandler::handleRequest",
"runtime": "java21",
"memoryMb": 1024,
"timeoutSeconds": 30,
"environment": {
"LOG_LEVEL": "INFO",
"ENV": "${env}"
},
"references": ["asset-store", "notification-sms", "domain-events"]
},
{
"name": "event-processor",
"handler": "com.example.EventProcessor::handleRequest",
"runtime": "java21",
"memoryMb": 512,
"timeoutSeconds": 60
}
]
}
codeStorage and codePath are set once at the component level and shared by all function items. references at the component level (app-db, transactional-email) apply to all functions; item-level references are merged in for that function only.
Automatic Environment Variables from Links
When a function component has links, the plugin automatically injects environment variables into all Lambda functions in the group. The variable name is derived from the target component name: convert to UPPER_SNAKE_CASE and append a suffix.
Variables Injected by Link Type
Link Type | Target Example | Environment Variable(s) | Value |
|---|---|---|---|
FUNCTION_TO_DATABASE | Content_Store | CONTENT_STORE_ARN | DynamoDB table ARN e.g. arn:aws:dynamodb:eu-west-2:123:table/app-content-store |
FUNCTION_TO_STORAGE | Asset_Store | ASSET_STORE_ARN | S3 bucket ARN e.g. arn:aws:s3:::app-asset-store |
FUNCTION_TO_EMAIL | Email_Service | EMAIL_SERVICE_ARN | SES email identity ARN |
FUNCTION_TO_SMS | Notif_SMS | NOTIF_SMS_ARN | SNS topic ARN |
FUNCTION_TO_EVENT_BUS | Order_Events | ORDER_EVENTS_ARN | EventBridge event bus ARN |
FUNCTION_TO_AUTHENTICATION | Auth_Service | AUTH_SERVICE_ARN | Cognito User Pool ARN |
AUTH_SERVICE_USER_POOL_ID | Cognito User Pool ID e.g. eu-west-2_aBcDeFgH | ||
AUTH_SERVICE_CLIENT_ID | Cognito App Client ID e.g. 1abc2def3ghi4jkl5mno | ||
FUNCTION_TO_FUNCTION | provision-site | FUNCTION_PROVISION_SITE | Target Lambda function ARN e.g. arn:aws:lambda:eu-west-2:123:function:app-provision-site |
Naming Convention
Target component name → replace - with _ → UPPERCASE → append suffix:
- {NAME}_ARN — injected for most link types
- FUNCTION_{NAME} — for FUNCTION_TO_FUNCTION links (no _ARN suffix)
- {NAME}_USER_POOL_ID — only for authentication links
- {NAME}_CLIENT_ID — only for authentication links
Per-Function Links
Individual functions can also define their own links array. These inject env vars only into that specific function (in addition to the component-level link vars):
{
"name": "special-handler",
"handler": "handler.special",
"runtime": "nodejs22.x",
"links": [
{ "targetComponent": "Special_DB" }
]
}
This injects SPECIAL_DB_ARN only into special-handler.
Merge Priority
When multiple sources define the same variable, later sources override earlier ones:
- Component-level link env vars (auto-injected from links array)
- Group-level environment from providerSettings
- Per-function environment from the function definition
- Per-function link env vars
Scheduled Functions (AWS)
Add a schedule to a function item to invoke it on a time cadence. The plugin provisions an EventBridge (CloudWatch Events) rule named {application}-{item.name}-schedule, points it at the function, and grants events.amazonaws.com permission to invoke it. No schedule means the function is deployed unchanged (invoked only by its other triggers, if any).
Schedule expression syntax
The schedule value is a standard EventBridge schedule expression:
- Rate — rate(value unit), where value is a positive integer and unit is minute(s), hour(s), or day(s). The unit must be singular when the value is 1 and plural otherwise, e.g. rate(1 day), rate(5 minutes), rate(2 hours).
- Cron — cron(minutes hours day-of-month month day-of-week year) (six fields), e.g. cron(0 12 * * ? *) for 12:00 UTC daily.
serverless:validate checks the expression shape before any cloud call; AWS performs the authoritative validation at deploy time.
Example
{
"type": "function",
"name": "groups-functions",
"providerSettings": {
"codeStorage": "artifacts",
"codePath": "releases/groups-functions-${version}.zip",
"functions": [
{
"name": "group-lifecycle-scheduler",
"handler": "dist/group-lifecycle-scheduler.handler",
"runtime": "nodejs22.x",
"schedule": "rate(1 day)"
}
]
}
}
Declarative redeploy: changing the schedule updates the rule's expression in place (the rule and target use deterministic names, so redeploys don't accumulate duplicates). Running serverless:undeploy removes the rule's targets and then the rule. Deploy identity permissions: events:PutRule, events:PutTargets, events:DeleteRule, events:RemoveTargets, events:ListTargetsByRule, and lambda:AddPermission — see Credentials.
Removing a schedule: deleting the schedule field does not tear down an already-created rule on the next deploy (deploy only creates/updates rules). To remove a schedule from a live function, run serverless:undeploy (which deletes the rule) or delete the rule out-of-band. The rule is always removed when the function is undeployed.
Scheduled functions are AWS-only. On Azure and GCP a schedule is currently ignored (the function is deployed without a timer trigger). Validation is a syntactic check of the rate(...)/cron(...) shape; AWS performs the authoritative validation of cron field contents at deploy time.
Explicit Permissions
Functions can declare a permissions array to grant IAM access to resource types that don't exist in the configuration. This is useful when a function needs to create, manage, or interact with resources dynamically (e.g., creating S3 buckets, managing DNS records).
Per-Function Permissions
{
"name": "domain-manager",
"handler": "handler.manage",
"runtime": "nodejs22.x",
"permissions": ["storage:create", "storage:delete", "dns:create", "dns:update", "dns:delete"]
}
Component-Level Permissions (fallback)
If a function does not define its own permissions, it inherits from the component level:
{
"type": "functions",
"name": "data-tools",
"providerSettings": {
"permissions": ["database:read", "database:write"],
"codeStorage": "deploy-artifacts",
"codePath": "releases/data-tools.jar",
"functions": [
{ "name": "reader", "handler": "handler.read", "runtime": "nodejs22.x" },
{ "name": "writer", "handler": "handler.write", "runtime": "nodejs22.x",
"permissions": ["database:read", "database:write", "database:delete"] }
]
}
}
In this example, reader gets database:read and database:write from the component level, while writer uses its own permissions array (which overrides the component level).
Available Permissions
Resource Type | Available Actions | AWS Mapping |
|---|---|---|
storage | create, read, write, delete, list | S3 actions (CreateBucket, GetObject, PutObject, DeleteObject, ListBucket, etc.) |
database | create, read, write, delete | DynamoDB actions (CreateTable, GetItem, PutItem, DeleteItem, Query, Scan, etc.) |
dns | create, update, delete, list | Route53 actions (ChangeResourceRecordSets, ListHostedZones, ListResourceRecordSets) |
email | send | SES actions (SendEmail, SendRawEmail) |
sms | send | SNS Publish |
event-bus | publish, subscribe, manage | EventBridge PutEvents / DescribeRule / PutRule / PutTargets / Scheduler actions |
authentication | create, read, update, delete | Cognito AdminCreateUser, AdminGetUser, AdminUpdateUserAttributes, AdminDeleteUser, etc. |
certificate | create, read, delete | ACM RequestCertificate, DescribeCertificate, DeleteCertificate, ListCertificates |
website | create, read, delete, invalidate | CloudFront CreateDistribution, GetDistribution, DeleteDistribution, ListDistributions, CreateInvalidation |
queue | create, send, receive, delete | SQS CreateQueue, SendMessage, ReceiveMessage, DeleteMessage, DeleteQueue |
Permissions vs Links: Use links when you are connecting to a specific, defined component (e.g., a particular database table). Use permissions when you need broad access to a resource type that may not be defined in the configuration (e.g., creating arbitrary S3 buckets or managing DNS records for any hosted zone). Both can be used together.
References
Use references at the component level for access shared by all functions, or at the individual function item level for per-function access control. Both levels can be combined — a function's effective permissions are the union of component-level and item-level references.