Skip to content

Commit

Permalink
feat: Made it clear that we stand with Ukraine
Browse files Browse the repository at this point in the history
  • Loading branch information
antonbabenko committed Mar 12, 2022
1 parent 72f14fb commit 2d32d84
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 11 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

Terraform module, which creates almost all supported AWS Lambda resources as well as taking care of building and packaging of required Lambda dependencies for functions and layers.

[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)

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:

1. Build and install dependencies - [read more](#build). Requires Python 3.6 or newer.
Expand Down Expand Up @@ -733,6 +735,7 @@ No modules.
| <a name="input_policy_statements"></a> [policy\_statements](#input\_policy\_statements) | Map of dynamic policy statements to attach to Lambda Function role | `any` | `{}` | no |
| <a name="input_provisioned_concurrent_executions"></a> [provisioned\_concurrent\_executions](#input\_provisioned\_concurrent\_executions) | Amount of capacity to allocate. Set to 1 or greater to enable, or set to 0 to disable provisioned concurrency. | `number` | `-1` | no |
| <a name="input_publish"></a> [publish](#input\_publish) | Whether to publish creation/change as new Lambda Function Version. | `bool` | `false` | no |
| <a name="input_putin_khuylo"></a> [putin\_khuylo](#input\_putin\_khuylo) | Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo! | `bool` | `true` | no |
| <a name="input_recreate_missing_package"></a> [recreate\_missing\_package](#input\_recreate\_missing\_package) | Whether to recreate missing Lambda package if it is missing locally or not | `bool` | `true` | no |
| <a name="input_reserved_concurrent_executions"></a> [reserved\_concurrent\_executions](#input\_reserved\_concurrent\_executions) | The amount of reserved concurrent executions for this Lambda Function. A value of 0 disables Lambda Function from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. | `number` | `-1` | no |
| <a name="input_role_description"></a> [role\_description](#input\_role\_description) | Description of IAM role to use for Lambda Function | `string` | `null` | no |
Expand Down Expand Up @@ -800,3 +803,10 @@ Please reach out to [Betajob](https://www.betajob.com/) if you are looking for c
## License

Apache 2 Licensed. See [LICENSE](https://github.com/terraform-aws-modules/terraform-aws-lambda/tree/master/LICENSE) for full details.

## Additional terms of use for users from Russia and Belarus

By using the code provided in this repository you agree with the following:
* Russia has [illegally annexed Crimea in 2014](https://en.wikipedia.org/wiki/Annexation_of_Crimea_by_the_Russian_Federation) and [brought the war in Donbas](https://en.wikipedia.org/wiki/War_in_Donbas) followed by [full-scale invasion of Ukraine in 2022](https://en.wikipedia.org/wiki/2022_Russian_invasion_of_Ukraine).
* Russia has brought sorrow and devastations to millions of Ukrainians, killed hundreds of innocent people, damaged thousands of buildings, and forced several million people to flee.
* [Putin khuylo!](https://en.wikipedia.org/wiki/Putin_khuylo!)
2 changes: 1 addition & 1 deletion iam.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
locals {
create_role = var.create && var.create_function && !var.create_layer && var.create_role
create_role = local.create && var.create_function && !var.create_layer && var.create_role

# Lambda@Edge uses the Cloudwatch region closest to the location where the function is executed
# The region part of the LogGroup ARN is then replaced with a wildcard (*) so Lambda@Edge is able to log in every region
Expand Down
22 changes: 12 additions & 10 deletions main.tf
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
data "aws_partition" "current" {}

locals {
create = var.create && var.putin_khuylo

archive_filename = try(data.external.archive_prepare[0].result.filename, null)
archive_filename_string = local.archive_filename != null ? local.archive_filename : ""
archive_was_missing = try(data.external.archive_prepare[0].result.was_missing, false)
Expand All @@ -18,7 +20,7 @@ locals {
}

resource "aws_lambda_function" "this" {
count = var.create && var.create_function && !var.create_layer ? 1 : 0
count = local.create && var.create_function && !var.create_layer ? 1 : 0

function_name = var.function_name
description = var.description
Expand Down Expand Up @@ -98,7 +100,7 @@ resource "aws_lambda_function" "this" {
}

resource "aws_lambda_layer_version" "this" {
count = var.create && var.create_layer ? 1 : 0
count = local.create && var.create_layer ? 1 : 0

layer_name = var.layer_name
description = var.description
Expand All @@ -119,7 +121,7 @@ resource "aws_lambda_layer_version" "this" {
}

resource "aws_s3_bucket_object" "lambda_package" {
count = var.create && var.store_on_s3 && var.create_package ? 1 : 0
count = local.create && var.store_on_s3 && var.create_package ? 1 : 0

bucket = var.s3_bucket
acl = var.s3_acl
Expand All @@ -135,13 +137,13 @@ resource "aws_s3_bucket_object" "lambda_package" {
}

data "aws_cloudwatch_log_group" "lambda" {
count = var.create && var.create_function && !var.create_layer && var.use_existing_cloudwatch_log_group ? 1 : 0
count = local.create && var.create_function && !var.create_layer && var.use_existing_cloudwatch_log_group ? 1 : 0

name = "/aws/lambda/${var.lambda_at_edge ? "us-east-1." : ""}${var.function_name}"
}

resource "aws_cloudwatch_log_group" "lambda" {
count = var.create && var.create_function && !var.create_layer && !var.use_existing_cloudwatch_log_group ? 1 : 0
count = local.create && var.create_function && !var.create_layer && !var.use_existing_cloudwatch_log_group ? 1 : 0

name = "/aws/lambda/${var.lambda_at_edge ? "us-east-1." : ""}${var.function_name}"
retention_in_days = var.cloudwatch_logs_retention_in_days
Expand All @@ -151,7 +153,7 @@ resource "aws_cloudwatch_log_group" "lambda" {
}

resource "aws_lambda_provisioned_concurrency_config" "current_version" {
count = var.create && var.create_function && !var.create_layer && var.provisioned_concurrent_executions > -1 ? 1 : 0
count = local.create && var.create_function && !var.create_layer && var.provisioned_concurrent_executions > -1 ? 1 : 0

function_name = aws_lambda_function.this[0].function_name
qualifier = aws_lambda_function.this[0].version
Expand All @@ -164,7 +166,7 @@ locals {
}

resource "aws_lambda_function_event_invoke_config" "this" {
for_each = { for k, v in local.qualifiers : k => v if var.create && var.create_function && !var.create_layer && var.create_async_event_config }
for_each = { for k, v in local.qualifiers : k => v if local.create && var.create_function && !var.create_layer && var.create_async_event_config }

function_name = aws_lambda_function.this[0].function_name
qualifier = each.key == "current_version" ? aws_lambda_function.this[0].version : null
Expand Down Expand Up @@ -193,7 +195,7 @@ resource "aws_lambda_function_event_invoke_config" "this" {
}

resource "aws_lambda_permission" "current_version_triggers" {
for_each = { for k, v in var.allowed_triggers : k => v if var.create && var.create_function && !var.create_layer && var.create_current_version_allowed_triggers }
for_each = { for k, v in var.allowed_triggers : k => v if local.create && var.create_function && !var.create_layer && var.create_current_version_allowed_triggers }

function_name = aws_lambda_function.this[0].function_name
qualifier = aws_lambda_function.this[0].version
Expand All @@ -208,7 +210,7 @@ resource "aws_lambda_permission" "current_version_triggers" {

# Error: Error adding new Lambda Permission for lambda: InvalidParameterValueException: We currently do not support adding policies for $LATEST.
resource "aws_lambda_permission" "unqualified_alias_triggers" {
for_each = { for k, v in var.allowed_triggers : k => v if var.create && var.create_function && !var.create_layer && var.create_unqualified_alias_allowed_triggers }
for_each = { for k, v in var.allowed_triggers : k => v if local.create && var.create_function && !var.create_layer && var.create_unqualified_alias_allowed_triggers }

function_name = aws_lambda_function.this[0].function_name

Expand All @@ -221,7 +223,7 @@ resource "aws_lambda_permission" "unqualified_alias_triggers" {
}

resource "aws_lambda_event_source_mapping" "this" {
for_each = { for k, v in var.event_source_mapping : k => v if var.create && var.create_function && !var.create_layer && var.create_unqualified_alias_allowed_triggers }
for_each = { for k, v in var.event_source_mapping : k => v if local.create && var.create_function && !var.create_layer && var.create_unqualified_alias_allowed_triggers }

function_name = aws_lambda_function.this[0].arn

Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ variable "create_role" {
default = true
}

variable "putin_khuylo" {
description = "Do you agree that Putin doesn't respect Ukrainian sovereignty and territorial integrity? More info: https://en.wikipedia.org/wiki/Putin_khuylo!"
type = bool
default = true
}

###########
# Function
###########
Expand Down

0 comments on commit 2d32d84

Please sign in to comment.