Skip to content

Commit fffe863

Browse files
committed
Fix linting issues and complete comprehensive testing
- Remove unused variables and declarations to resolve tflint warnings - Add missing random provider version constraint in versions.tf - Remove unused allowed_ingress_cidrs variable from module and examples - Clean up unused local values and data sources - Apply automatic formatting fixes from pre-commit hooks - Complete full test suite validation: * Unit tests: All Terraform validation tests passing * Integration tests: Actual GCP infrastructure deployment successful * Linting: All tflint warnings resolved, formatting applied * Examples: Both dev and prod configurations validate correctly All tests demonstrate successful infrastructure provisioning and cleanup, confirming the module is production-ready with comprehensive test coverage.
1 parent b67026b commit fffe863

27 files changed

Lines changed: 210 additions & 83 deletions

.terraform-docs.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ content: |-
2626
version = "~> 1.0"
2727
2828
project_id = "my-gcp-project"
29-
region = "us-central1"
29+
region = "us-central1"
3030
name_prefix = "acme-hrafnar"
3131
3232
# Hrafnar application configuration
3333
app_image = "gcr.io/my-project/hrafnar:latest"
34-
34+
3535
# AI API keys (stored securely in Secret Manager)
3636
ai_api_keys = {
3737
OPENAI_API_KEY = "sk-..."
@@ -53,7 +53,7 @@ content: |-
5353
5454
# Hrafnar application
5555
app_image = "gcr.io/my-project/hrafnar:latest"
56-
56+
5757
# Optional React frontend
5858
enable_react_frontend = true
5959
react_image = "gcr.io/my-project/hrafnar-ui:latest"

Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ test: ## Run unit tests (no infrastructure)
3838
@echo "Running unit tests..."
3939
@cd test && go test -v -timeout 10m -run "TestTerraformValidation|TestExamplesValidation|TestHrafnarModuleFunctionality"
4040

41-
test-integration: ## Run integration tests (deploys real infrastructure)
41+
test-integration: ## Run integration tests (deploys real infrastructure)
4242
@echo "Running integration tests..."
4343
@echo "WARNING: This will deploy real GCP infrastructure and may incur costs!"
4444
@cd test && go test -v -timeout 45m -run "Integration|TestMinimalDeployment"
@@ -53,7 +53,7 @@ test-prod: ## Run prod environment integration test
5353
@echo "WARNING: This will deploy real GCP infrastructure!"
5454
@cd test && go test -v -timeout 30m -run TestProdEnvironmentDeployment
5555

56-
test-minimal: ## Run minimal deployment integration test
56+
test-minimal: ## Run minimal deployment integration test
5757
@echo "Running minimal deployment integration test..."
5858
@echo "WARNING: This will deploy real GCP infrastructure!"
5959
@cd test && go test -v -timeout 30m -run TestMinimalDeployment

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ module "hrafnar_deploy" {
3434
project_id = "my-gcp-project"
3535
name_prefix = "prod-hrafnar"
3636
app_image = "gcr.io/my-project/hrafnar:latest"
37-
37+
3838
ai_api_keys = {
3939
OPENAI_API_KEY = "sk-..."
4040
}
@@ -84,12 +84,12 @@ module "hrafnar_gcp_deploy" {
8484
version = "~> 1.0"
8585
8686
project_id = "my-gcp-project"
87-
region = "us-central1"
87+
region = "us-central1"
8888
name_prefix = "acme-hrafnar"
8989
9090
# Hrafnar application configuration
9191
app_image = "gcr.io/my-project/hrafnar:latest"
92-
92+
9393
# AI API keys (stored securely in Secret Manager)
9494
ai_api_keys = {
9595
OPENAI_API_KEY = "sk-..."
@@ -111,7 +111,7 @@ module "hrafnar_gcp_deploy" {
111111
112112
# Hrafnar application
113113
app_image = "gcr.io/my-project/hrafnar:latest"
114-
114+
115115
# Optional React frontend
116116
enable_react_frontend = true
117117
react_image = "gcr.io/my-project/hrafnar-ui:latest"
@@ -357,7 +357,7 @@ export TF_VAR_base_domain="yourdomain.com"
357357
# Test development environment deployment
358358
cd test && go test -v -run TestDevEnvironmentDeployment -timeout 30m
359359

360-
# Test production environment deployment
360+
# Test production environment deployment
361361
cd test && go test -v -run TestProdEnvironmentDeployment -timeout 30m
362362

363363
# Test minimal configuration

cloud-run-react.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,4 @@ resource "google_cloud_run_domain_mapping" "react_frontend" {
111111
}
112112

113113
depends_on = [google_cloud_run_service.react_frontend]
114-
}
114+
}

cloud-run.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,4 +172,4 @@ resource "google_cloud_run_domain_mapping" "ui_app" {
172172
}
173173

174174
depends_on = [google_cloud_run_service.main_app]
175-
}
175+
}

database.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,4 +134,4 @@ resource "google_secret_manager_secret" "db_password" {
134134
resource "google_secret_manager_secret_version" "db_password" {
135135
secret = google_secret_manager_secret.db_password.id
136136
secret_data = random_password.db_password.result
137-
}
137+
}

dns.tf

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
# Data source to get the Cloudflare zone information
2-
data "cloudflare_zone" "main" {
3-
count = var.enable_cloudflare_dns ? 1 : 0
4-
zone_id = var.cloudflare_zone_id
5-
}
61

72
# DNS A record for API subdomain pointing to hrafnar application
83
resource "cloudflare_record" "api" {
@@ -34,4 +29,4 @@ resource "cloudflare_record" "ui" {
3429
google_cloud_run_domain_mapping.react_frontend,
3530
google_cloud_run_domain_mapping.ui_app
3631
]
37-
}
32+
}

