Skip to content

Commit

Permalink
feat: Add snap_start functionality (#406)
Browse files Browse the repository at this point in the history
  • Loading branch information
darrenswhite committed Jan 30, 2023
1 parent a802b6d commit 91c811b
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 4 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo
| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.13.1 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.9 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.44 |
| <a name="requirement_external"></a> [external](#requirement\_external) | >= 1.0 |
| <a name="requirement_local"></a> [local](#requirement\_local) | >= 1.0 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 2.0 |
Expand All @@ -668,7 +668,7 @@ Q4: What does this error mean - `"We currently do not support adding policies fo

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.9 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 4.44 |
| <a name="provider_external"></a> [external](#provider\_external) | >= 1.0 |
| <a name="provider_local"></a> [local](#provider\_local) | >= 1.0 |
| <a name="provider_null"></a> [null](#provider\_null) | >= 2.0 |
Expand Down Expand Up @@ -832,6 +832,7 @@ No modules.
| <a name="input_s3_object_tags_only"></a> [s3\_object\_tags\_only](#input\_s3\_object\_tags\_only) | Set to true to not merge tags with s3\_object\_tags. Useful to avoid breaching S3 Object 10 tag limit. | `bool` | `false` | no |
| <a name="input_s3_prefix"></a> [s3\_prefix](#input\_s3\_prefix) | Directory name where artifacts should be stored in the S3 bucket. If unset, the path from `artifacts_dir` is used | `string` | `null` | no |
| <a name="input_s3_server_side_encryption"></a> [s3\_server\_side\_encryption](#input\_s3\_server\_side\_encryption) | Specifies server-side encryption of the object in S3. Valid values are "AES256" and "aws:kms". | `string` | `null` | no |
| <a name="input_snap_start"></a> [snap\_start](#input\_snap\_start) | (Optional) Snap start settings for low-latency startups | `bool` | `false` | no |
| <a name="input_source_path"></a> [source\_path](#input\_source\_path) | The absolute path to a local file or directory containing your Lambda source code | `any` | `null` | no |
| <a name="input_store_on_s3"></a> [store\_on\_s3](#input\_store\_on\_s3) | Whether to store produced artifacts on S3 or locally. | `bool` | `false` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to resources. | `map(string)` | `{}` | no |
Expand Down
2 changes: 2 additions & 0 deletions examples/simple/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ module "lambda_function" {
# create_package = false
# local_existing_package = data.null_data_source.downloaded_package.outputs["filename"]

# snap_start = true

# policy_json = <<EOF
#{
# "Version": "2012-10-17",
Expand Down
10 changes: 9 additions & 1 deletion main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ resource "aws_lambda_function" "this" {
runtime = var.package_type != "Zip" ? null : var.runtime
layers = var.layers
timeout = var.lambda_at_edge ? min(var.timeout, 30) : var.timeout
publish = var.lambda_at_edge ? true : var.publish
publish = (var.lambda_at_edge || var.snap_start) ? true : var.publish
kms_key_arn = var.kms_key_arn
image_uri = var.image_uri
package_type = var.package_type
Expand Down Expand Up @@ -102,6 +102,14 @@ resource "aws_lambda_function" "this" {
}
}

dynamic "snap_start" {
for_each = var.snap_start ? [true] : []

content {
apply_on = "PublishedVersions"
}
}

tags = var.tags

depends_on = [
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,12 @@ variable "image_config_working_directory" {
default = null
}

variable "snap_start" {
description = "(Optional) Snap start settings for low-latency startups"
type = bool
default = false
}

###############
# Function URL
###############
Expand Down
2 changes: 1 addition & 1 deletion versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.9"
version = ">= 4.44"
}
external = {
source = "hashicorp/external"
Expand Down

0 comments on commit 91c811b

Please sign in to comment.