Skip to content

Commit 5096282

Browse files
authored
Merge pull request #22 from oozou/terraform-test
add terraform-test
2 parents c7cac28 + f18524e commit 5096282

23 files changed

+1855
-79
lines changed

.github/workflows/claude.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Claude PR Assistant
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
pull_request_review_comment:
7+
types: [created]
8+
issues:
9+
types: [opened, assigned]
10+
pull_request_review:
11+
types: [submitted]
12+
13+
jobs:
14+
claude-code-action:
15+
if: |
16+
(github.event_name == 'issue_comment' && contains(github.event.comment.body, '@claude')) ||
17+
(github.event_name == 'pull_request_review_comment' && contains(github.event.comment.body, '@claude')) ||
18+
(github.event_name == 'pull_request_review' && contains(github.event.review.body, '@claude')) ||
19+
(github.event_name == 'issues' && contains(github.event.issue.body, '@claude'))
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: read
23+
pull-requests: read
24+
issues: read
25+
id-token: write
26+
steps:
27+
- name: Checkout repository
28+
uses: actions/checkout@v4
29+
with:
30+
fetch-depth: 1
31+
32+
- name: Run Claude PR Action
33+
uses: anthropics/claude-code-action@beta
34+
with:
35+
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
36+
timeout_minutes: "60"
37+
model: "claude-opus-4-20250514"

.github/workflows/terraform-test.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Test Module
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- '*.tf'
7+
- 'tests/**'
8+
- 'examples/terraform-test/**'
9+
- '.github/workflows/terraform-test.yaml'
10+
workflow_dispatch:
11+
12+
permissions:
13+
contents: read
14+
pull-requests: write
15+
id-token: write
16+
17+
jobs:
18+
test:
19+
name: Run Terraform Tests
20+
uses: oozou/.github/.github/workflows/terraform-test.yml@main
21+
secrets: inherit
22+
with:
23+
aws_region: 'ap-southeast-1'
24+
tf_version: '1.6.0'
25+
go_version: '1.21'
26+
test_example_path: 'examples/terraform-test'
27+
timeout_minutes: 60
28+
module_name: 'AWS Lambda'
29+
iam_oidc_role: 'arn:aws:iam::562563527952:role/oozou-internal-devops-github-action-oidc-role' # oozou internal account

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
All notable changes to this module will be documented in this file.
44

5+
## [v1.2.3] - 2025-07-11
6+
7+
### Added
8+
9+
- var additional_lambda_log_group_kms_policy
10+
511
## [v1.2.2] - 2023-11-20
612

713
### Changed

README.md

Lines changed: 74 additions & 74 deletions
Large diffs are not rendered by default.

