Skip to content

Commit

Permalink
Add initial files and examples (#2)
Browse files Browse the repository at this point in the history
* Add initial code, docs and example

---------

Co-authored-by: sfloresk <sfkanter@amazon.com>
  • Loading branch information
sfloresk and sfloresk authored Jul 9, 2024
1 parent 2a28e1d commit 39c0b08
Show file tree
Hide file tree
Showing 16 changed files with 796 additions and 43 deletions.
9 changes: 9 additions & 0 deletions .config/.tflint.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,12 @@ rule "terraform_standard_module_structure" {
rule "terraform_workspace_remote" {
enabled = true
}


## Custom rules

# Disabling rule for invalid runtime since is flagging nodejs20.x as invalid, but it is a valid runtime
# https://docs.aws.amazon.com/lambda/latest/api/API_CreateFunction.html#API_CreateFunction_RequestSyntax
rule "aws_lambda_function_invalid_runtime"{
enabled = false
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,7 @@ go.mod
go.sum

# Terraform tests
tests/*.auto.tfvars
tests/*.auto.tfvars
.env
examples/basic/.terraform
examples/basic/src/
8 changes: 2 additions & 6 deletions .header.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
# Terraform Module Project
# AWS Lambda Power Tuning Terraform module

:no_entry_sign: Do not edit this readme.md file. To learn how to change this content and work with this repository, refer to CONTRIBUTING.md

## Readme Content

This file will contain any instructional information about this module.
Terraform module to automate the deployment of the [Lambda power tuning solution](https://github.com/alexcasalboni/aws-lambda-power-tuning)
79 changes: 68 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,88 @@
<!-- BEGIN_TF_DOCS -->
# Terraform Module Project
# AWS Lambda Power Tuning Terraform module

:no_entry_sign: Do not edit this readme.md file. To learn how to change this content and work with this repository, refer to CONTRIBUTING.md

## Readme Content

This file will contain any instructional information about this module.
Terraform module to automate the deployment of the [Lambda power tuning solution](https://github.com/alexcasalboni/aws-lambda-power-tuning)

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_archive"></a> [archive](#requirement\_archive) | >= 2.4.2 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.26 |
| <a name="requirement_null"></a> [null](#requirement\_null) | >= 3.2.2 |

## Providers

No providers.
| Name | Version |
|------|---------|
| <a name="provider_archive"></a> [archive](#provider\_archive) | >= 2.4.2 |
| <a name="provider_aws"></a> [aws](#provider\_aws) | >= 5.26 |
| <a name="provider_terraform"></a> [terraform](#provider\_terraform) | n/a |

## Modules

No modules.

## Resources

No resources.
| Name | Type |
|------|------|
| [aws_iam_policy.cleaner_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_policy.executor_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_policy.initializer_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_policy.optimizer_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |
| [aws_iam_policy_attachment.cleaner_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy_attachment) | resource |
| [aws_iam_policy_attachment.execute_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy_attachment) | resource |
| [aws_iam_policy_attachment.executor_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy_attachment) | resource |
| [aws_iam_policy_attachment.initializer_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy_attachment) | resource |
| [aws_iam_policy_attachment.optimizer_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy_attachment) | resource |
| [aws_iam_policy_attachment.sfn_attach](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy_attachment) | resource |
| [aws_iam_role.analyzer_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role.cleaner_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role.executor_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role.initializer_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role.optimizer_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_iam_role.sfn_role](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |
| [aws_lambda_function.analyzer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_function.cleaner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_function.executor](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_function.initializer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_function.optimizer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_function) | resource |
| [aws_lambda_layer_version.lambda_layer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/lambda_layer_version) | resource |
| [aws_sfn_state_machine.state_machine](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/sfn_state_machine) | resource |
| [terraform_data.always_replace](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [terraform_data.build_layer](https://registry.terraform.io/providers/hashicorp/terraform/latest/docs/resources/data) | resource |
| [archive_file.app](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |
| [archive_file.layer](https://registry.terraform.io/providers/hashicorp/archive/latest/docs/data-sources/file) | data source |
| [aws_caller_identity.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/caller_identity) | data source |
| [aws_iam_policy.analyzer_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |
| [aws_iam_policy.sfn_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy) | data source |
| [aws_iam_policy_document.cleaner](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.executor](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.initializer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.lambda](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.optimizer](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |
| [aws_iam_policy_document.sfn](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |

## Inputs

No inputs.
| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_lambda_function_prefix"></a> [lambda\_function\_prefix](#input\_lambda\_function\_prefix) | Prefix used for the names of Lambda functions, Step Functions state machines, IAM roles, and IAM policies. | `string` | `"lambda_power_tuning"` | no |
| <a name="input_permissions_boundary"></a> [permissions\_boundary](#input\_permissions\_boundary) | ARN of the policy that is used to set the permissions boundary for the role. | `string` | `null` | no |
| <a name="input_role_path_override"></a> [role\_path\_override](#input\_role\_path\_override) | IAM Role path to use for each Lambda function's role, instead of the default path /lambda\_power\_tuning/ (see variable lambda\_function\_prefix). | `string` | `""` | no |
| <a name="input_tags"></a> [tags](#input\_tags) | A map of tags to assign to the resources. | `map(string)` | <pre>{<br> "app": "lambda_power_tuning"<br>}</pre> | no |
| <a name="input_vpc_security_group_ids"></a> [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | List of security group ids when Lambda Function should run in the VPC. | `list(string)` | `null` | no |
| <a name="input_vpc_subnet_ids"></a> [vpc\_subnet\_ids](#input\_vpc\_subnet\_ids) | List of subnet ids when Lambda Function should run in the VPC. Usually private or intra subnets. | `list(string)` | `null` | no |

## Outputs

No outputs.
<!-- END_TF_DOCS -->
| Name | Description |
|------|-------------|
| <a name="output_analyzer_function"></a> [analyzer\_function](#output\_analyzer\_function) | Analyzer lambda function ARN |
| <a name="output_cleaner_function"></a> [cleaner\_function](#output\_cleaner\_function) | Cleaner lambda function ARN |
| <a name="output_executor_function"></a> [executor\_function](#output\_executor\_function) | Executor lambda function ARN |
| <a name="output_initializer_function"></a> [initializer\_function](#output\_initializer\_function) | Initializer lambda function ARN |
| <a name="output_optimizer_function"></a> [optimizer\_function](#output\_optimizer\_function) | optimizer lambda function ARN |
<!-- END_TF_DOCS -->
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.0
v0.0.1
3 changes: 3 additions & 0 deletions examples/basic/.header.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Basic example

Terraform example that deploys the [Lambda power tuning solution](https://github.com/alexcasalboni/aws-lambda-power-tuning) using the terraform module aws-lambda-power-tuning
21 changes: 16 additions & 5 deletions examples/basic/README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,24 @@
<!-- BEGIN_TF_DOCS -->
# Basic example

Terraform example that deploys the [Lambda power tuning solution](https://github.com/alexcasalboni/aws-lambda-power-tuning) using the terraform module aws-lambda-power-tuning

## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 0.14.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 3.72.0 |
| <a name="requirement_awscc"></a> [awscc](#requirement\_awscc) | >= 0.11.0 |
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 5.26 |

## Providers

No providers.

## Modules

No modules.
| Name | Source | Version |
|------|--------|---------|
| <a name="module_aws_power_tuning"></a> [aws\_power\_tuning](#module\_aws\_power\_tuning) | ../../ | n/a |

## Resources

Expand All @@ -25,5 +30,11 @@ No inputs.

## Outputs

No outputs.
| Name | Description |
|------|-------------|
| <a name="output_analyzer_function_arn"></a> [analyzer\_function\_arn](#output\_analyzer\_function\_arn) | Analyzer lambda function ARN |
| <a name="output_cleaner_function_arn"></a> [cleaner\_function\_arn](#output\_cleaner\_function\_arn) | Cleaner lambda function ARN |
| <a name="output_executor_function_arn"></a> [executor\_function\_arn](#output\_executor\_function\_arn) | Executor lambda function ARN |
| <a name="output_initializer_function_arn"></a> [initializer\_function\_arn](#output\_initializer\_function\_arn) | Initializer lambda function ARN |
| <a name="output_optimizer_function_arn"></a> [optimizer\_function\_arn](#output\_optimizer\_function\_arn) | optimizer lambda function ARN |
<!-- END_TF_DOCS -->
7 changes: 7 additions & 0 deletions examples/basic/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,10 @@
# per use-case. The code below should not be copied directly but referenced in order
# to build your own root module that invokes this module
#####################################################################################
provider "aws" {
region = "us-west-2"
}

module "aws_power_tuning" {
source = "../../"
}
24 changes: 24 additions & 0 deletions examples/basic/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
output "analyzer_function_arn" {
description = "Analyzer lambda function ARN"
value = try(module.aws_power_tuning.analyzer_function, null)
}

output "cleaner_function_arn" {
description = "Cleaner lambda function ARN"
value = try(module.aws_power_tuning.cleaner_function.arn, null)
}

output "executor_function_arn" {
description = "Executor lambda function ARN"
value = try(module.aws_power_tuning.executor_function, null)
}

output "initializer_function_arn" {
description = "Initializer lambda function ARN"
value = try(module.aws_power_tuning.initializer_function, null)
}

output "optimizer_function_arn" {
description = "optimizer lambda function ARN"
value = try(module.aws_power_tuning.optimizer_function, null)
}
17 changes: 3 additions & 14 deletions examples/basic/providers.tf
Original file line number Diff line number Diff line change
@@ -1,21 +1,10 @@
terraform {
required_version = ">= 0.14.0"
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 3.72.0"
}
awscc = {
source = "hashicorp/awscc"
version = ">= 0.11.0"
version = ">= 5.26"
}
}
}

provider "awscc" {
user_agent = [{
product_name = "terraform-awscc-"
product_version = "0.0.1"
comment = "V1/AWS-D69B4015/<github repo id>"
}]
}
Loading

0 comments on commit 39c0b08

Please sign in to comment.