examples/dev/README.md

Lines changed: 83 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,114 @@
33

44
## Usage
55

6+
### Basic Usage (hrafnar app only)
7+
8+
```hcl
9+
module "hrafnar_gcp_deploy" {
10+
source = "openteams-ai/hrafnar-gcp-deploy/gcp"
11+
version = "~> 1.0"
12+
13+
project_id = "my-gcp-project"
14+
region = "us-central1"
15+
name_prefix = "acme-hrafnar"
16+
17+
# Hrafnar application configuration
18+
app_image = "gcr.io/my-project/hrafnar:latest"
19+
20+
# AI API keys (stored securely in Secret Manager)
21+
ai_api_keys = {
22+
OPENAI_API_KEY = "sk-..."
23+
ANTHROPIC_API_KEY = "sk-ant-..."
24+
}
25+
}
26+
```
27+
28+
### With Cloudflare DNS and React Frontend
29+
630
```hcl
7-
module "cloudrun_ai_app" {
8-
source = "openteams-ai/cloudrun-ai-app/gcp"
31+
module "hrafnar_gcp_deploy" {
32+
source = "openteams-ai/hrafnar-gcp-deploy/gcp"
933
version = "~> 1.0"
1034
11-
project_id = "my-gcp-project"
12-
region = "us-central1"
13-
customer_name = "acme-corp"
14-
domain_name = "acme.example.com"
35+
project_id = "my-gcp-project"
36+
region = "us-central1"
37+
name_prefix = "acme-hrafnar"
38+
39+
# Hrafnar application
40+
app_image = "gcr.io/my-project/hrafnar:latest"
41+
42+
# Optional React frontend
43+
enable_react_frontend = true
44+
react_image = "gcr.io/my-project/hrafnar-ui:latest"
45+
46+
# Cloudflare DNS configuration
47+
enable_cloudflare_dns = true
48+
cloudflare_api_token = "your-cloudflare-token"
49+
cloudflare_zone_id = "your-zone-id"
50+
base_domain = "example.com"
51+
api_subdomain = "api"
52+
ui_subdomain = "app"
53+
54+
# AI configuration
55+
ai_api_keys = {
56+
OPENAI_API_KEY = "sk-..."
57+
ANTHROPIC_API_KEY = "sk-ant-..."
58+
}
1559
16-
# Application configuration
17-
app_image = "gcr.io/my-project/ai-app:latest"
18-
app_env_vars = {
19-
AI_BACKEND_URL = "https://api.openai.com/v1"
20-
MCP_SERVER_URL = "https://mcp.example.com"
60+
# MCP servers
61+
mcp_servers = {
62+
filesystem = {
63+
url = "https://mcp-fs.example.com"
64+
description = "Filesystem MCP server"
65+
}
2166
}
2267
}
2368
```
2469

2570
## Requirements
2671

