Learn FUNCTIONX with Real Code Examples
Updated Nov 25, 2025
Code Sample Descriptions
1
Simple FunctionX Deployment
# functionx/demo/deployment.yaml
service: hello-world
provider: aws
runtime: nodejs14.x
functions:
hello:
handler: handler.hello
events:
- http:
path: /hello
method: get
A basic FunctionX YAML configuration for deploying a serverless function.
2
FunctionX Deployment with Environment Variables
# functionx/demo/env.yaml
service: env-demo
provider: aws
runtime: nodejs14.x
env:
STAGE: dev
API_KEY: 12345
functions:
envTest:
handler: handler.envTest
events:
- http:
path: /env
method: get
FunctionX YAML configuration demonstrating environment variables for a function.
3
FunctionX Scheduled Function
# functionx/demo/schedule.yaml
service: scheduler-demo
provider: aws
runtime: nodejs14.x
functions:
scheduledTask:
handler: handler.scheduledTask
events:
- schedule:
cron: '0 12 * * ? *'
A FunctionX function triggered by a cron schedule.
4
FunctionX Deployment with Multiple Functions
# functionx/demo/multiple.yaml
service: multi-func-demo
provider: aws
runtime: nodejs14.x
functions:
first:
handler: handler.first
events:
- http:
path: /first
method: get
second:
handler: handler.second
events:
- http:
path: /second
method: post
YAML demonstrating multiple serverless functions in one service.
5
FunctionX Function with IAM Role
# functionx/demo/iam.yaml
service: iam-demo
provider: aws
runtime: nodejs14.x
functions:
secureFunc:
handler: handler.secureFunc
role: arn:aws:iam::123456789012:role/customRole
events:
- http:
path: /secure
method: get
A FunctionX YAML configuration specifying a custom IAM role for a function.
6
FunctionX Function with VPC Configuration
# functionx/demo/vpc.yaml
service: vpc-demo
provider: aws
runtime: nodejs14.x
vpc:
subnets:
- subnet-12345678
- subnet-87654321
securityGroupIds:
- sg-12345678
functions:
vpcFunc:
handler: handler.vpcFunc
events:
- http:
path: /vpc
method: get
A FunctionX YAML defining a function inside a VPC for secure network access.
7
FunctionX Function Triggered by S3
# functionx/demo/s3trigger.yaml
service: s3-demo
provider: aws
runtime: nodejs14.x
functions:
s3Upload:
handler: handler.s3Upload
events:
- s3:
bucket: my-upload-bucket
event: s3:ObjectCreated:*
FunctionX YAML for a function triggered when an object is uploaded to an S3 bucket.
8
FunctionX Function with Lambda Layer
# functionx/demo/layer.yaml
service: layer-demo
provider: aws
runtime: nodejs14.x
layers:
commonLibs:
path: layers/commonLibs
functions:
layerFunc:
handler: handler.layerFunc
layers:
- { Ref: commonLibs }
events:
- http:
path: /layer
method: get
A FunctionX function using a Lambda layer for shared dependencies.
9
FunctionX Function with Environment Secrets
# functionx/demo/secrets.yaml
service: secrets-demo
provider: aws
runtime: nodejs14.x
functions:
secretFunc:
handler: handler.secretFunc
env:
DB_PASSWORD: {{resolve:secretsmanager:dbPassword:SecretString}}
events:
- http:
path: /secret
method: get
A FunctionX YAML showing secret environment variables from AWS Secrets Manager.
10
FunctionX Function with Multiple Triggers
# functionx/demo/multi-triggers.yaml
service: multi-triggers-demo
provider: aws
runtime: nodejs14.x
functions:
multiFunc:
handler: handler.multiFunc
events:
- http:
path: /multi
method: post
- s3:
bucket: my-upload-bucket
event: s3:ObjectCreated:*
A FunctionX YAML where a single function has HTTP and S3 triggers.