Web Service
This example shows a basic web service configuration.
Web service resource
- Provides continuously running container with public endpoint (URL) accessible from anywhere on internet.
- TLS/SSL out of the box.
- Easy setup of scaling, healthchecks and other properties.
Basic example
resources:myWebService:type: web-serviceproperties:# Configures CORS (Cross-Origin Resource Sharing) for this service.## - If CORS is configured using this property, CORS headers returned from your application are ignored and replaced## > This property only works if **loadBalancing** type is `http-api-gateway`(default).## - Type: object# - Required: falsecors:# Enables CORS (Cross-Origin Resource Sharing)## If you do not specify any additional properties, default CORS configuration is used:# - `AllowedMethods`: Inferred from methods used by integrations associated with the api gateway# - `AllowedOrigins`: `*`# - `AllowedHeaders`: `Content-Type`, `X-Amz-Date`, `Authorization`, `X-Api-Key`, `X-Amz-Security-Token`, `X-Amz-User-Agent`## - Type: boolean# - Required: true# - Default: falseenabled: true# Origins to accepts cross-domain requests from## - Origin is a combination of scheme (protocol), hostname (domain), and port of the URL# - Example origin: https://foo.example## - Type: array<string># - Required: false# - Default: *allowedOrigins:- https://example.com- https://app.example.com# Allowed HTTP headers## - Each header name in the `Access-Control-Request-Headers` header of a preflight request must match a corresponding entry in the rule.## - Type: array<string># - Required: falseallowedHeaders:- Content-Type- Authorization# Allowed HTTP methods## - By default, Stacktape determines allowed methods based on the event integrations associated with gateway## - Type: array<object (reference)># - Required: falseallowedMethods:- GET- POST- PUT- DELETE# Configures the presence of credentials in the CORS request## - Type: boolean# - Required: falseallowCredentials: true# Response headers that should be made available to scripts running in the browser, in response to a cross-origin request## - Type: array<string># - Required: falseexposedResponseHeaders:- example-value# Time in seconds that browser can cache the response for a preflight request## - Type: number# - Required: falsemaxAge: 3600# Attaches a custom domains to this Web Service## Stacktape allows you to connect your custom domain names to some of your resources# (Web Service, HTTP API Gateways, Application Load Balancers and Buckets with CDNs).## Connecting a custom domain to the resource does 2 things:# - **Creates DNS records**:# - If you use your custom domain with a resource, Stacktape automatically creates a DNS record (during deploy) pointing the specified domain name to the resource.# - **Adds TLS certificates**# - If the origin resource (HTTP API Gateway, Application Load Balancer or CDN) uses HTTPS protocol, Stacktape takes care of# issuing and attaching correct (free, AWS-managed) certificate to the resource.# This means, you do not have to deal with TLS termination as it is handled by the connected resource.# - If you want to use your own certificates, you can configure `customCertificateArns`.## > To manage a custom domain, it first needs to be added to your AWS account.# > This means that a [hosted zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHZWorkingWith.html)# > (collection of records managed together for a given domain)# > for your domain exists in your AWS account and your domain registrar's name servers are pointing to it.# > To learn more, refer to [Adding a domain guide](https://docs.stacktape.com/other-resources/domains-and-certificates/#adding-domain).## - Type: array<object (reference)># - Required: falsecustomDomains:- domainName: api.example.comcustomCertificateArn: example-value# Configures AWS Cloudfront CDN (Content Delivery Network) to be in front of your Web Service## - CDN is a globally distributed network that can cache responses from your Web Service at the edge - close to your users.# - AWS Cloudfront has 205 edge locations on 6 continents.# - The CDN is used to:# - reduce latency & improve load times# - reduce bandwidth costs# - reduce the amount of traffic coming to the origin (Web Service containers)# - improve security# - CDN caches responses from the origin at the edge for specified amount of time.# - If the content requested by the client is in the CDN cache,# the CDN immediately returns it to the client without making a request to the origin.# - If the content is NOT in the cache, the CDN makes a request to the Origin.# The response from the origin is then forwarded to the client, and cached at the edge.## - Type: object# - Required: falsecdn:# Enables the CDN### - Type: boolean# - Required: true# - Default: falseenabled: true# Configures custom caching options## - Configures the caching behavior of your edge distribution (what & when should stay in cache, and when to refetch it from the origin).# - When response from the origin does not contain neither `cache-control` nor `expires` headers default caching behaviour is used.# - Default caching behaviour depends on the type of origin the CDN is attached to:# - **bucket** - by default objects are cached for 6 months (or until the CDN cache is invalidated).# - **http-api-gateway** and **application-load-balancer** - by default responses are not cached.## - Type: object# - Required: falsecachingOptions:# Only responses to the requests with these methods will be cached## - Possible values are:# - `['GET', 'HEAD']`# - `['GET', 'HEAD', 'OPTIONS']`## - Type: array<string># - Required: falsecacheMethods:- GET# The minimum amount of time in seconds that the objects will stay in the CDN cache before another request is sent to the origin## - To learn more about cache expiration, refer to [AWS Docs](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html)## - Type: number# - Required: falseminTTL: 100# The maximum amount of time in seconds that the objects will stay in the CDN cache before another request is sent to the origin## - To learn more about cache expiration, refer to [AWS Docs](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html)## - Type: number# - Required: falsemaxTTL: 100# The default amount of time in seconds that the objects will stay in the CDN cache before another request is sent to the origin## - To learn more about cache expiration, refer to [AWS Docs](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/Expiration.html)## - Type: number# - Required: falsedefaultTTL: 100# Disables compression of the objects served by the CDN## - Compression is enabled by default.# - Compression can significantly reduce the size of the responses from the CDN.# In some cases, less than a quarter the size of the original. This can result in a better performance# and lower transfer costs.# - The CDN compresses objects using the `Gzip` and `Brotli` compression methods.# - If the viewer supports both formats, Brotli version is used.# - The client must indicate that it accepts compressed files using the `Accept-Encoding` HTTP header.# - To learn more about compression, refer to [AWS Docs](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/ServingCompressedFiles.html)## - Type: boolean# - Required: false# - Default: falsedisableCompression: false# Configures HTTP headers, cookies, and URL query strings to include in the cache key## - By default the cache key depends on the type of origin the CDN routes to:# - **bucket** - only `url path` is part of the cache key# - **http-api-gateway** and **application-load-balancer** - only `url path` and `query string` are part of the cache key# - The values included in the cache key are automatically forwarded in the requests that the CDN sends to the origin.## - Type: object# - Required: falsecacheKeyParameters:# Configures cookies that will be included in the cache key## - By default no cookies are included in the cache key.## - Type: object# - Required: falsecookies:# No cookies are included in the cache key## - Type: boolean# - Required: falsenone: true# Only the listed cookies are included in the cache key## - Type: array<string># - Required: falsewhitelist:- example-value# All cookies except the ones listed are included in the cache key## - Type: array<string># - Required: falseallExcept:- example-value# All cookies are included in the cache key## - Type: boolean# - Required: falseall: true# Configures headers that will be included included in the cache key## - By default no headers (except `Accept-Encoding` for compression to work) are included in the cache key.## - Type: object# - Required: falseheaders:# No headers are included in the cache key## - Type: boolean# - Required: falsenone: true# Only the headers listed are included in the cache key## - Type: array<string># - Required: falsewhitelist:- example-value# Configures query parameters that will be included in the cache key## - The query params included in the cache key are automatically forwarded in the requests that the CDN sends to the origin.# - By default no query params are included in the cache key.## - Type: object# - Required: falsequeryString:# All query params are included in the cache key## - Type: boolean# - Required: falseall: true# No query params are included in the cache key## - Type: boolean# - Required: falsenone: true# Only the query parameters listed are included in the cache key## - Type: array<string># - Required: falsewhitelist:- example-value# Specifies id of pre-created cache policy that you wish to use## - Use this in a case you wish to use pre-created cache policy, instead of configuring `ttl`, `cacheKeyParameters` and other options.## - Type: string# - Required: falsecachePolicyId: example-value# Configures which parts of the request are forwarded to the origin (headers, query parameters, cookies etc.)## - Type: object# - Required: falseforwardingOptions:# Adds static headers that the CDN will add to all requests sent to the origin## - Type: array<object (reference)># - Required: falsecustomRequestHeaders:- headerName: myHeaderNamevalue: example-value# Configured methods that will be forwarded by the CDN to the origin## - If not set, all methods are forwarded## - Type: array<string># - Required: falseallowedMethods:- GET- POST- PUT- DELETE# Configured cookies forwarded to the origin## - If not set, all cookies are forwarded# - All cookies that are part of the cache key (see `cachingOptions`) are automatically forwarded to the origin.## - Type: object# - Required: falsecookies:# No cookies are forwarded to the origin## - Type: boolean# - Required: falsenone: true# Only the cookies listed are forwarded to the origin## - Type: array<string># - Required: falsewhitelist:- example-value# All cookies are forwarded to the origin## - Type: boolean# - Required: falseall: true# Configured headers will be forwarded to the origin## - If not set, all headers are forwarded# - All headers that are part of the cache key (see `cachingOptions`) are automatically forwarded to the origin.## > Warning: `Authorization` header must be set to be used as a cache key parameter within the caching options in order to be forwarded to the origin. This is to avoid unauthorized access to the resources.## - Type: object# - Required: falseheaders:# No headers are forwarded to the origin## - Type: boolean# - Required: falsenone: true# Only the headers listed are forwarded to the origin## - Type: array<string># - Required: falsewhitelist:- example-value# All viewer headers are forwarded to the origin## - Type: boolean# - Required: falseallViewer: true# All viewer headers and additional listed CDN headers are forwarded to the origin## - Type: array<string># - Required: falseallViewerAndWhitelistCloudFront:- example-value# All viewer headers except those that are explicitly specified are forwarded to the origin## - Type: array<string># - Required: falseallExcept:- example-value# Configured query params will be forwarded to the origin## - If not set, all query string parameters are forwarded# - All query string parameters that are part of the cache key (see `cachingOptions`) are automatically forwarded to the origin.## - Type: object# - Required: falsequeryString:# All query params are forwarded to the origin## - Type: boolean# - Required: falseall: true# No query params are forwarded to the origin## - Type: boolean# - Required: falsenone: true# Only the query parameters listed are forwarded to the origin## - Type: array<string># - Required: falsewhitelist:- example-value# Specifies id of pre-created origin request policy that you wish to use## - Use this in a case you wish to use pre-created origin request policy, instead of configuring `cookies`, `headers` and `queryString` options.## - Type: string# - Required: falseoriginRequestPolicyId: example-value# Enables you to redirect specific requests to a different origin## - Each incoming request to the CDN is first evaluated against route rewrites. The requested path is compared with path pattern specified in route rewrite.# - If the requested path matches the path pattern specified by route rewrite, the request is sent to the configured route.# - Route rewrites are evaluated in order. The first match is where the request will be sent to.# - If no match is found, request is sent to the default origin (the one that the CDN is attached to).## **Example use cases**:# - Most of the content you are serving is a static content# served from a bucket (static website). Some content however needs to be# rendered dynamically by a lambda function. You can route paths that need# to be rendered dynamically to the Lambda function.# - You want to cache your `jpg` files longer than# other files. You can create route rewrite that will catch every path# ending with `jpg` and set custom caching options for these paths.## - Type: array<object (reference)># - Required: falserouteRewrites:- path: example-valueroutePrefix: example-value# Attaches a custom domains to this CDN## Stacktape allows you to connect your custom domain names to some of your resources# (Web Service, Nextjs web, HTTP API Gateways, Application Load Balancers and Buckets with CDNs).## Connecting a custom domain to the resource does 2 things:# - **Creates DNS records**:# - If you use your custom domain with a resource, Stacktape automatically creates a DNS record (during deploy) pointing the specified domain name to the resource.# - **Adds TLS certificates**# - If the origin resource (HTTP API Gateway, Application Load Balancer or CDN) uses HTTPS protocol, Stacktape takes care of# issuing and attaching correct (free, AWS-managed) certificate to the resource.# This means, you do not have to deal with TLS termination as it is handled by the connected resource.# - If you want to use your own certificates, you can configure `customCertificateArns`.## > To manage a custom domain, it first needs to be added to your AWS account.# > This means that a [hosted zone](https://docs.aws.amazon.com/Route53/latest/DeveloperGuide/AboutHZWorkingWith.html)# > (collection of records managed together for a given domain)# > for your domain exists in your AWS account and your domain registrar's name servers are pointing to it.# > To learn more, refer to [Adding a domain guide](https://docs.stacktape.com/other-resources/domains-and-certificates/#adding-domain).## - Type: array<object (reference)># - Required: falsecustomDomains:- domainName: api.example.comcustomCertificateArn: example-value# Configures Edge function triggers## - You can associate `edge-lambda-function` with CDN to be executed:# - `onRequest` - function is executed when CDN receives a request from a client(viewer) before checking CDN cache# - `onResponse` - function is executed before returning the response to the client(viewer)## - Potential use-cases for using edge functions:# - generating immediate HTTP response without the need to check CDN cache or forward to the origin# - modifying request (i.e rewrite url, headers etc) before forwarding to the origin# - inspection of cookies# - inspection/validation of authorization headers and tokens## - Type: object# - Required: falseedgeFunctions:# Name of the edge-lambda-function in the config## - `onRequest` function is triggered when CDN receives a request from a client(viewer):# - You can modify the request before forwarding it to the origin# - You can return immediate response to the client(viewer)# - You can make network calls to external resources to confirm user credentials, or fetch additional content# - The body of the request is exposed to the function with some restrictions# (refer to [AWS docs](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html#lambda-at-edge-restrictions-request-body) for more details)## - Type: string# - Required: falseonRequest: example-value# Name of the edge-lambda-function in the config## - `onResponse` function is triggered before CDN returns response to the client(viewer):# - You can modify the response (headers, cookies) before returning to the client# - The function does not execute in following cases:# - When the origin returns an HTTP status code of 400 or higher.# - When the response is generated from a function that was triggered by a viewer request event (`onRequest` function).## - Type: string# - Required: falseonResponse: example-value# Name of the edge-lambda-function in the config## > Use `onOriginRequest` trigger only if you are an advanced user and know what you are doing.# > Using this trigger can **override the default behaviour configured by Stacktape**.# > Stacktape uses pre-configured lambdas together with this trigger when using CDN with:# > - **bucket** - Stacktape uses this trigger with pre-configured lambda to correctly resolve URLs# > - **web-service, http-api-gateway, application-load-balancer** - Stacktape uses this trigger with pre-configured lambda to adjust headers before sending to origin# - `onOriginRequest` function is triggered after CDN receives a request from a client(viewer) but before the request is send to the origin:# - This means that function is NOT triggered when response is found in the cache (as no request to origin needs to happen)# - You can modify the request before forwarding it to the origin# - You can return immediate response to the client(viewer) - the response will be cached same way as if it was from the origin# - You can make network calls to external resources to confirm user credentials, or fetch additional content# - The body of the request is exposed to the function with some restrictions# (refer to [AWS docs](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/edge-functions-restrictions.html#lambda-at-edge-restrictions-request-body) for more details)## - Type: string# - Required: falseonOriginRequest: example-value# Name of the edge-lambda-function in the config## - `onOriginResponse` function is triggered after origin returns response but before it is sent back to the client(viewer):# - You can modify the response (headers, cookies) before returning to the client - the response will be cached same way as if it was from the origin# - You can update the response status.## - Type: string# - Required: falseonOriginResponse: example-value# Configures locations from which the CDN serves traffic## - Higher price class results in more locations that serve your traffic.# - This can result in better performance in some regions, but is more costly.# - Example: If your users are located only in US & Europe, you can save money by configuring `PriceClass_100`# - To learn more about price classes, refer to [AWS docs](https://aws.amazon.com/cloudfront/pricing/)## - Type: enum: [PriceClass_100, PriceClass_200, PriceClass_All]# - Required: false# - Default: PriceClass_All# - Allowed values: [PriceClass_100, PriceClass_200, PriceClass_All]cloudfrontPriceClass: PriceClass_All# Prefixes requests to the origin with specified prefix## - Incoming requests will be prefixed with `defaultRoutePrefix` before being forwarded to the origin.# - Example: If the CDN receives a request with path `/my/resource/url`, the request will be sent to the origin as# `/default_route_prefix/my/resource/url`## - Type: string# - Required: falsedefaultRoutePrefix: example-value# Custom error document URL## - Error document is requested by the CDN if the original request to the origin responds with an error code `404`.# - Example: `/error.html`## - Type: string# - Required: false# - Default: /404.htmlerrorDocument: /404.html# Custom index (root) document served for requests with root path `/`### - Type: string# - Required: false# - Default: '/index.html'indexDocument: '/index.html'# Disables invalidating of the CDN cache after each deployment## - Cache is by default invalidated after every deploy to prevent serving outdated content to your users.# - When invalidating the cache, CDN flushes all the cached content and new requests# will result in a request to the origin (bucket, application-load-balancer, function or http-api-gateway)## - Type: boolean# - Required: false# - Default: falsedisableInvalidationAfterDeploy: false# Name of the 'web-app-firewall' resource to used with your CDN## - You can use `web-app-firewall` to protect your resources from common web exploits that could affect application availability, compromise security, or consume excessive resources.# - Web app firewall protects your application by filtering dangerous requests coming to your app.# You can read more about the firewall [in our docs](https://docs.stacktape.com/security-resources/web-app-firewalls/).## - Type: string# - Required: falseuseFirewall: example-value# Configures deployment (update) behaviour of the web-service## - Using `deployment` you can update the web-service in live environment in a safe way - by shifting the traffic to the new version gradually.# - Gradual shift of traffic gives you opportunity to test/monitor the workload during update and in a case of a problem quickly rollback.# - Deployment supports multiple strategies:# - **Canary10Percent5Minutes** - Shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed five minutes later.# - **Canary10Percent15Minutes** - Shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed 15 minutes later.# - **Linear10PercentEvery1Minute** - Shifts 10 percent of traffic every minute until all traffic is shifted.# - **Linear10PercentEvery3Minutes** - Shifts 10 percent of traffic every three minutes until all traffic is shifted.# - **AllAtOnce** - Shifts all traffic to the updated web-service at once.# - You can validate/abort deployment(update) using lambda-function hooks.# > When using deployment, your web-service must use **application-load-balancer** load balancing type## - Type: object# - Required: falsedeployment:# Determines strategy used for deployment (update)## - **Canary10Percent5Minutes** - Shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed five minutes later.# - **Canary10Percent15Minutes** - Shifts 10 percent of traffic in the first increment. The remaining 90 percent is deployed 15 minutes later.# - **Linear10PercentEvery1Minute** - Shifts 10 percent of traffic every minute until all traffic is shifted.# - **Linear10PercentEvery3Minutes** - Shifts 10 percent of traffic every three minutes until all traffic is shifted.# - **AllAtOnce** - Shifts all traffic to the updated container workload at once.## - Type: enum: [AllAtOnce, Canary10Percent15Minutes, Canary10Percent5Minutes, Linear10PercentEvery1Minutes, Linear10PercentEvery3Minutes]# - Required: true# - Allowed values: [AllAtOnce, Canary10Percent15Minutes, Canary10Percent5Minutes, Linear10PercentEvery1Minutes, Linear10PercentEvery3Minutes]strategy: AllAtOnce# The name of the lambda function to run before traffic routing starts.## - Typical usage is performing checks before the traffic is shifted# - The function must send response (success of failure) to the code deploy API.# To learn more, refer to [documentation](https://docs.stacktape.com/compute-resources/multi-container-workloads/#hook-functions)## - Type: string# - Required: falsebeforeAllowTrafficFunction: example-value# The name of the lambda function to run after traffic is shifted.## - Typical usage is performing final checks after the traffic is shifted# - The function must send response (success of failure) to the code deploy API.# To learn more, refer to [documentation](https://docs.stacktape.com/compute-resources/multi-container-workloads/#hook-functions)## - Type: string# - Required: falseafterTrafficShiftFunction: example-value# Port of the listener to be used for test traffic## - Specify this property if you are using `beforeAllowTrafficFunction` and your load balancer uses custom listeners# - To see how to use test listener with beforeAllowTrafficFunction refer to [test listener](https://docs.stacktape.com/compute-resources/multi-container-workloads/#test-traffic-listener).## - Type: number# - Required: falsetestListenerPort: 3000# Name of the `web-app-firewall` resource to be used for this web-service## - You can use `web-app-firewall` to protect your resources from common web exploits that could affect application availability, compromise security, or consume excessive resources.# - Web app firewall protects your application by filtering dangerous requests coming to your app.# You can read more about the firewall [in our docs](https://docs.stacktape.com/security-resources/web-app-firewalls/).## - Type: string# - Required: falseuseFirewall: example-value# Configures an image used for the service container## - Type: union (anyOf)# - Required: true## - Type: object# - Required: truepackaging:## - Type: string# - Required: truetype: stacktape-image-buildpack# Configures properties for the image automatically built by Stacktape from the source code.## - Type: object# - Required: trueproperties:# Path to the entry point of your compute resource (relative to the stacktape config file)## - Stacktape tries to bundle all your source code with its dependencies into a single file.# - If a certain dependency doesn't support static bundling (because it depends on binary executable, uses dynamic require() calls, etc.),# Stacktape will install it and copy it to the bundle## - Type: string# - Required: trueentryfilePath: ./src/index.ts# Configuration of packaging properties specific to given language## - Type: union (anyOf)# - Required: false# Builds image with support for glibc-based binaries## - You can use this option to add support for glibc-based native dependencies.# - This means that Stacktape will use different (and significantly larger) base-image for your container.# - Stacktape uses alpine Docker images by default. These images use musl, instead of glibc.# - Packages with C-based binaries compiled using glibc doesn't work with musl.## - Type: boolean# - Required: falserequiresGlibcBinaries: true# List of commands to be executed during docker image building.## - This property enables you to execute custom commands in your container during image building.# - Commands are executed using docker `RUN` directive.# - Commands can be used to install required additional dependencies into your container.## - Type: array<string># - Required: falsecustomDockerBuildCommands:- apt-get update && apt-get install -y curl- npm install -g pm2# Files that should be explicitly included in the deployment package (glob pattern)## - Example glob pattern: `images/*.jpg`# - The path is relative to the stacktape configuration file location or to `cwd` if configured using `--currentWorkingDirectory` command line option.## - Type: array<string># - Required: falseincludeFiles:- public/**/*- assets/*.png# Files that should be explicitly excluded from deployment package (glob pattern)## Example glob pattern: `images/*.jpg`## - Type: array<string># - Required: falseexcludeFiles:- *.test.ts- node_modules/**# Dependencies to ignore.## - These dependencies won't be a part of your deployment package.## - Type: array<string># - Required: falseexcludeDependencies:- example-value# Environment variables injected to the runtime environment## - Environment variables are often used to inject information about other parts of the infrastructure (such as database URLs, secrets, etc.).## - Type: array<object (reference)># - Required: falseenvironment:- name: NODE_ENVvalue: production- name: DATABASE_URLvalue: $ResourceParam(myDatabase, connectionString)# Configures logging behavior for the service container## - Container logs (stdout and stderr) are automatically sent to a pre-created CloudWatch log group.# - By default, logs are retained for 180 days..# - You can browse your logs in 2 ways:# - go to the log group page in the AWS CloudWatch console. You can use `stacktape stack-info` command to get a# direct link.# - use [stacktape logs command](https://docs.stacktape.com/cli/commands/logs/) to print logs to the console## - Type: object# - Required: falselogging:# Disables the collection of containers's application logs (stdout and stderr) to CloudWatch## - Type: boolean# - Required: false# - Default: falsedisabled: false# Amount of days the logs will be retained in the log group## - Type: enum: [1, 120, 14, 150, 180, 1827, 3, 30, 365, 3653, 400, 5, 545, 60, 7, 731, 90]# - Required: false# - Default: 90# - Allowed values: [1, 120, 14, 150, 180, 1827, 3, 30, 365, 3653, 400, 5, 545, 60, 7, 731, 90]retentionDays: 90# Configures forwarding of logs to specified destination## - Log forwarding is done using [Amazon Kinesis Data Firehose](https://aws.amazon.com/kinesis/data-firehose/) delivery stream.# - When using log forwarding, you will incur costs based on the amount of data being transferred to the destination (~$0.03 per transferred GB).# Refer to [AWS Kinesis Firehose Pricing](https://aws.amazon.com/kinesis/data-firehose/pricing/?nc=sn&loc=3) page to see details.# - Currently supported destinations for logs:# - `http-endpoint`# - delivers logs to any HTTP endpoint.# - The endpoint must follow [Firehose request and response specifications](https://docs.aws.amazon.com/firehose/latest/dev/httpdeliveryrequestresponse.html).# (Many of the third party vendors are compliant with this specifications out of the box.)# - `datadog`# - delivers logs to [Datadog](https://www.datadoghq.com/).# - `highlight`# - delivers logs to [Highlight.io](https://www.highlight.io/) project.## Refer to [our docs](https://docs.stacktape.com/configuration/log-forwarding/) for more information.## > Logs that fail to be delivered to the destination even after multiple retries (time spend on retries can be configured) are put into bucket with name `{stackName}-{resourceName}-logs-{generatedHash}`## - Type: union (anyOf)# - Required: false## - Type: object# - Required: falselogForwarding:## - Type: string# - Required: truetype: http-endpoint## - Type: object# - Required: trueproperties:# HTTPS endpoint where logs will be forwarded## - Type: string# - Required: trueendpointUrl: https://example.com# Specifies whether to use GZIP compression for the request## - When enabled, Firehose uses the content encoding to compress the body of a request before sending the request to the destination## - Type: boolean# - Required: falsegzipEncodingEnabled: true# Parameters included in each call to HTTP endpoint## - Key/Value pairs containing additional metadata you wish to send to the HTTP endpoint.# - Parameters are delivered within **X-Amz-Firehose-Common-Attributes** header as a JSON object with following format: `{"commonAttributes":{"param1":"val1", "param2":"val2"}}`## - Type: object# - Required: false# Amount of time spend on retries.## - The total amount of time that Kinesis Data Firehose spends on retries.# - This duration starts after the initial attempt to send data to the custom destination via HTTPS endpoint fails.# - Logs that fail to be delivered to the HTTP endpoint even after multiple retries (time spend on retries can be configured) are put into bucket with name `{stackName}-{resourceName}-logs-{generatedHash}`## - Type: number# - Required: falseretryDuration: 100# Access key (credentials), needed for authenticating with endpoint## - Access key is carried within a **X-Amz-Firehose-Access-Key** header# - The configured key is copied verbatim into the value of this header.The contents can be arbitrary and can potentially represent a JWT token or an ACCESS_KEY.# - It is recommended to use [secret](https://docs.stacktape.com/resources/secrets/) for storing your access key.## - Type: string# - Required: falseaccessKey: example-value# Configures computing resources(CPU/memory and EC2 instance types) for the service container## - When specifying resources there are two underlying compute engines to use:# - **Fargate** - abstracts the server and cluster management away from the user, allowing them to run containers without# managing the underlying servers, simplifying deployment and management of applications but offering less control over the computing environment.# - **EC2 (Elastic Compute Cloud)** - provides granular control over the underlying servers (instances).# By choosing `instanceTypes` you get complete control over the computing environment and the ability to optimize for specific workloads.## - **To use Fargate**: Do NOT specify `instanceTypes` and specify `cpu` and `memory` properties.# - **To use EC2 instances**: specify `instanceTypes`.## - Type: object# - Required: trueresources:# Number of virtual CPUs available to containers## - If you specify `instanceTypes` property, and do not set `cpu`, cpus of an EC2 instance are shared between **instances of your compute resource** running on the EC2 instance.## - Type: enum: [0.25, 0.5, 1, 16, 2, 4, 8]# - Required: false# - Allowed values: [0.25, 0.5, 1, 16, 2, 4, 8]cpu: 0.5# Amount of memory in MB available to containers## - If you do not specify `instanceTypes` property you are using Fargate and you are only allowed to use following memory and vCPU configurations:# - 0.25 vCPU: `512`, `1024`, `2048`# - 0.5 vCPU: `1024`, `2048`, `3072`, `4096`# - 1 vCPU: `2048`, `3072`, `4096`, `5120`, `6144`, `7168`, `8192`# - 2 vCPU: Between `4096` and `16384` GB in `1024-MB` increments# - 4 vCPU: Between `8192` and `30720` in `1024-MB` increments# - 8 vCPU: Between `16384` and `61440` in `4096-MB` increments# - 16 vCPU: Between `32768` and `122880` in `8192-MB` increments# - If you specify `instanceTypes` property, this property is optional. If you do not set `memory` property, Stacktape sets the memory# to a maximum possible value so that all EC2 instance types listed in `instanceTypes` are able provide that amount of memory.## In other words: Stacktape sets the memory so that the smallest instance type in `instanceTypes`(in terms of memory) is able to provide that amount of memory.## - Type: number# - Required: falsememory: 2048# Types of EC2 instances(VMs) that can be used## - EC2 instances are automatically added or removed to meet the scaling needs of your compute resource(see also `scaling` property).# - When using `instanceTypes`, **we recommend to specify only one instance type and to NOT set `cpu` or `memory` properties**.# By doing so, Stacktape will set the cpu and memory to fit the instance precisely - resulting in the optimal resource utilization.# - Stacktape leverages [ECS Managed Scaling](https://docs.aws.amazon.com/AmazonECS/latest/developerguide/cluster-auto-scaling.html) with target utilization 100%.# This means that there are no unused EC2 instances(unused = not running your workload/service) running. Unused EC2 instances are terminated.# - Ordering in `instanceTypes` list matters. Instance types which are higher on the list are preferred over the instance types which are lower on the list.# Only when instance type higher on the list is not available, next instance type on the list will be used.# - For exhaustive list of available EC2 instance types refer to [AWS docs](https://aws.amazon.com/ec2/instance-types/).## > To ensure that your containers are running on patched and up-to-date EC2 instances, your instances are automatically# > refreshed (replaced) once a week(Sunday 00:00 UTC). Your compute resource stays available throughout this process.## - Type: array<string># - Required: falseinstanceTypes:- t3.medium- t3.large# Enable EC2 Auto Scaling warm pool## - **Only works when you specify exactly one instance type in `instanceTypes`**. Warm pools are not supported with mixed instance types.# - Creates a warm pool of pre-initialized EC2 instances that are kept in a `Stopped` state, ready to be quickly launched when scaling up.# - Warm pool instances are maintained between the desired capacity count and the maximum capacity count of your Auto Scaling group.# - When scaling up is needed, instances from the warm pool are started much faster than launching new instances from scratch.# - **Cost optimization**: Instances in the warm pool are in `Stopped` state, so you only pay for EBS storage, not for compute time.# - Improves scaling performance by reducing the time needed to launch new instances during traffic spikes.# - The warm pool size is automatically managed based on your workload's scaling configuration.# - For more details, see [AWS Auto Scaling warm pools documentation](https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-warm-pools.html).## - Type: boolean# - Required: falseenableWarmPool: true# Configures service scaling## - Scaling is done horizontally (adding more parallel containers)# - Incoming requests to your service/workload are split between all available containers## - Type: object# - Required: falsescaling:# Minimum number of workload/service instances running in parallel## - Type: number# - Required: false# - Default: 1minInstances: 1# Maximum number of workload/service instances running in parallel## - Type: number# - Required: false# - Default: 1maxInstances: 3# Configures when the scaling is triggered## - Type: object# - Required: falsescalingPolicy:# Maximum amount for CPU utilization after which the `scale out`(adding new workload/service instance) is triggered## - Utilization is calculated as an average utilization of all workload/service instances running.# - Metrics are collected in 1 minute intervals.# - If average CPU utilization metric is below this value, the `scale in` is triggered (removing an instance).## - Type: number# - Required: false# - Default: 80keepAvgCpuUtilizationUnder: 80# Maximum amount for memory utilization after which the `scale out`(adding new workload/service instance) is triggered## - Utilization is calculated as an average utilization of all workload/service instances running.# - Metrics are collected in 1 minute intervals.# - If average memory utilization metric is below this value, the `scale in` is triggered (removing an instance).## - Type: number# - Required: false# - Default: 80keepAvgMemoryUtilizationUnder: 80# Configuration of internal healthcheck (used to determine, if the service container is healthy)## - If the container is considered unhealthy, it is killed and replaced with a new one.## - Type: object# - Required: falseinternalHealthCheck:# Command to run that determines if the container is healthy## - Must start with either:# - `CMD` to execute the command arguments directly# - `CMD-SHELL` to run the command with the container's default shell.# - An exit code `0` indicates success, and non-zero exit code indicates failure.# - Example: `[ "CMD-SHELL", "curl -f http://localhost/ || exit 1" ]`</code>`## - Type: array<string># - Required: truehealthCheckCommand:- example-value# Time period in seconds between health check executions## - Must be between 5 and 300 seconds.## - Type: number# - Required: false# - Default: 30intervalSeconds: 30# The time period in seconds to wait for a health check to succeed before it is considered failed## - Must be between 2 and 60 seconds.## - Type: number# - Required: false# - Default: 5timeoutSeconds: 5# The number of times to retry a failed health check before the container is considered unhealthy.## - Must be between 1 and 10 retries.## - Type: number# - Required: false# - Default: 3retries: 3# "Grace" period to give the container to bootstrap before failed health checks count towards the maximum number of retries.## - Must be between 0 and 300 seconds.# - Disabled by default.## - Type: number# - Required: falsestartPeriodSeconds: 100# Amount of time in seconds to wait before the container is forcefully killed if it doesn't exit normally on its own.## - When a container is stopped, a `SIGTERM` signal is sent to container's entry process, usually PID 1.# After a timeout has lapsed, the process will be sent a `SIGKILL` signal.# By default, there is a 2 second delay between the delivery of `SIGTERM` and `SIGKILL` signals.# - Setting stop timeout can help you give container the time to "finish the job" or to "cleanup" when deploying new version of container or when deleting the service.# - Minimum stop timeout is 2 seconds, maximum 120 seconds.## - Type: number# - Required: falsestopTimeout: 30# Enables remote interactive shell sessions into running containers## - When enabled, you can use `stacktape container:session` command to start an interactive shell session inside a running container# - Uses AWS ECS Exec and SSM Session Manager under the hood to establish secure connection to the container# - SSM agent binaries are mounted into your container and the SSM core agent runs alongside your application (using small amount of CPU/memory)# - Useful for debugging issues and quick inspecting deployed containers## - Type: boolean# - Required: falseenableRemoteSessions: true# List of volume mounts to attach to the container## - Volumes provide persistent storage for your container# - Currently supports EFS (Elastic File System) volumes# - Multiple containers can share the same volume# - Volumes persist even if the container is stopped or replaced## - Type: array<object (reference)># - Required: falsevolumeMounts:- type: efs# List of helper containers to extend the service## Helper containers provide additional functionality alongside your main service container.## **Container types:**# - **`run-on-init`** - Runs before the service starts. The service container waits until the run-on-init container exits successfully (exit code 0).# Use for setup tasks like database migrations, environment preparation, or dependency initialization.# - **`always-running`** - Runs alongside the service container throughout its lifecycle. Starts before the service and stops when the service stops.# Use for supporting services like monitoring agents, log collectors, or debugging tools.## **Networking:**# - always-running containers can communicate with the service container via `localhost:<port>` where `<port>` is the service's exposed port (default: 3000).## - Type: array<object (reference)># - Required: falsesideContainers:- containerType: always-runningname: example-nameessential: true# Configures access to other resources of your stack (such as databases, buckets, event-buses, etc.) and aws services## By referencing resources (or services) in `connectTo` list, Stacktape automatically:# - configures correct compute resource's **IAM role permissions** if needed# - sets up correct **security group rules** to allow access if needed# - **injects relevant environment variables** containing information about resource you are connecting to into the compute resource's runtime# - names of environment variables use upper-snake-case and are in form `STP_[RESOURCE_NAME]_[VARIABLE_NAME]`,# - examples: `STP_MY_DATABASE_CONNECTION_STRING` or `STP_MY_EVENT_BUS_ARN`,# - list of injected variables for each resource type can be seen below.### Granted permissions and injected environment variables are different depending on resource type:### `Bucket`# - **Permissions:**# - list objects in a bucket# - create / get / delete / tag object in a bucket# - **Injected env variables**: `NAME`, `ARN`### `DynamoDB table`# - **Permissions:**# - get / put / update / delete item in a table# - scan / query a table# - describe table stream# - **Injected env variables**: `NAME`, `ARN`, `STREAM_ARN`### `MongoDB Atlas cluster`# - **Permissions:**# - Allows connection to a cluster with `accessibilityMode` set to `scoping-workloads-in-vpc`. To learn more about# MongoDB Atlas clusters accessibility modes, refer to# [MongoDB Atlas cluster docs](https://docs.stacktape.com/3rd-party-resources/mongo-db-atlas-clusters/#accessibility).# - Creates access "user" associated with compute resource's role to allow for secure credential-less access to the the cluster# - **Injected env variables**: `CONNECTION_STRING`### `Relational(SQL) database`# - **Permissions:**# - Allows connection to a relational database with `accessibilityMode` set to `scoping-workloads-in-vpc`. To learn more about# relational database accessibility modes, refer to [Relational databases docs](https://docs.stacktape.com/resources/relational-databases#accessibility).# - **Injected env variables**: `CONNECTION_STRING`, `JDBC_CONNECTION_STRING`, `HOST`, `PORT`# (in case of aurora multi instance cluster additionally: `READER_CONNECTION_STRING`, `READER_JDBC_CONNECTION_STRING`, `READER_HOST`)### `Redis cluster`# - **Permissions:**# - Allows connection to a redis cluster with `accessibilityMode` set to `scoping-workloads-in-vpc`. To learn more about# redis cluster accessibility modes, refer to [Redis clusters docs](https://docs.stacktape.com/resources/redis-clusters#accessibility).# - **Injected env variables**: `HOST`, `READER_HOST`, `PORT`### `Event bus`# - **Permissions:**# - publish events to the specified Event bus# - **Injected env variables**: `ARN`### `Function`# - **Permissions:**# - invoke the specified function# - invoke the specified function via url (if lambda has URL enabled)# - **Injected env variables**: `ARN`### `Batch job`# - **Permissions:**# - submit batch-job instance into batch-job queue# - list submitted job instances in a batch-job queue# - describe / terminate a batch-job instance# - list executions of state machine which executes the batch-job according to its strategy# - start / terminate execution of a state machine which executes the batch-job according to its strategy# - **Injected env variables**: `JOB_DEFINITION_ARN`, `STATE_MACHINE_ARN`### `User auth pool`# - **Permissions:**# - full control over the user pool (`cognito-idp:*`)# - for more information about allowed methods refer to [AWS docs](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazoncognitouserpools.html)# - **Injected env variables**: `ID`, `CLIENT_ID`, `ARN`#### `SNS Topic`# - **Permissions:**# - confirm/list subscriptions of the topic# - publish/subscribe to the topic# - unsubscribe from the topic# - **Injected env variables**: `ARN`, `NAME`#### `SQS Queue`# - **Permissions:**# - send/receive/delete message# - change visibility of message# - purge queue# - **Injected env variables**: `ARN`, `NAME`, `URL`### `Upstash Kafka topic`# - **Injected env variables**: `TOPIC_NAME`, `TOPIC_ID`, `USERNAME`, `PASSWORD`, `TCP_ENDPOINT`, `REST_URL`### `Upstash Redis`# - **Injected env variables**: `HOST`, `PORT`, `PASSWORD`, `REST_TOKEN`, `REST_URL`, `REDIS_URL`### `Private service`# - **Injected env variables**: `ADDRESS`### `aws:ses`(Macro)# - **Permissions:**# - gives full permissions to aws ses (`ses:*`).# - for more information about allowed methods refer to [AWS docs](https://docs.aws.amazon.com/service-authorization/latest/reference/list_amazonses.html)## - Type: array<string># - Required: falseconnectTo:- myDatabase- myBucket# Raw AWS IAM role statements appended to your resources's role.## - Type: array<object (reference)># - Required: falseiamRoleStatements:- Resource: ["example-value"]Sid: example-value
LoadBalancing alternatives
http-api-gateway
This example shows how to configure loadbalancing using http-api-gateway.
resources:myWebService:type: web-serviceproperties:# Configures what type of entry point is used for distributing traffic to containers## - Supported types of entry points are: `http-api-gateway` and `application-load-balancer` and `network-load-balancer`. To understand when to use which, refer to below sections.## `http-api-gateway` (default)# - distributes traffic to the available containers randomly# - uses pay-per-use pricing model (~$1 for million requests)# - pay-per-use pricing model is ideal for most workloads but once you cross ~500,000 requests per day,# it might be cheaper to use application-load-balancer## `application-load-balancer`# - distributes traffic to the available containers in a round robin fashion# - uses pricing which is combination of flat hourly charge(\~$0.0252/hour) and used LCUs(Load Balancer Capacity Units)(\~$0.08/hour)# - is eligible for free tier, for better understanding of pricing refer to [AWS docs](https://aws.amazon.com/elasticloadbalancing/pricing/)## `network-load-balancer`# - supports TCP and TLS protocols# - uses pricing which is combination of flat hourly charge(\~$0.0252/hour) and used LCUs(Load Balancer Capacity Units)(\~$0.08/hour)# - is eligible for free tier, for better understanding of pricing refer to [AWS docs](https://aws.amazon.com/elasticloadbalancing/pricing/)## - Type: object# - Required: trueloadBalancing:## - Type: string# - Required: truetype: http-api-gateway
application-load-balancer
This example shows how to configure loadbalancing using application-load-balancer.
resources:myWebService:type: web-serviceproperties:# Configures what type of entry point is used for distributing traffic to containers## - Supported types of entry points are: `http-api-gateway` and `application-load-balancer` and `network-load-balancer`. To understand when to use which, refer to below sections.## `http-api-gateway` (default)# - distributes traffic to the available containers randomly# - uses pay-per-use pricing model (~$1 for million requests)# - pay-per-use pricing model is ideal for most workloads but once you cross ~500,000 requests per day,# it might be cheaper to use application-load-balancer## `application-load-balancer`# - distributes traffic to the available containers in a round robin fashion# - uses pricing which is combination of flat hourly charge(\~$0.0252/hour) and used LCUs(Load Balancer Capacity Units)(\~$0.08/hour)# - is eligible for free tier, for better understanding of pricing refer to [AWS docs](https://aws.amazon.com/elasticloadbalancing/pricing/)## `network-load-balancer`# - supports TCP and TLS protocols# - uses pricing which is combination of flat hourly charge(\~$0.0252/hour) and used LCUs(Load Balancer Capacity Units)(\~$0.08/hour)# - is eligible for free tier, for better understanding of pricing refer to [AWS docs](https://aws.amazon.com/elasticloadbalancing/pricing/)## - Type: object# - Required: trueloadBalancing:## - Type: string# - Required: truetype: application-load-balancer## - Type: object# - Required: falseproperties:# Path on which load balancer performs healthcheck### - Type: string# - Required: false# - Default: /healthcheckPath: /# Interval in seconds for how often the healthcheck is performed### - Type: number# - Required: false# - Default: 5healthcheckInterval: 5# Timeout in seconds after which healthcheck is considered failed### - Type: number# - Required: false# - Default: 4healthcheckTimeout: 4
network-load-balancer
This example shows how to configure loadbalancing using network-load-balancer.
resources:myWebService:type: web-serviceproperties:# Configures what type of entry point is used for distributing traffic to containers## - Supported types of entry points are: `http-api-gateway` and `application-load-balancer` and `network-load-balancer`. To understand when to use which, refer to below sections.## `http-api-gateway` (default)# - distributes traffic to the available containers randomly# - uses pay-per-use pricing model (~$1 for million requests)# - pay-per-use pricing model is ideal for most workloads but once you cross ~500,000 requests per day,# it might be cheaper to use application-load-balancer## `application-load-balancer`# - distributes traffic to the available containers in a round robin fashion# - uses pricing which is combination of flat hourly charge(\~$0.0252/hour) and used LCUs(Load Balancer Capacity Units)(\~$0.08/hour)# - is eligible for free tier, for better understanding of pricing refer to [AWS docs](https://aws.amazon.com/elasticloadbalancing/pricing/)## `network-load-balancer`# - supports TCP and TLS protocols# - uses pricing which is combination of flat hourly charge(\~$0.0252/hour) and used LCUs(Load Balancer Capacity Units)(\~$0.08/hour)# - is eligible for free tier, for better understanding of pricing refer to [AWS docs](https://aws.amazon.com/elasticloadbalancing/pricing/)## - Type: object# - Required: trueloadBalancing:## - Type: string# - Required: truetype: network-load-balancer## - Type: object# - Required: trueproperties:## - Type: array<object (reference)># - Required: trueports:- port: 3000protocol: HTTP# Path on which load balancer performs healthcheck## - Only takes effect if `healthcheckProtocol` is set to `HTTP`## - Type: string# - Required: false# - Default: /healthcheckPath: /# Interval in seconds for how often the healthcheck is performed## Must be between 5 and 300## - Type: number# - Required: false# - Default: 5healthcheckInterval: 5# Timeout in seconds after which healthcheck is considered failed## Must be between 2 and 120## - Type: number# - Required: false# - Default: 4healthcheckTimeout: 4# Protocol the load balancer uses when performing health checks on targets## - The protocol the load balancer uses when performing health checks on targets.## - Type: enum: [HTTP, TCP]# - Required: false# - Default: TCP# - Allowed values: [HTTP, TCP]healthCheckProtocol: TCP# Port the load balancer uses when performing health checks on targets## - The port the load balancer uses to perform health checks on targets.# - By default uses the port that receives traffic from the load balancer## - Type: number# - Required: falsehealthCheckPort: 3000
RouteTo alternatives
application-load-balancer
This example shows how to configure routeto using application-load-balancer.
resources:myWebService:type: web-serviceproperties:cdn:routeRewrites:items:## - Type: object# - Required: truerouteTo:## - Type: string# - Required: truetype: application-load-balancer## - Type: object# - Required: trueproperties:# Name of the Load balancer## - Type: string# - Required: trueloadBalancerName: myLoadBalancerName# Port of the Load balancer listener## - You need to specify listener port if the load balancer you are routing to uses custom listeners.## - Type: number# - Required: falselistenerPort: 3000# Explicitly sets the origin domain name you wish to use when forwarding to load balancer## - This is required only if the load balancer has no `customDomains` attached and listener uses `customCertificateArns`## - Type: string# - Required: falseoriginDomainName: myOriginDomainName
http-api-gateway
This example shows how to configure routeto using http-api-gateway.
resources:myWebService:type: web-serviceproperties:cdn:routeRewrites:items:## - Type: object# - Required: truerouteTo:## - Type: string# - Required: truetype: http-api-gateway## - Type: object# - Required: trueproperties:# Name of the HTTP Api Gateway## - Type: string# - Required: truehttpApiGatewayName: myHttpApiGatewayName
function
This example shows how to configure routeto using function.
resources:myWebService:type: web-serviceproperties:cdn:routeRewrites:items:## - Type: object# - Required: truerouteTo:## - Type: string# - Required: truetype: function## - Type: object# - Required: trueproperties:# Name of the Web Service resource## - Type: string# - Required: truefunctionName: myFunctionName
custom-origin
This example shows how to configure routeto using custom-origin.
resources:myWebService:type: web-serviceproperties:cdn:routeRewrites:items:## - Type: object# - Required: truerouteTo:## - Type: string# - Required: truetype: custom-origin## - Type: object# - Required: trueproperties:# Domain name of the custom origin.## Example: `mydomain.com` or `domain.example.com`## - Type: string# - Required: truedomainName: api.example.com# Protocol to use when connecting to custom origin.### - Type: enum: [HTTP, HTTPS]# - Required: false# - Default: HTTPS# - Allowed values: [HTTP, HTTPS]protocol: HTTP# Port of the custom origin.## By default port number 443 is used for `HTTPS` origins and port number 80 is used for `HTTP` origins.## - Type: number# - Required: false# - Default: 443port: 3000
bucket
This example shows how to configure routeto using bucket.
resources:myWebService:type: web-serviceproperties:cdn:routeRewrites:items:## - Type: object# - Required: truerouteTo:## - Type: string# - Required: truetype: bucket## - Type: object# - Required: trueproperties:# Name of the bucket## - Type: string# - Required: truebucketName: my-example-bucket# Disables URL normalization (ability to use clean urls without the `.html` extension)## - URL normalization is enabled by default.# - URL normalization is useful when you want to serve HTML files from the bucket# - When the URL normalization is enabled, the CDN is able to fetch correct HTML files# from the bucket even when incomplete URL is used (without the `.html` extension)# - This enables you to use URLs such as `<<my-domain.com>>/about` instead of urls# `<<my-domain.com>>/about.html` or `<<my-domain.com>>/about/index.html`## - Type: boolean# - Required: false# - Default: falsedisableUrlNormalization: false
Packaging alternatives
stacktape-image-buildpack
This example shows how to configure packaging using stacktape-image-buildpack.
resources:myWebService:type: web-serviceproperties:# Configures an image used for the service container## - Type: object# - Required: truepackaging:## - Type: string# - Required: truetype: stacktape-image-buildpack# Configures properties for the image automatically built by Stacktape from the source code.## - Type: object# - Required: trueproperties:# Path to the entry point of your compute resource (relative to the stacktape config file)## - Stacktape tries to bundle all your source code with its dependencies into a single file.# - If a certain dependency doesn't support static bundling (because it depends on binary executable, uses dynamic require() calls, etc.),# Stacktape will install it and copy it to the bundle## - Type: string# - Required: trueentryfilePath: ./src/index.ts# Configuration of packaging properties specific to given language## - Type: union (anyOf)# - Required: false# Builds image with support for glibc-based binaries## - You can use this option to add support for glibc-based native dependencies.# - This means that Stacktape will use different (and significantly larger) base-image for your container.# - Stacktape uses alpine Docker images by default. These images use musl, instead of glibc.# - Packages with C-based binaries compiled using glibc doesn't work with musl.## - Type: boolean# - Required: falserequiresGlibcBinaries: true# List of commands to be executed during docker image building.## - This property enables you to execute custom commands in your container during image building.# - Commands are executed using docker `RUN` directive.# - Commands can be used to install required additional dependencies into your container.## - Type: array<string># - Required: falsecustomDockerBuildCommands:- apt-get update && apt-get install -y curl- npm install -g pm2# Files that should be explicitly included in the deployment package (glob pattern)## - Example glob pattern: `images/*.jpg`# - The path is relative to the stacktape configuration file location or to `cwd` if configured using `--currentWorkingDirectory` command line option.## - Type: array<string># - Required: falseincludeFiles:- public/**/*- assets/*.png# Files that should be explicitly excluded from deployment package (glob pattern)## Example glob pattern: `images/*.jpg`## - Type: array<string># - Required: falseexcludeFiles:- *.test.ts- node_modules/**# Dependencies to ignore.## - These dependencies won't be a part of your deployment package.## - Type: array<string># - Required: falseexcludeDependencies:- example-value
external-buildpack
This example shows how to configure packaging using external-buildpack.
resources:myWebService:type: web-serviceproperties:# Configures an image used for the service container## - Type: object# - Required: truepackaging:## - Type: string# - Required: truetype: external-buildpack## - Type: object# - Required: trueproperties:# Path to the directory where the buildpack will be executed## - Type: string# - Required: truesourceDirectoryPath: ./# Buildpack Builder to use## - By default, [paketobuildpacks/builder-jammy-base](https://github.com/paketo-buildpacks/builder-jammy-base) is used.## - Type: string# - Required: false# - Default: paketobuildpacks/builder-jammy-basebuilder: paketobuildpacks/builder-jammy-base# Buildpack to use## - By default, buildpacks is detected automatically.## - Type: array<string># - Required: falsebuildpacks:- example-value# Command to be executed when the container starts.## - Example: `['app.py']`.## - Type: array<string># - Required: falsecommand:- node- dist/index.js
prebuilt-image
This example shows how to configure packaging using prebuilt-image.
resources:myWebService:type: web-serviceproperties:# Configures an image used for the service container## - Type: object# - Required: truepackaging:## - Type: string# - Required: truetype: prebuilt-image# Configures properties for the image pre-built by user.## - Type: object# - Required: trueproperties:# Name or the URL of the image## - Type: string# - Required: trueimage: example-value# ARN (Amazon resource name) of the secret containing credentials for the private registry containing the image.## - You can create a secret with you credentials using [stacktape secret:create](https://docs.stacktape.com/resources/secrets/) command.# - The body of the secret should have the following format: `{"username" : "<<privateRegistryUsername>>", "password" : "<<privateRegistryPassword>>"}`# - After you create the secret, its ARN can be retrieved using [stacktape secret:get](https://docs.stacktape.com/cli/commands/secret-get/) command## - Type: string# - Required: falserepositoryCredentialsSecretArn: example-value# Script to be executed when the container starts. Overrides ENTRYPOINT instruction in the Dockerfile.## - Type: array<string># - Required: falseentryPoint:- /usr/local/bin/docker-entrypoint.sh# Command to be executed when the container starts. Overrides CMD instruction in the Dockerfile.## - Example: `['app.py']`## - Type: array<string># - Required: falsecommand:- node- dist/index.js
custom-dockerfile
This example shows how to configure packaging using custom-dockerfile.
resources:myWebService:type: web-serviceproperties:# Configures an image used for the service container## - Type: object# - Required: truepackaging:## - Type: string# - Required: truetype: custom-dockerfile# Configures properties for the image built by Stacktape using specified Dockerfile.## - Type: object# - Required: trueproperties:# Path to directory (relative to stacktape config file) used as build context## - Type: string# - Required: truebuildContextPath: ./# Script to be executed when the container starts. Overrides ENTRYPOINT instruction in the Dockerfile.## - Type: array<string># - Required: falseentryPoint:- /usr/local/bin/docker-entrypoint.sh# Path to Dockerfile (relative to `buildContextPath`) used to build application image.## - Type: string# - Required: falsedockerfilePath: Dockerfile# List of arguments passed to the `docker build` command when building the image## - Type: array<object (reference)># - Required: falsebuildArgs:- argName: NODE_ENVvalue: production- argName: BUILD_VERSIONvalue: 1.0.0# Command to be executed when the container starts. Overrides CMD instruction in the Dockerfile.## - Example: `['app.py']`## - Type: array<string># - Required: falsecommand:- node- dist/index.js
nixpacks
This example shows how to configure packaging using nixpacks.
resources:myWebService:type: web-serviceproperties:# Configures an image used for the service container## - Type: object# - Required: truepackaging:## - Type: string# - Required: truetype: nixpacks## - Type: object# - Required: trueproperties:# Path to the directory where the buildpack will be executed## - Type: string# - Required: truesourceDirectoryPath: ./# Build Image## - The image to use as the base when building the application.# - To learn more, refer to [nixpacks docs](https://nixpacks.com/docs/configuration/file#build-image)## - Type: string# - Required: falsebuildImage: example-value# Providers## - A list of provider names used to determine build and runtime environments.## - Type: array<string># - Required: falseproviders:- example-value# Start Command## - The command to execute when starting the application.# - Overrides default start commands inferred by nixpacks.## - Type: string# - Required: falsestartCmd: example-value# Start Run Image## - The image to use as the base when running the application.## - Type: string# - Required: falsestartRunImage: example-value# Start Only Include Files## - A list of file paths to include in the runtime environment.# - Other files will be excluded.## - Type: array<string># - Required: falsestartOnlyIncludeFiles:- example-value# Phases## - Defines the build phases for the application.# - Each phase specifies commands, dependencies, and settings.## - Type: array<object (reference)># - Required: falsephases:- name: example-namecmds: ["example-value"]
LogForwarding alternatives
http-endpoint
This example shows how to configure logforwarding using http-endpoint.
resources:myWebService:type: web-serviceproperties:logging:# Configures forwarding of logs to specified destination## - Log forwarding is done using [Amazon Kinesis Data Firehose](https://aws.amazon.com/kinesis/data-firehose/) delivery stream.# - When using log forwarding, you will incur costs based on the amount of data being transferred to the destination (~$0.03 per transferred GB).# Refer to [AWS Kinesis Firehose Pricing](https://aws.amazon.com/kinesis/data-firehose/pricing/?nc=sn&loc=3) page to see details.# - Currently supported destinations for logs:# - `http-endpoint`# - delivers logs to any HTTP endpoint.# - The endpoint must follow [Firehose request and response specifications](https://docs.aws.amazon.com/firehose/latest/dev/httpdeliveryrequestresponse.html).# (Many of the third party vendors are compliant with this specifications out of the box.)# - `datadog`# - delivers logs to [Datadog](https://www.datadoghq.com/).# - `highlight`# - delivers logs to [Highlight.io](https://www.highlight.io/) project.## Refer to [our docs](https://docs.stacktape.com/configuration/log-forwarding/) for more information.## > Logs that fail to be delivered to the destination even after multiple retries (time spend on retries can be configured) are put into bucket with name `{stackName}-{resourceName}-logs-{generatedHash}`## - Type: object# - Required: truelogForwarding:## - Type: string# - Required: truetype: http-endpoint## - Type: object# - Required: trueproperties:# HTTPS endpoint where logs will be forwarded## - Type: string# - Required: trueendpointUrl: https://example.com# Specifies whether to use GZIP compression for the request## - When enabled, Firehose uses the content encoding to compress the body of a request before sending the request to the destination## - Type: boolean# - Required: falsegzipEncodingEnabled: true# Parameters included in each call to HTTP endpoint## - Key/Value pairs containing additional metadata you wish to send to the HTTP endpoint.# - Parameters are delivered within **X-Amz-Firehose-Common-Attributes** header as a JSON object with following format: `{"commonAttributes":{"param1":"val1", "param2":"val2"}}`## - Type: object# - Required: false# Amount of time spend on retries.## - The total amount of time that Kinesis Data Firehose spends on retries.# - This duration starts after the initial attempt to send data to the custom destination via HTTPS endpoint fails.# - Logs that fail to be delivered to the HTTP endpoint even after multiple retries (time spend on retries can be configured) are put into bucket with name `{stackName}-{resourceName}-logs-{generatedHash}`## - Type: number# - Required: falseretryDuration: 100# Access key (credentials), needed for authenticating with endpoint## - Access key is carried within a **X-Amz-Firehose-Access-Key** header# - The configured key is copied verbatim into the value of this header.The contents can be arbitrary and can potentially represent a JWT token or an ACCESS_KEY.# - It is recommended to use [secret](https://docs.stacktape.com/resources/secrets/) for storing your access key.## - Type: string# - Required: falseaccessKey: example-value
highlight
This example shows how to configure logforwarding using highlight.
resources:myWebService:type: web-serviceproperties:logging:# Configures forwarding of logs to specified destination## - Log forwarding is done using [Amazon Kinesis Data Firehose](https://aws.amazon.com/kinesis/data-firehose/) delivery stream.# - When using log forwarding, you will incur costs based on the amount of data being transferred to the destination (~$0.03 per transferred GB).# Refer to [AWS Kinesis Firehose Pricing](https://aws.amazon.com/kinesis/data-firehose/pricing/?nc=sn&loc=3) page to see details.# - Currently supported destinations for logs:# - `http-endpoint`# - delivers logs to any HTTP endpoint.# - The endpoint must follow [Firehose request and response specifications](https://docs.aws.amazon.com/firehose/latest/dev/httpdeliveryrequestresponse.html).# (Many of the third party vendors are compliant with this specifications out of the box.)# - `datadog`# - delivers logs to [Datadog](https://www.datadoghq.com/).# - `highlight`# - delivers logs to [Highlight.io](https://www.highlight.io/) project.## Refer to [our docs](https://docs.stacktape.com/configuration/log-forwarding/) for more information.## > Logs that fail to be delivered to the destination even after multiple retries (time spend on retries can be configured) are put into bucket with name `{stackName}-{resourceName}-logs-{generatedHash}`## - Type: object# - Required: truelogForwarding:## - Type: string# - Required: truetype: highlight## - Type: object# - Required: trueproperties:# Id of a [highlight.io](https://www.highlight.io/) project.## - You can get the id of your project in your [highlight.io console](https://app.highlight.io/).## - Type: string# - Required: trueprojectId: example-value# HTTPS endpoint where logs will be forwarded## - By default Stacktape uses `https://pub.highlight.io/v1/logs/firehose`## - Type: string# - Required: false# - Default: https://pub.highlight.io/v1/logs/firehoseendpointUrl: https://pub.highlight.io/v1/logs/firehose
datadog
This example shows how to configure logforwarding using datadog.
resources:myWebService:type: web-serviceproperties:logging:# Configures forwarding of logs to specified destination## - Log forwarding is done using [Amazon Kinesis Data Firehose](https://aws.amazon.com/kinesis/data-firehose/) delivery stream.# - When using log forwarding, you will incur costs based on the amount of data being transferred to the destination (~$0.03 per transferred GB).# Refer to [AWS Kinesis Firehose Pricing](https://aws.amazon.com/kinesis/data-firehose/pricing/?nc=sn&loc=3) page to see details.# - Currently supported destinations for logs:# - `http-endpoint`# - delivers logs to any HTTP endpoint.# - The endpoint must follow [Firehose request and response specifications](https://docs.aws.amazon.com/firehose/latest/dev/httpdeliveryrequestresponse.html).# (Many of the third party vendors are compliant with this specifications out of the box.)# - `datadog`# - delivers logs to [Datadog](https://www.datadoghq.com/).# - `highlight`# - delivers logs to [Highlight.io](https://www.highlight.io/) project.## Refer to [our docs](https://docs.stacktape.com/configuration/log-forwarding/) for more information.## > Logs that fail to be delivered to the destination even after multiple retries (time spend on retries can be configured) are put into bucket with name `{stackName}-{resourceName}-logs-{generatedHash}`## - Type: object# - Required: truelogForwarding:## - Type: string# - Required: truetype: datadog## - Type: object# - Required: trueproperties:# API key required to enable delivery of logs to Datadog## - You can get your Datadog API key in [Datadog console](https://app.datadoghq.com/organization-settings/api-keys)# - It is recommended to use [secret](https://docs.stacktape.com/resources/secrets/) for storing your api key.## - Type: string# - Required: trueapiKey: example-value# HTTPS endpoint where logs will be forwarded## - By default Stacktape uses `https://aws-kinesis-http-intake.logs.datadoghq.com/v1/input`# - If your Datadog site is in EU you should probably use `https://aws-kinesis-http-intake.logs.datadoghq.eu/v1/input`## - Type: string# - Required: false# - Default: https://aws-kinesis-http-intake.logs.datadoghq.com/v1/inputendpointUrl: https://aws-kinesis-http-intake.logs.datadoghq.com/v1/input