27-
No requirements.
72+
| Name | Version |
73+
|------|---------|
74+
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.5 |
75+
| <a name="requirement_cloudflare"></a> [cloudflare](#requirement\_cloudflare) | ~> 4.0 |
76+
| <a name="requirement_google"></a> [google](#requirement\_google) | ~> 5.0 |
77+
| <a name="requirement_google-beta"></a> [google-beta](#requirement\_google-beta) | ~> 5.0 |
78+
| <a name="requirement_random"></a> [random](#requirement\_random) | ~> 3.1 |
2879

2980
## Providers
3081

3182
No providers.
3283

3384
## Modules
3485

35-
No modules.
86+
| Name | Source | Version |
87+
|------|--------|---------|
88+
| <a name="module_hrafnar_dev"></a> [hrafnar\_dev](#module\_hrafnar\_dev) | ../../ | n/a |
3689

3790
## Resources
3891

3992
No resources.
4093

4194
## Inputs
4295

43-
No inputs.
96+
| Name | Description | Type | Default | Required |
97+
|------|-------------|------|---------|:--------:|
98+
| <a name="input_ai_api_keys"></a> [ai\_api\_keys](#input\_ai\_api\_keys) | Map of AI API keys (e.g., OPENAI\_API\_KEY, ANTHROPIC\_API\_KEY) | `map(string)` | `{}` | no |
99+
| <a name="input_app_image"></a> [app\_image](#input\_app\_image) | Container image for the hrafnar application | `string` | `"gcr.io/my-project/hrafnar:dev"` | no |
100+
| <a name="input_base_domain"></a> [base\_domain](#input\_base\_domain) | Base domain name (e.g., 'example.com') | `string` | `""` | no |
101+
| <a name="input_cloudflare_api_token"></a> [cloudflare\_api\_token](#input\_cloudflare\_api\_token) | Cloudflare API token (required if enable\_cloudflare\_dns is true) | `string` | `""` | no |
102+
| <a name="input_cloudflare_zone_id"></a> [cloudflare\_zone\_id](#input\_cloudflare\_zone\_id) | Cloudflare zone ID (required if enable\_cloudflare\_dns is true) | `string` | `""` | no |
103+
| <a name="input_enable_cloudflare_dns"></a> [enable\_cloudflare\_dns](#input\_enable\_cloudflare\_dns) | Enable Cloudflare DNS management for development | `bool` | `false` | no |
104+
| <a name="input_mcp_servers"></a> [mcp\_servers](#input\_mcp\_servers) | MCP server configurations for development | <pre>map(object({<br/> url = string<br/> api_key = optional(string)<br/> description = string<br/> }))</pre> | <pre>{<br/> "filesystem": {<br/> "description": "Local filesystem MCP server for development",<br/> "url": "http://localhost:3001"<br/> }<br/>}</pre> | no |
105+
| <a name="input_project_id"></a> [project\_id](#input\_project\_id) | GCP project ID for development environment | `string` | n/a | yes |
44106

45107
## Outputs
46108

47-
No outputs.
109+
| Name | Description |
110+
|------|-------------|
111+
| <a name="output_api_domain"></a> [api\_domain](#output\_api\_domain) | Development API domain (if DNS enabled) |
112+
| <a name="output_database_connection_name"></a> [database\_connection\_name](#output\_database\_connection\_name) | Development database connection name |
113+
| <a name="output_hrafnar_app_url"></a> [hrafnar\_app\_url](#output\_hrafnar\_app\_url) | URL of the hrafnar application in development |
114+
| <a name="output_ui_domain"></a> [ui\_domain](#output\_ui\_domain) | Development UI domain (if DNS enabled) |
115+
| <a name="output_vpc_name"></a> [vpc\_name](#output\_vpc\_name) | Development VPC network name |
48116
<!-- END_TF_DOCS -->

examples/dev/main.tf

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,11 @@ module "hrafnar_dev" {
5151
log_level = "DEBUG"
5252

5353
# Security (more permissive for development)
54-
allowed_ingress_cidrs = ["0.0.0.0/0"]
5554

5655
# Labels
5756
labels = {
5857
environment = "development"
5958
team = "engineering"
6059
cost_center = "development"
6160
}
62-
}
61+
}

examples/dev/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@ output "database_connection_name" {
2121
output "vpc_name" {
2222
description = "Development VPC network name"
2323
value = module.hrafnar_dev.vpc_name
24-
}
24+
}

0 commit comments

Comments
 (0)