Skip to content

Commit 67f56ba

Browse files
authored
Merge pull request #1 from SPHTech-Platform/feature/support-for-vpc-subnet-ids
Add support for vpc_subnet_ids and vpc_security_group_ids
2 parents 4cb7d58 + 708aca0 commit 67f56ba

File tree

7 files changed

+96
-19
lines changed

7 files changed

+96
-19
lines changed

Diff for: LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
1919
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2020
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2121
SOFTWARE.
22-
Footer
22+
Footer

Diff for: README.md

+16-3
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@ Terraform module for creating the lambda and the github actions IAM Role deploye
88
| Name | Version |
99
|------|---------|
1010
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0 |
11+
| <a name="requirement_archive"></a> [archive](#requirement\_archive) | ~> 1.3 |
1112
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.27 |
1213

1314
## Providers
1415

1516
| Name | Version |
1617
|------|---------|
1718
| <a name="provider_archive"></a> [archive](#provider\_archive) | 2.3.0 |
18-
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.58.0 |
19+
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.62.0 |
1920

2021
## Modules
2122

@@ -42,23 +43,35 @@ Terraform module for creating the lambda and the github actions IAM Role deploye
4243
|------|-------------|------|---------|:--------:|
4344
| <a name="input_addition_lambda_policy"></a> [addition\_lambda\_policy](#input\_addition\_lambda\_policy) | List of additional policies for the lambda execution | `list(string)` | `[]` | no |
4445
| <a name="input_additional_deployer_role"></a> [additional\_deployer\_role](#input\_additional\_deployer\_role) | (Optional) Additional Deployer Policy Role | `list(any)` | `[]` | no |
46+
| <a name="input_additional_lambda_policy_statements"></a> [additional\_lambda\_policy\_statements](#input\_additional\_lambda\_policy\_statements) | Additional Inline Lambda Policy Statements | `any` | `{}` | no |
4547
| <a name="input_allowed_triggers"></a> [allowed\_triggers](#input\_allowed\_triggers) | Map of allowed triggers to create Lambda permissions | `map(any)` | `{}` | no |
4648
| <a name="input_app_metadata"></a> [app\_metadata](#input\_app\_metadata) | Application component prefix, name used to generate resource names | <pre>object({<br> prefix = string<br> name = string<br> env = string<br> })</pre> | n/a | yes |
49+
| <a name="input_attach_network_policy"></a> [attach\_network\_policy](#input\_attach\_network\_policy) | Flag to attach network policy to use VPC subnet and security group | `bool` | `true` | no |
4750
| <a name="input_authorization_type"></a> [authorization\_type](#input\_authorization\_type) | The type of authentication that the Lambda Function URL uses. Set to 'AWS\_IAM' to restrict access to authenticated IAM users only. Set to 'NONE' to bypass IAM authentication and create a public endpoint. | `string` | `"AWS_IAM"` | no |
4851
| <a name="input_cors"></a> [cors](#input\_cors) | CORS settings to be used by the Lambda Function URL | `any` | `{}` | no |
4952
| <a name="input_create_gha_deployer"></a> [create\_gha\_deployer](#input\_create\_gha\_deployer) | Flag for creating Github Actions Deployer deployer | `bool` | `true` | no |
5053
| <a name="input_function_description"></a> [function\_description](#input\_function\_description) | Lambda Function Description | `string` | `""` | no |
5154
| <a name="input_function_index_handler"></a> [function\_index\_handler](#input\_function\_index\_handler) | Lambda Function Index Handler | `string` | `"index.handler"` | no |
52-
| <a name="input_function_name"></a> [function\_name](#input\_function\_name) | Lambda Function Name | `string` | `""` | no |
55+
| <a name="input_function_name"></a> [function\_name](#input\_function\_name) | Lambda Function Name | `string` | n/a | yes |
5356
| <a name="input_function_prefix"></a> [function\_prefix](#input\_function\_prefix) | Prefix for the IAM role for lambda functions | `string` | `""` | no |
5457
| <a name="input_github_branches"></a> [github\_branches](#input\_github\_branches) | List of github branches allowed for oidc subject claims. | `list(string)` | `[]` | no |
5558
| <a name="input_github_environments"></a> [github\_environments](#input\_github\_environments) | (Optional) Allow GitHub action to deploy to all (default) or to one of the environments in the list. | `list(string)` | <pre>[<br> "*"<br>]</pre> | no |
5659
| <a name="input_github_repo"></a> [github\_repo](#input\_github\_repo) | GitHub repository to grant access to assume a role via OIDC. | `string` | n/a | yes |
5760
| <a name="input_lambda_environment_variables"></a> [lambda\_environment\_variables](#input\_lambda\_environment\_variables) | A map that defines environment variables for the Lambda Function. | `map(string)` | `{}` | no |
5861
| <a name="input_lambda_runtime"></a> [lambda\_runtime](#input\_lambda\_runtime) | Lambda Function runtime | `string` | `"nodejs18.x"` | no |
5962
| <a name="input_role_name"></a> [role\_name](#input\_role\_name) | (Optional) role name of the created role, if not provided the github\_repo will be used to generate. | `string` | `null` | no |
63+
| <a name="input_vpc_security_group_ids"></a> [vpc\_security\_group\_ids](#input\_vpc\_security\_group\_ids) | Listof Security Groups | `list(string)` | n/a | yes |
64+
| <a name="input_vpc_subnet_ids"></a> [vpc\_subnet\_ids](#input\_vpc\_subnet\_ids) | List of Subnet Ids | `list(string)` | n/a | yes |
6065

6166
## Outputs
6267

63-
No outputs.
68+
| Name | Description |
69+
|------|-------------|
70+
| <a name="output_lambda_cloudwatch_log_group_arn"></a> [lambda\_cloudwatch\_log\_group\_arn](#output\_lambda\_cloudwatch\_log\_group\_arn) | Lambda Cloudwatch Log group |
71+
| <a name="output_lambda_cloudwatch_log_group_name"></a> [lambda\_cloudwatch\_log\_group\_name](#output\_lambda\_cloudwatch\_log\_group\_name) | Lambda Cloudwatch Log group |
72+
| <a name="output_lambda_function_arn"></a> [lambda\_function\_arn](#output\_lambda\_function\_arn) | Lambda Function ARN |
73+
| <a name="output_lambda_function_name"></a> [lambda\_function\_name](#output\_lambda\_function\_name) | Lambda Function Name |
74+
| <a name="output_lambda_role_arn"></a> [lambda\_role\_arn](#output\_lambda\_role\_arn) | ARN of the IAM role created for the Lambda Function |
75+
| <a name="output_lambda_role_name"></a> [lambda\_role\_name](#output\_lambda\_role\_name) | The name of the IAM role created for the Lambda Function |
76+
| <a name="output_lambda_role_unique_id"></a> [lambda\_role\_unique\_id](#output\_lambda\_role\_unique\_id) | The unique id of the IAM role created for the Lambda Function |
6477
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->

Diff for: gha_deployer.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ module "github_actions_repo" {
2828
default_conditions = ["allow_environment", "allow_main"]
2929
github_environments = var.github_environments
3030

31-
conditions = (var.github_branches != []) ? [
31+
conditions = (length(var.github_branches) > 0) ? [
3232
{
3333
test = "StringLike"
3434
variable = "token.actions.githubusercontent.com:sub"

Diff for: main.tf

+19-13
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,26 @@ module "lambda" {
1111
source = "terraform-aws-modules/lambda/aws"
1212
version = "~> 4.10.1"
1313

14-
function_name = var.function_name
15-
description = var.function_description
16-
role_name = "${var.function_name}-role"
17-
handler = var.function_index_handler
18-
runtime = var.lambda_runtime
19-
create_package = false
20-
environment_variables = var.lambda_environment_variables
21-
allowed_triggers = var.allowed_triggers
22-
create_lambda_function_url = true
23-
authorization_type = var.authorization_type
24-
cors = var.cors
25-
attach_policy_jsons = true
26-
ignore_source_code_hash = true
14+
function_name = var.function_name
15+
description = var.function_description
16+
role_name = "${var.function_name}-role"
17+
handler = var.function_index_handler
18+
runtime = var.lambda_runtime
19+
create_package = false
20+
environment_variables = var.lambda_environment_variables
21+
allowed_triggers = var.allowed_triggers
22+
create_lambda_function_url = true
23+
create_current_version_allowed_triggers = false
24+
authorization_type = var.authorization_type
25+
cors = var.cors
26+
attach_policy_jsons = true
27+
ignore_source_code_hash = true
2728
# dummy package, package is delegated to CI pipeline
2829
local_existing_package = data.archive_file.dummy.output_path
2930
policy_jsons = var.addition_lambda_policy
31+
policy_statements = var.additional_lambda_policy_statements
32+
33+
vpc_subnet_ids = var.vpc_subnet_ids
34+
vpc_security_group_ids = var.vpc_security_group_ids
35+
attach_network_policy = var.attach_network_policy
3036
}

Diff for: outputs.tf

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
output "lambda_function_arn" {
2+
description = "Lambda Function ARN"
3+
value = module.lambda.lambda_function_arn
4+
}
5+
6+
output "lambda_function_name" {
7+
description = "Lambda Function Name"
8+
value = module.lambda.lambda_function_name
9+
}
10+
11+
# Cloudwatch Log Group
12+
output "lambda_cloudwatch_log_group_arn" {
13+
description = "Lambda Cloudwatch Log group"
14+
value = module.lambda.lambda_cloudwatch_log_group_arn
15+
}
16+
17+
output "lambda_cloudwatch_log_group_name" {
18+
description = "Lambda Cloudwatch Log group"
19+
value = module.lambda.lambda_cloudwatch_log_group_name
20+
}
21+
22+
# IAM Role
23+
output "lambda_role_arn" {
24+
description = "ARN of the IAM role created for the Lambda Function"
25+
value = module.lambda.lambda_role_arn
26+
}
27+
28+
output "lambda_role_name" {
29+
description = "The name of the IAM role created for the Lambda Function"
30+
value = module.lambda.lambda_role_name
31+
}
32+
33+
output "lambda_role_unique_id" {
34+
description = "The unique id of the IAM role created for the Lambda Function"
35+
value = module.lambda.lambda_role_unique_id
36+
}

Diff for: variables.tf

+22-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ variable "app_metadata" {
1515
variable "function_name" {
1616
description = "Lambda Function Name"
1717
type = string
18-
default = ""
1918
}
2019

2120
variable "function_description" {
@@ -104,3 +103,25 @@ variable "addition_lambda_policy" {
104103
type = list(string)
105104
default = []
106105
}
106+
107+
variable "additional_lambda_policy_statements" {
108+
description = "Additional Inline Lambda Policy Statements"
109+
type = any
110+
default = {}
111+
}
112+
113+
variable "vpc_subnet_ids" {
114+
description = "List of Subnet Ids"
115+
type = list(string)
116+
}
117+
118+
variable "vpc_security_group_ids" {
119+
description = "Listof Security Groups"
120+
type = list(string)
121+
}
122+
123+
variable "attach_network_policy" {
124+
description = "Flag to attach network policy to use VPC subnet and security group"
125+
type = bool
126+
default = true
127+
}

Diff for: versions.tf

+1
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,6 @@ terraform {
77
source = "hashicorp/aws"
88
version = ">= 4.27"
99
}
10+
archive = "~> 1.3"
1011
}
1112
}

0 commit comments

Comments
 (0)