Skip to content

Commit

Permalink
Merge pull request #6 from clouddrove/CD-147
Browse files Browse the repository at this point in the history
fix labels managedby variables
  • Loading branch information
anmolnagpal committed Mar 25, 2020
2 parents 19e78a4 + 80c91bf commit 4bfff9d
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 50 deletions.
83 changes: 42 additions & 41 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<hr>


We eat, drink, sleep and most importantly love **DevOps**. We are working towards stratergies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.
We eat, drink, sleep and most importantly love **DevOps**. We are working towards strategies for standardizing architecture while ensuring security for the infrastructure. We are strong believer of the philosophy <b>Bigger problems are always solved by breaking them into smaller manageable problems</b>. Resonating with microservices architecture, it is considered best-practice to run database, cluster, storage in smaller <b>connected yet manageable pieces</b> within the infrastructure.

This module is basically combination of [Terraform open source](https://www.terraform.io/) and includes automatation tests and examples. It also helps to create and improve your infrastructure with minimalistic code instead of maintaining the whole infrastructure code yourself.

Expand Down Expand Up @@ -72,7 +72,7 @@ Here are some examples of how you can use this module in your inventory structur
### Basic Function
```hcl
module "lambda" {
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.2"
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.4"
name = "lambda"
application = "clouddrove"
environment = "test"
Expand All @@ -89,7 +89,7 @@ Here are some examples of how you can use this module in your inventory structur
### Basic S3 Function
```hcl
module "lambda" {
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.2"
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.4"
name = "lambda"
application = "clouddrove"
environment = "test"
Expand All @@ -107,7 +107,7 @@ Here are some examples of how you can use this module in your inventory structur
### Complete Function
```hcl
module "lambda" {
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.2"
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.4"
name = "lambda"
application = "clouddrove"
environment = "test"
Expand Down Expand Up @@ -167,52 +167,53 @@ Here are some examples of how you can use this module in your inventory structur

| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| actions | The AWS Lambda action you want to allow in this statement. (e.g. lambda:InvokeFunction). | list | `<list>` | no |
| application | Application (e.g. `cd` or `clouddrove`). | string | `` | no |
| attributes | Additional attributes (e.g. `1`). | list | `<list>` | no |
| compatible_runtimes | A list of Runtimes this layer is compatible with. Up to 5 runtimes can be specified. | list | `<list>` | no |
| delimiter | Delimiter to be used between `organization`, `environment`, `name` and `attributes`. | string | `-` | no |
| description | Description of what your Lambda Function does. | string | `` | no |
| actions | The AWS Lambda action you want to allow in this statement. \(e.g. lambda:InvokeFunction\). | list | `<list>` | no |
| application | Application \(e.g. `cd` or `clouddrove`\). | string | `""` | no |
| attributes | Additional attributes \(e.g. `1`\). | list | `<list>` | no |
| compatible\_runtimes | A list of Runtimes this layer is compatible with. Up to 5 runtimes can be specified. | list | `<list>` | no |
| delimiter | Delimiter to be used between `organization`, `environment`, `name` and `attributes`. | string | `"-"` | no |
| description | Description of what your Lambda Function does. | string | `""` | no |
| descriptions | Description of what your Lambda Layer does. | list | `<list>` | no |
| enabled | Whether to create lambda function. | bool | `false` | no |
| environment | Environment (e.g. `prod`, `dev`, `staging`). | string | `` | no |
| event_source_tokens | The Event Source Token to validate. Used with Alexa Skills. | list | `<list>` | no |
| filename | The path to the function's deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used. | string | `` | no |
| filenames | The path to the function's deployment package within the local filesystem. If defined, The s3_-prefixed options cannot be used. | list | `<list>` | no |
| handler | The function entrypoint in your code. | string | - | yes |
| iam_actions | The actions for Iam Role Policy. | list | `<list>` | no |
| kms_key_arn | The ARN for the KMS encryption key. | string | `` | no |
| label_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
| layers | List of Lambda Layer Version ARNs (maximum of 5) to attach to your Lambda Function. | string | `` | no |
| license_infos | License info for your Lambda Layer. See License Info. | list | `<list>` | no |
| memory_size | Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. | number | `128` | no |
| name | Name (e.g. `app` or `cluster`). | string | `` | no |
| enabled | Whether to create lambda function. | bool | `"false"` | no |
| environment | Environment \(e.g. `prod`, `dev`, `staging`\). | string | `""` | no |
| event\_source\_tokens | The Event Source Token to validate. Used with Alexa Skills. | list | `<list>` | no |
| filename | The path to the function's deployment package within the local filesystem. If defined, The s3\_-prefixed options cannot be used. | string | `""` | no |
| filenames | The path to the function's deployment package within the local filesystem. If defined, The s3\_-prefixed options cannot be used. | list | `<list>` | no |
| handler | The function entrypoint in your code. | string | n/a | yes |
| iam\_actions | The actions for Iam Role Policy. | list | `<list>` | no |
| kms\_key\_arn | The ARN for the KMS encryption key. | string | `""` | no |
| label\_order | Label order, e.g. `name`,`application`. | list | `<list>` | no |
| layers | List of Lambda Layer Version ARNs \(maximum of 5\) to attach to your Lambda Function. | string | `""` | no |
| license\_infos | License info for your Lambda Layer. See License Info. | list | `<list>` | no |
| managedby | ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'. | string | `"anmol@clouddrove.com"` | no |
| memory\_size | Amount of memory in MB your Lambda Function can use at runtime. Defaults to 128. | number | `"128"` | no |
| name | Name \(e.g. `app` or `cluster`\). | string | `""` | no |
| names | A unique name for your Lambda Layer. | list | `<list>` | no |
| principals | The principal who is getting this permission. e.g. s3.amazonaws.com, an AWS account ID, or any valid AWS service principal such as events.amazonaws.com or sns.amazonaws.com. | list | `<list>` | no |
| publish | Whether to publish creation/change as new Lambda Function Version. Defaults to false. | bool | `false` | no |
| publish | Whether to publish creation/change as new Lambda Function Version. Defaults to false. | bool | `"false"` | no |
| qualifiers | Query parameter to specify function version or alias name. The permission will then apply to the specific qualified ARN. e.g. arn:aws:lambda:aws-region:acct-id:function:function-name:2 | list | `<list>` | no |
| reserved_concurrent_executions | The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. | number | `-1` | no |
| runtime | Runtimes. | string | - | yes |
| s3_bucket | The S3 bucket location containing the function's deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function. | string | `` | no |
| s3_buckets | The S3 bucket location containing the function's deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function. | list | `<list>` | no |
| s3_keies | The S3 key of an object containing the function's deployment package. Conflicts with filename. | list | `<list>` | no |
| s3_key | The S3 key of an object containing the function's deployment package. Conflicts with filename. | string | `` | no |
| s3_object_version | The object version containing the function's deployment package. Conflicts with filename. | string | `` | no |
| s3_object_versions | The object version containing the function's deployment package. Conflicts with filename. | list | `<list>` | no |
| security_group_ids | Security group ids for vpc config. | list | `<list>` | no |
| source_accounts | This parameter is used for S3 and SES. The AWS account ID (without a hyphen) of the source owner. | list | `<list>` | no |
| source_arns | When granting Amazon S3 or CloudWatch Events permission to invoke your function, you should specify this field with the Amazon Resource Name (ARN) for the S3 Bucket or CloudWatch Events Rule as its value. This ensures that only events generated from the specified bucket or rule can invoke the function. | list | `<list>` | no |
| statement_ids | A unique statement identifier. By default generated by Terraform. | list | `<list>` | no |
| subnet_ids | Subnet ids for vpc config. | list | `<list>` | no |
| tags | Additional tags (e.g. map(`BusinessUnit`,`XYZ`). | map | `<map>` | no |
| timeout | The amount of time your Lambda Function has to run in seconds. Defaults to 3. | number | `3` | no |
| reserved\_concurrent\_executions | The amount of reserved concurrent executions for this lambda function. A value of 0 disables lambda from being triggered and -1 removes any concurrency limitations. Defaults to Unreserved Concurrency Limits -1. | number | `"-1"` | no |
| runtime | Runtimes. | string | n/a | yes |
| s3\_bucket | The S3 bucket location containing the function's deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function. | string | `""` | no |
| s3\_buckets | The S3 bucket location containing the function's deployment package. Conflicts with filename. This bucket must reside in the same AWS region where you are creating the Lambda function. | list | `<list>` | no |
| s3\_keies | The S3 key of an object containing the function's deployment package. Conflicts with filename. | list | `<list>` | no |
| s3\_key | The S3 key of an object containing the function's deployment package. Conflicts with filename. | string | `""` | no |
| s3\_object\_version | The object version containing the function's deployment package. Conflicts with filename. | string | `""` | no |
| s3\_object\_versions | The object version containing the function's deployment package. Conflicts with filename. | list | `<list>` | no |
| security\_group\_ids | Security group ids for vpc config. | list | `<list>` | no |
| source\_accounts | This parameter is used for S3 and SES. The AWS account ID \(without a hyphen\) of the source owner. | list | `<list>` | no |
| source\_arns | When granting Amazon S3 or CloudWatch Events permission to invoke your function, you should specify this field with the Amazon Resource Name \(ARN\) for the S3 Bucket or CloudWatch Events Rule as its value. This ensures that only events generated from the specified bucket or rule can invoke the function. | list | `<list>` | no |
| statement\_ids | A unique statement identifier. By default generated by Terraform. | list | `<list>` | no |
| subnet\_ids | Subnet ids for vpc config. | list | `<list>` | no |
| tags | Additional tags \(e.g. map\(`BusinessUnit`,`XYZ`\). | map | `<map>` | no |
| timeout | The amount of time your Lambda Function has to run in seconds. Defaults to 3. | number | `"3"` | no |
| variables | A map that defines environment variables for the Lambda function. | map | `<map>` | no |

## Outputs

| Name | Description |
|------|-------------|
| arn | The Amazon Resource Name (ARN) identifying your Lambda Function. |
| arn | The Amazon Resource Name \(ARN\) identifying your Lambda Function. |
| tags | A mapping of tags to assign to the resource. |


Expand Down Expand Up @@ -246,4 +247,4 @@ At [CloudDrove][website], we offer expert guidance, implementation support and s
[linkedin]: https://cpco.io/linkedin
[twitter]: https://twitter.com/clouddrove/
[email]: https://clouddrove.com/contact-us.html
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=
[terraform_modules]: https://github.com/clouddrove?utf8=%E2%9C%93&q=terraform-&type=&language=
6 changes: 3 additions & 3 deletions README.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ usage : |-
### Basic Function
```hcl
module "lambda" {
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.2"
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.4"
name = "lambda"
application = "clouddrove"
environment = "test"
Expand All @@ -54,7 +54,7 @@ usage : |-
### Basic S3 Function
```hcl
module "lambda" {
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.2"
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.4"
name = "lambda"
application = "clouddrove"
environment = "test"
Expand All @@ -72,7 +72,7 @@ usage : |-
### Complete Function
```hcl
module "lambda" {
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.2"
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.4"
name = "lambda"
application = "clouddrove"
environment = "test"
Expand Down
2 changes: 1 addition & 1 deletion _example/basic-function/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ provider "aws" {
}

module "lambda" {
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.2"
source = "../../"

name = "lambda"
application = "clouddrove"
Expand Down
2 changes: 1 addition & 1 deletion _example/basic-s3-function/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ provider "aws" {
}

module "lambda" {
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.2"
source = "../../"

name = "lambda"
application = "clouddrove"
Expand Down
2 changes: 1 addition & 1 deletion _example/complete-function/example.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ provider "aws" {
}

module "lambda" {
source = "git::https://github.com/clouddrove/terraform-aws-lambda.git?ref=tags/0.12.2"
source = "../../"

name = "lambda"
application = "clouddrove"
Expand Down
7 changes: 4 additions & 3 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module "labels" {
name = var.name
application = var.application
environment = var.environment
managedby = var.managedby
label_order = var.label_order
}

Expand Down Expand Up @@ -67,7 +68,7 @@ resource "aws_iam_role_policy_attachment" "default" {
# Module : Archive file
# Description : Terraform module to zip a directory.
data "archive_file" "lambda_zip" {
count = length(var.filenames) > 0 ? length(var.filenames) : 0
count = var.enabled && length(var.filenames) > 0 ? length(var.filenames) : 0
type = "zip"
source_dir = element(var.filenames, count.index)["input"]
output_path = element(var.filenames, count.index)["output"]
Expand All @@ -76,7 +77,7 @@ data "archive_file" "lambda_zip" {
# Module : Lambda layers
# Description : Terraform module to create Lambda layers resource on AWS.
resource "aws_lambda_layer_version" "default" {
count = length(var.names) > 0 ? length(var.names) : 0
count = length(var.names) > 0 && var.enabled ? length(var.names) : 0
filename = length(var.filenames) > 0 ? element(var.filenames, count.index)["output"] : null
s3_bucket = length(var.s3_buckets) > 0 ? element(var.s3_buckets, count.index) : null
s3_key = length(var.s3_keies) > 0 ? element(var.s3_keies, count.index) : null
Expand All @@ -91,7 +92,7 @@ resource "aws_lambda_layer_version" "default" {
# Module : Archive file
# Description : Terraform module to zip a directory.
data "archive_file" "default" {
count = var.filename != null ? 1 : 0
count = var.enabled && var.filename != null ? 1 : 0
type = "zip"
source_dir = var.filename
output_path = format("%s.zip", module.labels.id)
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ variable "tags" {
description = "Additional tags (e.g. map(`BusinessUnit`,`XYZ`)."
}

variable "managedby" {
type = string
default = "anmol@clouddrove.com"
description = "ManagedBy, eg 'CloudDrove' or 'AnmolNagpal'."
}

# Module : Lambda function
# Description : Terraform Lambda function module variables.
variable "enabled" {
Expand Down

0 comments on commit 4bfff9d

Please sign in to comment.