An open API service indexing awesome lists of open source software.

https://github.com/jameswoolfenden/terraform-aws-lex-lambda

When working with lex and lambdas, we had a lot of resources associated to supporting one lambda, this just uses some sensible defaults to lighten the load.
https://github.com/jameswoolfenden/terraform-aws-lex-lambda

aws cloudwatch lambda lex metrics module terraform

Last synced: about 1 year ago
JSON representation

When working with lex and lambdas, we had a lot of resources associated to supporting one lambda, this just uses some sensible defaults to lighten the load.

Awesome Lists containing this project

README

          

# terraform-aws-lex-lambda

terraform-aws-lex-lambda

[![Build Status](https://github.com/JamesWoolfenden/terraform-aws-lex-lambda/workflows/Verify%20and%20Bump/badge.svg?branch=master)](https://github.com/JamesWoolfenden/terraform-aws-lex-lambda)
[![Latest Release](https://img.shields.io/github/release/JamesWoolfenden/terraform-aws-lex-lambda.svg)](https://github.com/JamesWoolfenden/terraform-aws-lex-lambda/releases/latest)
[![GitHub tag (latest SemVer)](https://img.shields.io/github/tag/JamesWoolfenden/terraform-aws-lex-lambda.svg?label=latest)](https://github.com/JamesWoolfenden/terraform-aws-lex-lambda/releases/latest)
![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.14.0-blue.svg)
[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/JamesWoolfenden/terraform-aws-lex-lambda/cis_aws)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=JamesWoolfenden%2Fterraform-aws-lex-lambda&benchmark=CIS+AWS+V1.2)
[![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)](https://github.com/pre-commit/pre-commit)
[![checkov](https://img.shields.io/badge/checkov-verified-brightgreen)](https://www.checkov.io/)
[![Infrastructure Tests](https://www.bridgecrew.cloud/badges/github/jameswoolfenden/terraform-aws-lex-lambda/general)](https://www.bridgecrew.cloud/link/badge?vcs=github&fullRepo=JamesWoolfenden%2Fterraform-aws-lex-lambda&benchmark=INFRASTRUCTURE+SECURITY)

The terraform module creates lambda with permissions, for my purposes a lex lambda combination bit options for IAM and CLoudwatch.
To use a lambda with an intent a number of other objects are either required. In this module I have included a number of reasonable default values.
This should make it easier to build the lambdas that go with your lex objects.
The Lamda permission is a array/list this means you can add as many permissions to lambda as you need to.

How to use this project:

---

It's 100% Open Source and licensed under the [APACHE2](LICENSE).

## Usage

This is a minimal example **Examplea**, but with Cloudwatch alarms enabled.

```terraform
module lexlambda {
source = "github.com/jameswoolfenden/terraform-aws-lex-lambda"
version= "0.3.40"

lambdapermmissions = [{
intent = "Pizza"
source_arn = "Pizza:*"
}]

account_id = data.aws_caller_identity.current.account_id
alarms_enabled = true
common_tags = var.common_tags
description = "Best Pizza!!"
filename = "${path.module}/lambda.zip"
name = var.name
region_name = data.aws_region.current.name
role_arn = data.aws_iam_role.lambda.arn
}
```

## Requirements

No requirements.

## Providers

| Name | Version |
|------|---------|
| [aws](#provider\_aws) | n/a |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_cloudwatch_log_group.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_log_group) | resource |
| [aws_cloudwatch_metric_alarm.invocations](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/cloudwatch_metric_alarm) | resource |
| [aws_lambda_function.withintent](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_permission.withintent](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_permission) | resource |
| [aws_sns_topic.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sns_topic) | resource |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy_document.sns](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |

## Inputs

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| [account\_id](#input\_account\_id) | The Aws account the policy or object should target | `string` | n/a | yes |
| [action](#input\_action) | Action for the Lambda permission | `string` | `"lambda:InvokeFunction"` | no |
| [alarms\_enabled](#input\_alarms\_enabled) | Cloudwatch alarms enabled | `bool` | `false` | no |
| [common\_tags](#input\_common\_tags) | Implements the common tags scheme | `map(any)` | n/a | yes |
| [description](#input\_description) | Of the the Lambda | `string` | n/a | yes |
| [envvar](#input\_envvar) | Optional set of environmental variables for the lambda | `map(any)` |

{
"Terraform": "Bug"
}
| no |
| [filename](#input\_filename) | name of zip file if any | `string` | `null` | no |
| [handler](#input\_handler) | The file the lambda should import | `string` | `"index.handler"` | no |
| [kms\_key\_id](#input\_kms\_key\_id) | ARN of CMK for Lambda,SNS | `string` | n/a | yes |
| [kms\_master\_key\_id](#input\_kms\_master\_key\_id) | ID of CMK for Lambda,SNS | `string` | n/a | yes |
| [lambdapermmissions](#input\_lambdapermmissions) | This takes a list object with values to set permissions of a lambda. Can take multiple permission objects | `list(any)` | `[]` | no |
| [layers](#input\_layers) | Optionally, add in up 5 lambda layers | `list(any)` | `[]` | no |
| [memory\_size](#input\_memory\_size) | Of the the lambda | `string` | `"128"` | no |
| [metric\_comparison\_operator](#input\_metric\_comparison\_operator) | For Cloudwatch Alarms | `string` | `"GreaterThanThreshold"` | no |
| [metric\_datapoints\_to\_alarm](#input\_metric\_datapoints\_to\_alarm) | For Cloudwatch Alarms | `number` | `1` | no |
| [metric\_evaluation\_periods](#input\_metric\_evaluation\_periods) | For Cloudwatch Alarms | `number` | `1` | no |
| [metric\_metric\_name](#input\_metric\_metric\_name) | n/a | `string` | `"Invocations"` | no |
| [metric\_period](#input\_metric\_period) | n/a | `number` | `300` | no |
| [metric\_statistic](#input\_metric\_statistic) | n/a | `string` | `"Average"` | no |
| [metric\_threshold](#input\_metric\_threshold) | n/a | `number` | `100` | no |
| [name](#input\_name) | Name of Lambda object | `string` | n/a | yes |
| [prefixdash](#input\_prefixdash) | Support for renaming on multi-environments | `string` | `""` | no |
| [principal](#input\_principal) | n/a | `string` | `"lex.amazonaws.com"` | no |
| [region\_name](#input\_region\_name) | Aws region name, eu-west-1... | `string` | n/a | yes |
| [role\_arn](#input\_role\_arn) | The name you want your IAM role to have | `string` | n/a | yes |
| [runtime](#input\_runtime) | Language the code runs in | `string` | `"nodejs8.10"` | no |
| [s3\_bucket](#input\_s3\_bucket) | path to the lambda bucket | `string` | `null` | no |
| [s3\_key](#input\_s3\_key) | path to the lambda zip | `string` | `null` | no |
| [security\_group\_ids](#input\_security\_group\_ids) | The IDs of some security groups | `list(string)` | `[]` | no |
| [subnet\_ids](#input\_subnet\_ids) | Subnet IDs... | `list(string)` | `[]` | no |
| [timeout](#input\_timeout) | Of the the lambda | `string` | `"100"` | no |
| [tracing\_config](#input\_tracing\_config) | Sets the x-ray tracing mode | `string` | `"Active"` | no |
| [vpc\_config](#input\_vpc\_config) | Optional Vpc attachment config | `map(any)` | `{}` | no |

## Outputs

| Name | Description |
|------|-------------|
| [lambda](#output\_lambda) | n/a |
| [lambda\_arn](#output\_lambda\_arn) | n/a |
| [memory\_size](#output\_memory\_size) | n/a |
| [source\_code\_size](#output\_source\_code\_size) | n/a |
| [timeout](#output\_timeout) | n/a |

## Policy

This is the policy required to build this project:

The Terraform resource required is:

```golang
resource "aws_iam_policy" "terraform_pike" {
name_prefix = "terraform_pike"
path = "/"
description = "Pike Autogenerated policy from IAC"

policy = jsonencode({
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": [
"SNS:CreateTopic",
"SNS:DeleteTopic",
"SNS:GetTopicAttributes",
"SNS:ListTagsForResource",
"SNS:SetTopicAttributes",
"SNS:TagResource",
"SNS:UnTagResource"
],
"Resource": "*"
},
{
"Sid": "VisualEditor1",
"Effect": "Allow",
"Action": [
"cloudwatch:DeleteAlarms",
"cloudwatch:DescribeAlarms",
"cloudwatch:ListTagsForResource",
"cloudwatch:PutMetricAlarm"
],
"Resource": "*"
},
{
"Sid": "VisualEditor2",
"Effect": "Allow",
"Action": [
"ec2:DescribeAccountAttributes"
],
"Resource": "*"
},
{
"Sid": "VisualEditor3",
"Effect": "Allow",
"Action": [
"iam:PassRole"
],
"Resource": "*"
},
{
"Sid": "VisualEditor4",
"Effect": "Allow",
"Action": [
"lambda:AddPermission",
"lambda:CreateFunction",
"lambda:DeleteFunction",
"lambda:GetFunction",
"lambda:GetFunctionCodeSigningConfig",
"lambda:GetPolicy",
"lambda:ListVersionsByFunction",
"lambda:RemovePermission",
"lambda:TagResource",
"lambda:UntagResource"
],
"Resource": "*"
},
{
"Sid": "VisualEditor5",
"Effect": "Allow",
"Action": [
"logs:AssociateKmsKey",
"logs:CreateLogGroup",
"logs:DeleteLogGroup",
"logs:DeleteRetentionPolicy",
"logs:DescribeLogGroups",
"logs:DisassociateKmsKey",
"logs:ListTagsLogGroup",
"logs:PutRetentionPolicy"
],
"Resource": "*"
}
]
})
}

```

## Related Projects

Check out these related projects.

- [terraform-aws-codecommit](https://github.com/jameswoolfenden/terraform-aws-codebuild) - Storing ones code

## Help

**Got a question?**

File a GitHub [issue](https://github.com/JamesWoolfenden/terraform-aws-lex-lambda/issues).

## Contributing

### Bug Reports & Feature Requests

Please use the [issue tracker](https://github.com/JamesWoolfenden/terraform-aws-lex-lambda/issues) to report any bugs or file feature requests.

## Copyrights

Copyright © 2019-2022 James Woolfenden

## License

[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)

See [LICENSE](LICENSE) for full details.

Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.

### Contributors

[![James Woolfenden][jameswoolfenden_avatar]][jameswoolfenden_homepage]
[James Woolfenden][jameswoolfenden_homepage] |

[jameswoolfenden_homepage]: https://github.com/jameswoolfenden
[jameswoolfenden_avatar]: https://github.com/jameswoolfenden.png?size=150