examples/terraform-test/README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<!-- BEGIN_TF_DOCS -->
2+
## Requirements
3+
4+
| Name | Version |
5+
|---------------------------------------------------------------------------|-------------------|
6+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.0.0 |
7+
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | >= 4.0.0, < 5.0.0 |
8+
9+
## Providers
10+
11+
No providers.
12+
13+
## Modules
14+
15+
| Name | Source | Version |
16+
|--------------------------------------------------------|--------|---------|
17+
| <a name="module_lambda"></a> [lambda](#module\_lambda) | ../../ | n/a |
18+
19+
## Resources
20+
21+
No resources.
22+
23+
## Inputs
24+
25+
| Name | Description | Type | Default | Required |
26+
|--------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------|---------|:--------:|
27+
| <a name="input_generic_info"></a> [generic\_info](#input\_generic\_info) | `prefix` >> The prefix name of customer to be displayed in AWS console and resource<br> `environment` >> Environment Variable used as a prefix<br> `name` >> Name of the ECS cluster and s3 also redis to create<br> `custom_tags` >> Custom tags which can be passed on to the AWS resources. They should be key value pairs having distinct keys | <pre>object({<br> prefix = string<br> environment = string<br> name = string<br> custom_tags = map(any)<br> })</pre> | n/a | yes |
28+
29+
## Outputs
30+
31+
No outputs.
32+
<!-- END_TF_DOCS -->

examples/terraform-test/main.tf

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
module "lambda" {
2+
source = "../../"
3+
4+
prefix = var.generic_info.prefix
5+
environment = var.generic_info.environment
6+
name = var.generic_info.name
7+
8+
is_edge = false # Defautl is `false`, If you want to publish to the edge don't forget to override aws's provider to virgina
9+
10+
# If is_edge is `false`, ignore this config
11+
is_create_lambda_bucket = true # Default is `false`; plz use false, if not 1 lambda: 1 bucket
12+
bucket_name = "" # If `is_create_lambda_bucket` is `false`; specified this, default is `""`
13+
14+
# Source code
15+
source_code_dir = "./src"
16+
compressed_local_file_dir = "./outputs"
17+
18+
# Lambda Env
19+
runtime = "nodejs22.x"
20+
handler = "index.handler"
21+
22+
# Lambda Specification
23+
timeout = 3
24+
memory_size = 128
25+
reserved_concurrent_executions = -1
26+
27+
# Optional to connect Lambda to VPC
28+
# vpc_config = {
29+
# security_group_ids = ["sg-028f637312eea735e"]
30+
# subnet_ids_to_associate = ["subnet-0b853f8c85796d72d", "subnet-07c068b4b51262793", "subnet-0362f68c559ef7716"]
31+
# }
32+
# dead_letter_target_arn = "arn:aws:sns:ap-southeast-1:557291035693:demo" # To send failed processing to target, Default is `""`
33+
34+
# IAM
35+
is_create_lambda_role = true # Default is `true`
36+
lambda_role_arn = "" # If `is_create_lambda_role` is `false`
37+
# The policies that you want to attach to IAM Role created by only this module # If `is_create_lambda_role` is `false`
38+
additional_lambda_role_policy_arns = ["arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess"]
39+
40+
# Resource policy
41+
lambda_permission_configurations = {
42+
lambda_on_my_account = {
43+
principal = "apigateway.amazonaws.com"
44+
source_arn = "arn:aws:execute-api:ap-southeast-1:557291035112:lk36vflbha/*/*/"
45+
}
46+
lambda_on_my_another_account_wrong = {
47+
principal = "apigateway.amazonaws.com"
48+
source_arn = "arn:aws:execute-api:ap-southeast-1:224563527112:q6pwa6wgr6/*/*/"
49+
source_account = "557291035112"
50+
}
51+
lambda_on_my_another_account_correct = {
52+
principal = "apigateway.amazonaws.com"
53+
source_arn = "arn:aws:execute-api:ap-southeast-1:557291035112:wpj4t3scmb/*/*/"
54+
}
55+
}
56+
57+
# Logging
58+
is_create_cloudwatch_log_group = true # Default is `true`
59+
cloudwatch_log_retention_in_days = 90 # Default is `90`
60+
additional_lambda_log_group_kms_policy = data.aws_iam_policy_document.allow_github_oidc.json
61+
# Env
62+
ssm_params = {}
63+
environment_variables = {
64+
region = "ap-southeast-1"
65+
cluster_name = "oozou-dev-test-schedule-cluster"
66+
nodegroup_name = "oozou-dev-test-schedule-custom-nodegroup"
67+
min = 1,
68+
max = 1,
69+
desired = 1
70+
}
71+
72+
tags = var.generic_info.custom_tags
73+
}
74+
75+
76+
data "aws_iam_policy_document" "allow_github_oidc" {
77+
statement {
78+
sid = "AllowGitHubActionsEncryptDecrypt"
79+
effect = "Allow"
80+
81+
principals {
82+
type = "AWS"
83+
identifiers = [
84+
"arn:aws:iam::562563527952:role/oozou-internal-devops-github-action-oidc-role"
85+
]
86+
}
87+
88+
actions = [
89+
"kms:Encrypt",
90+
"kms:Decrypt",
91+
"kms:GenerateDataKey*",
92+
"kms:DescribeKey"
93+
]
94+
95+
resources = ["*"]
96+
}
97+
}

examples/terraform-test/outputs.tf

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
output "function_name" {
2+
description = "Name of the Lambda function."
3+
value = module.lambda.function_name
4+
}
5+
6+
output "function_arn" {
7+
description = "ARN of the Lambda function."
8+
value = module.lambda.function_arn
9+
}
10+
11+
output "execution_role_arn" {
12+
description = "ARN of the Lambda function's execution role."
13+
value = module.lambda.execution_role_arn
14+
}
338 Bytes
Binary file not shown.

examples/terraform-test/src/index.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
var http = require('http')
2+
3+
exports.handler = (event, context, callback) => {
4+
const options = {
5+
hostname: event.Host,
6+
port: event.Port
7+
}
8+
9+
const response = {};
10+
11+
http.get(options, (res) => {
12+
response.httpStatus = res.statusCode
13+
callback(null, response)
14+
}).on('error', (err) => {
15+
callback(null, err.message);
16+
})
17+
18+
};
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
generic_info = {
2+
prefix = "oozou",
3+
environment = "dev",
4+
name = "demo",
5+
custom_tags = {
6+
Workspace = "999-oozou-demo-dev-wp"
7+
}
8+
}

0 commit comments

Comments
 (0)