Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions modules/alias/README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# AWS Lambda Alias

Terraform module, which creates Lambda alias as well as takes care of async event configuration and Lambda permissions for alias.
Terraform module, which creates a Lambda alias as well as takes care of async event configuration and Lambda permissions for the alias.

Lambda Alias is required to do complex Lambda deployments, eg. using external tools like AWS CodeDeploy.
Lambda Alias is required to do complex Lambda deployments, e.g., using external tools like AWS CodeDeploy.

This Terraform module is the part of [serverless.tf framework](https://github.com/antonbabenko/serverless.tf), which aims to simplify all operations when working with the serverless in Terraform.
This Terraform module is part of [serverless.tf framework](https://github.com/antonbabenko/serverless.tf), which aims to simplify all operations when working with serverless in Terraform.


## Usage

### Lambda Function and statically configured alias with the version of Lambda Function
### Lambda Function and statically configured alias with the version of the Lambda Function

```hcl
module "lambda_function" {
Expand Down Expand Up @@ -43,7 +43,7 @@ module "alias_no_refresh" {

### Lambda Alias (auto-refreshing when version changed externally)

This is useful when doing complex deployments using external tool.
This is useful when doing complex deployments using an external tool.

```hcl
module "alias_refresh" {
Expand All @@ -56,7 +56,7 @@ module "alias_refresh" {

### Lambda Alias (using existing alias)

This is useful when extra configuration on existing Lambda alias is required.
This is useful when extra configuration on the existing Lambda alias is required.

```hcl
module "alias_refresh" {
Expand Down Expand Up @@ -86,7 +86,7 @@ module "alias_existing" {

## Conditional creation

Sometimes you need to have a way to create resources conditionally but Terraform does not allow usage of `count` inside `module` block, so the solution is to specify `create` arguments.
Sometimes you need to have a way to create resources conditionally, but Terraform does not allow the usage of `count` inside `module` block, so the solution is to specify `create` arguments.

```hcl
module "lambda" {
Expand Down Expand Up @@ -155,7 +155,7 @@ No modules.
| <a name="input_destination_on_failure"></a> [destination\_on\_failure](#input\_destination\_on\_failure) | Amazon Resource Name (ARN) of the destination resource for failed asynchronous invocations | `string` | `null` | no |
| <a name="input_destination_on_success"></a> [destination\_on\_success](#input\_destination\_on\_success) | Amazon Resource Name (ARN) of the destination resource for successful asynchronous invocations | `string` | `null` | no |
| <a name="input_event_source_mapping"></a> [event\_source\_mapping](#input\_event\_source\_mapping) | Map of event source mapping | `any` | `{}` | no |
| <a name="input_function_name"></a> [function\_name](#input\_function\_name) | The function ARN of the Lambda function for which you want to create an alias. | `string` | `""` | no |
| <a name="input_function_name"></a> [function\_name](#input\_function\_name) | Name or ARN of the Lambda function for which you want to create an alias. | `string` | n/a | yes |
| <a name="input_function_version"></a> [function\_version](#input\_function\_version) | Lambda function version for which you are creating the alias. Pattern: ($LATEST\|[0-9]+). | `string` | `""` | no |
| <a name="input_maximum_event_age_in_seconds"></a> [maximum\_event\_age\_in\_seconds](#input\_maximum\_event\_age\_in\_seconds) | Maximum age of a request that Lambda sends to a function for processing in seconds. Valid values between 60 and 21600. | `number` | `null` | no |
| <a name="input_maximum_retry_attempts"></a> [maximum\_retry\_attempts](#input\_maximum\_retry\_attempts) | Maximum number of times to retry when the function returns an error. Valid values between 0 and 2. Defaults to 2. | `number` | `null` | no |
Expand Down
3 changes: 1 addition & 2 deletions modules/alias/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,8 @@ variable "description" {
}

variable "function_name" {
description = "The function ARN of the Lambda function for which you want to create an alias."
description = "Name or ARN of the Lambda function for which you want to create an alias."
type = string
default = ""
}

variable "function_version" {
Expand Down
2 changes: 1 addition & 1 deletion wrappers/alias/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module "wrapper" {
destination_on_failure = try(each.value.destination_on_failure, var.defaults.destination_on_failure, null)
destination_on_success = try(each.value.destination_on_success, var.defaults.destination_on_success, null)
event_source_mapping = try(each.value.event_source_mapping, var.defaults.event_source_mapping, {})
function_name = try(each.value.function_name, var.defaults.function_name, "")
function_name = try(each.value.function_name, var.defaults.function_name)
function_version = try(each.value.function_version, var.defaults.function_version, "")
maximum_event_age_in_seconds = try(each.value.maximum_event_age_in_seconds, var.defaults.maximum_event_age_in_seconds, null)
maximum_retry_attempts = try(each.value.maximum_retry_attempts, var.defaults.maximum_retry_attempts, null)
Expand Down