tf-starter 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (137) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +421 -0
  3. package/bin/tf-starter.js +88 -0
  4. package/package.json +43 -0
  5. package/scripts/postinstall.js +105 -0
  6. package/setup.py +32 -0
  7. package/tf_starter/__init__.py +3 -0
  8. package/tf_starter/__main__.py +6 -0
  9. package/tf_starter/cli.py +379 -0
  10. package/tf_starter/generator.py +171 -0
  11. package/tf_starter/template_engine.py +80 -0
  12. package/tf_starter/templates/aws/environments/backend.tf.j2 +16 -0
  13. package/tf_starter/templates/aws/environments/main.tf.j2 +85 -0
  14. package/tf_starter/templates/aws/environments/terraform.tfvars.j2 +52 -0
  15. package/tf_starter/templates/aws/environments/variables.tf.j2 +127 -0
  16. package/tf_starter/templates/aws/github/terraform.yml.j2 +133 -0
  17. package/tf_starter/templates/aws/misc/Makefile.j2 +60 -0
  18. package/tf_starter/templates/aws/misc/README.md.j2 +445 -0
  19. package/tf_starter/templates/aws/misc/init.sh.j2 +110 -0
  20. package/tf_starter/templates/aws/misc/pre-commit-config.yaml.j2 +34 -0
  21. package/tf_starter/templates/aws/modules/apigateway/main.tf.j2 +224 -0
  22. package/tf_starter/templates/aws/modules/apigateway/outputs.tf.j2 +28 -0
  23. package/tf_starter/templates/aws/modules/apigateway/variables.tf.j2 +69 -0
  24. package/tf_starter/templates/aws/modules/compute/main.tf.j2 +245 -0
  25. package/tf_starter/templates/aws/modules/compute/outputs.tf.j2 +38 -0
  26. package/tf_starter/templates/aws/modules/compute/variables.tf.j2 +68 -0
  27. package/tf_starter/templates/aws/modules/database/main.tf.j2 +122 -0
  28. package/tf_starter/templates/aws/modules/database/outputs.tf.j2 +33 -0
  29. package/tf_starter/templates/aws/modules/database/variables.tf.j2 +63 -0
  30. package/tf_starter/templates/aws/modules/kubernetes/main.tf.j2 +167 -0
  31. package/tf_starter/templates/aws/modules/kubernetes/outputs.tf.j2 +33 -0
  32. package/tf_starter/templates/aws/modules/kubernetes/variables.tf.j2 +64 -0
  33. package/tf_starter/templates/aws/modules/lambda/main.tf.j2 +215 -0
  34. package/tf_starter/templates/aws/modules/lambda/outputs.tf.j2 +38 -0
  35. package/tf_starter/templates/aws/modules/lambda/variables.tf.j2 +88 -0
  36. package/tf_starter/templates/aws/modules/messaging/main.tf.j2 +85 -0
  37. package/tf_starter/templates/aws/modules/messaging/outputs.tf.j2 +28 -0
  38. package/tf_starter/templates/aws/modules/messaging/variables.tf.j2 +41 -0
  39. package/tf_starter/templates/aws/modules/monitoring/main.tf.j2 +155 -0
  40. package/tf_starter/templates/aws/modules/monitoring/outputs.tf.j2 +23 -0
  41. package/tf_starter/templates/aws/modules/monitoring/variables.tf.j2 +39 -0
  42. package/tf_starter/templates/aws/modules/network/main.tf.j2 +147 -0
  43. package/tf_starter/templates/aws/modules/network/outputs.tf.j2 +33 -0
  44. package/tf_starter/templates/aws/modules/network/variables.tf.j2 +52 -0
  45. package/tf_starter/templates/aws/modules/storage/main.tf.j2 +88 -0
  46. package/tf_starter/templates/aws/modules/storage/outputs.tf.j2 +23 -0
  47. package/tf_starter/templates/aws/modules/storage/variables.tf.j2 +25 -0
  48. package/tf_starter/templates/aws/root/backend.tf.j2 +19 -0
  49. package/tf_starter/templates/aws/root/main.tf.j2 +219 -0
  50. package/tf_starter/templates/aws/root/outputs.tf.j2 +134 -0
  51. package/tf_starter/templates/aws/root/providers.tf.j2 +24 -0
  52. package/tf_starter/templates/aws/root/variables.tf.j2 +300 -0
  53. package/tf_starter/templates/aws/root/versions.tf.j2 +26 -0
  54. package/tf_starter/templates/azure/environments/backend.tf.j2 +11 -0
  55. package/tf_starter/templates/azure/environments/main.tf.j2 +57 -0
  56. package/tf_starter/templates/azure/environments/terraform.tfvars.j2 +14 -0
  57. package/tf_starter/templates/azure/environments/variables.tf.j2 +30 -0
  58. package/tf_starter/templates/azure/github/terraform.yml.j2 +133 -0
  59. package/tf_starter/templates/azure/misc/Makefile.j2 +60 -0
  60. package/tf_starter/templates/azure/misc/README.md.j2 +426 -0
  61. package/tf_starter/templates/azure/misc/init.sh.j2 +110 -0
  62. package/tf_starter/templates/azure/misc/pre-commit-config.yaml.j2 +34 -0
  63. package/tf_starter/templates/azure/modules/apigateway/main.tf.j2 +125 -0
  64. package/tf_starter/templates/azure/modules/apigateway/outputs.tf.j2 +18 -0
  65. package/tf_starter/templates/azure/modules/apigateway/variables.tf.j2 +54 -0
  66. package/tf_starter/templates/azure/modules/compute/main.tf.j2 +114 -0
  67. package/tf_starter/templates/azure/modules/compute/outputs.tf.j2 +9 -0
  68. package/tf_starter/templates/azure/modules/compute/variables.tf.j2 +23 -0
  69. package/tf_starter/templates/azure/modules/database/main.tf.j2 +56 -0
  70. package/tf_starter/templates/azure/modules/database/outputs.tf.j2 +13 -0
  71. package/tf_starter/templates/azure/modules/database/variables.tf.j2 +38 -0
  72. package/tf_starter/templates/azure/modules/kubernetes/main.tf.j2 +50 -0
  73. package/tf_starter/templates/azure/modules/kubernetes/outputs.tf.j2 +19 -0
  74. package/tf_starter/templates/azure/modules/kubernetes/variables.tf.j2 +37 -0
  75. package/tf_starter/templates/azure/modules/lambda/main.tf.j2 +98 -0
  76. package/tf_starter/templates/azure/modules/lambda/outputs.tf.j2 +23 -0
  77. package/tf_starter/templates/azure/modules/lambda/variables.tf.j2 +53 -0
  78. package/tf_starter/templates/azure/modules/messaging/main.tf.j2 +29 -0
  79. package/tf_starter/templates/azure/modules/messaging/outputs.tf.j2 +14 -0
  80. package/tf_starter/templates/azure/modules/messaging/variables.tf.j2 +11 -0
  81. package/tf_starter/templates/azure/modules/monitoring/main.tf.j2 +31 -0
  82. package/tf_starter/templates/azure/modules/monitoring/outputs.tf.j2 +9 -0
  83. package/tf_starter/templates/azure/modules/monitoring/variables.tf.j2 +16 -0
  84. package/tf_starter/templates/azure/modules/network/main.tf.j2 +89 -0
  85. package/tf_starter/templates/azure/modules/network/outputs.tf.j2 +25 -0
  86. package/tf_starter/templates/azure/modules/network/variables.tf.j2 +25 -0
  87. package/tf_starter/templates/azure/modules/storage/main.tf.j2 +41 -0
  88. package/tf_starter/templates/azure/modules/storage/outputs.tf.j2 +17 -0
  89. package/tf_starter/templates/azure/modules/storage/variables.tf.j2 +16 -0
  90. package/tf_starter/templates/azure/root/backend.tf.j2 +11 -0
  91. package/tf_starter/templates/azure/root/main.tf.j2 +181 -0
  92. package/tf_starter/templates/azure/root/outputs.tf.j2 +45 -0
  93. package/tf_starter/templates/azure/root/providers.tf.j2 +18 -0
  94. package/tf_starter/templates/azure/root/variables.tf.j2 +114 -0
  95. package/tf_starter/templates/azure/root/versions.tf.j2 +16 -0
  96. package/tf_starter/templates/gcp/environments/backend.tf.j2 +9 -0
  97. package/tf_starter/templates/gcp/environments/main.tf.j2 +58 -0
  98. package/tf_starter/templates/gcp/environments/terraform.tfvars.j2 +12 -0
  99. package/tf_starter/templates/gcp/environments/variables.tf.j2 +21 -0
  100. package/tf_starter/templates/gcp/github/terraform.yml.j2 +133 -0
  101. package/tf_starter/templates/gcp/misc/Makefile.j2 +60 -0
  102. package/tf_starter/templates/gcp/misc/README.md.j2 +426 -0
  103. package/tf_starter/templates/gcp/misc/init.sh.j2 +110 -0
  104. package/tf_starter/templates/gcp/misc/pre-commit-config.yaml.j2 +34 -0
  105. package/tf_starter/templates/gcp/modules/apigateway/main.tf.j2 +67 -0
  106. package/tf_starter/templates/gcp/modules/apigateway/outputs.tf.j2 +18 -0
  107. package/tf_starter/templates/gcp/modules/apigateway/variables.tf.j2 +34 -0
  108. package/tf_starter/templates/gcp/modules/compute/main.tf.j2 +138 -0
  109. package/tf_starter/templates/gcp/modules/compute/outputs.tf.j2 +13 -0
  110. package/tf_starter/templates/gcp/modules/compute/variables.tf.j2 +33 -0
  111. package/tf_starter/templates/gcp/modules/database/main.tf.j2 +62 -0
  112. package/tf_starter/templates/gcp/modules/database/outputs.tf.j2 +13 -0
  113. package/tf_starter/templates/gcp/modules/database/variables.tf.j2 +29 -0
  114. package/tf_starter/templates/gcp/modules/kubernetes/main.tf.j2 +75 -0
  115. package/tf_starter/templates/gcp/modules/kubernetes/outputs.tf.j2 +14 -0
  116. package/tf_starter/templates/gcp/modules/kubernetes/variables.tf.j2 +38 -0
  117. package/tf_starter/templates/gcp/modules/lambda/main.tf.j2 +122 -0
  118. package/tf_starter/templates/gcp/modules/lambda/outputs.tf.j2 +18 -0
  119. package/tf_starter/templates/gcp/modules/lambda/variables.tf.j2 +77 -0
  120. package/tf_starter/templates/gcp/modules/messaging/main.tf.j2 +44 -0
  121. package/tf_starter/templates/gcp/modules/messaging/outputs.tf.j2 +13 -0
  122. package/tf_starter/templates/gcp/modules/messaging/variables.tf.j2 +20 -0
  123. package/tf_starter/templates/gcp/modules/monitoring/main.tf.j2 +44 -0
  124. package/tf_starter/templates/gcp/modules/monitoring/outputs.tf.j2 +9 -0
  125. package/tf_starter/templates/gcp/modules/monitoring/variables.tf.j2 +13 -0
  126. package/tf_starter/templates/gcp/modules/network/main.tf.j2 +103 -0
  127. package/tf_starter/templates/gcp/modules/network/outputs.tf.j2 +21 -0
  128. package/tf_starter/templates/gcp/modules/network/variables.tf.j2 +22 -0
  129. package/tf_starter/templates/gcp/modules/storage/main.tf.j2 +47 -0
  130. package/tf_starter/templates/gcp/modules/storage/outputs.tf.j2 +13 -0
  131. package/tf_starter/templates/gcp/modules/storage/variables.tf.j2 +16 -0
  132. package/tf_starter/templates/gcp/root/backend.tf.j2 +12 -0
  133. package/tf_starter/templates/gcp/root/main.tf.j2 +210 -0
  134. package/tf_starter/templates/gcp/root/outputs.tf.j2 +61 -0
  135. package/tf_starter/templates/gcp/root/providers.tf.j2 +18 -0
  136. package/tf_starter/templates/gcp/root/variables.tf.j2 +140 -0
  137. package/tf_starter/templates/gcp/root/versions.tf.j2 +23 -0
@@ -0,0 +1,85 @@
1
+ # ---------------------------------------------------------------------------------------------------------------------
2
+ # ENVIRONMENT: {{ environment | upper }}
3
+ # Project: {{ project_name }}
4
+ # Generated by tf-starter
5
+ # ---------------------------------------------------------------------------------------------------------------------
6
+
7
+ module "{{ project_name | replace('-', '_') }}" {
8
+ source = "../../"
9
+
10
+ environment = "{{ environment }}"
11
+ region = "{{ region }}"
12
+
13
+ # ----- Network -----
14
+ vpc_cidr = var.vpc_cidr
15
+ public_subnet_cidrs = var.public_subnet_cidrs
16
+ private_subnet_cidrs = var.private_subnet_cidrs
17
+ availability_zones = var.availability_zones
18
+
19
+ {% if "compute" in services %}
20
+ # ----- Compute -----
21
+ {% if environment == "prod" %}
22
+ instance_type = "t3.large"
23
+ asg_min_size = 2
24
+ asg_max_size = 8
25
+ asg_desired_capacity = 4
26
+ {% elif environment == "staging" %}
27
+ instance_type = "t3.medium"
28
+ asg_min_size = 1
29
+ asg_max_size = 4
30
+ asg_desired_capacity = 2
31
+ {% else %}
32
+ instance_type = "t3.small"
33
+ asg_min_size = 1
34
+ asg_max_size = 2
35
+ asg_desired_capacity = 1
36
+ {% endif %}
37
+ {% endif %}
38
+
39
+ {% if "database" in services %}
40
+ # ----- Database -----
41
+ {% if environment == "prod" %}
42
+ db_instance_class = "db.r6g.large"
43
+ db_allocated_storage = 100
44
+ {% elif environment == "staging" %}
45
+ db_instance_class = "db.t3.medium"
46
+ db_allocated_storage = 50
47
+ {% else %}
48
+ db_instance_class = "db.t3.micro"
49
+ db_allocated_storage = 20
50
+ {% endif %}
51
+ db_name = "{{ project_name | replace('-', '_') }}_{{ environment }}"
52
+ db_username = var.db_username
53
+ {% endif %}
54
+
55
+ {% if "kubernetes" in services %}
56
+ # ----- Kubernetes -----
57
+ {% if environment == "prod" %}
58
+ eks_node_instance_type = "t3.xlarge"
59
+ eks_node_desired_size = 3
60
+ eks_node_min_size = 2
61
+ eks_node_max_size = 10
62
+ {% else %}
63
+ eks_node_instance_type = "t3.large"
64
+ eks_node_desired_size = 2
65
+ eks_node_min_size = 1
66
+ eks_node_max_size = 5
67
+ {% endif %}
68
+ {% endif %}
69
+
70
+ {% if "monitoring" in services %}
71
+ # ----- Monitoring -----
72
+ alarm_email = var.alarm_email
73
+ {% endif %}
74
+
75
+ {% if "messaging" in services %}
76
+ # ----- Messaging -----
77
+ sqs_message_retention = var.sqs_message_retention
78
+ sqs_visibility_timeout = var.sqs_visibility_timeout
79
+ {% endif %}
80
+
81
+ {% if "storage" in services %}
82
+ # ----- Storage -----
83
+ s3_enable_versioning = var.s3_enable_versioning
84
+ {% endif %}
85
+ }
@@ -0,0 +1,52 @@
1
+ # ---------------------------------------------------------------------------------------------------------------------
2
+ # ENVIRONMENT TFVARS: {{ environment | upper }}
3
+ # Project: {{ project_name }}
4
+ #
5
+ # ### MUST EDIT THIS ###
6
+ # Update these values for your {{ environment }} environment.
7
+ # ---------------------------------------------------------------------------------------------------------------------
8
+
9
+ vpc_cidr = "10.0.0.0/16"
10
+ public_subnet_cidrs = ["10.0.1.0/24", "10.0.2.0/24"]
11
+ private_subnet_cidrs = ["10.0.10.0/24", "10.0.11.0/24"]
12
+ availability_zones = ["{{ region }}a", "{{ region }}b"]
13
+
14
+ {% if "lambda" in services %}
15
+ lambda_function_name = "app"
16
+ lambda_runtime = "python3.12"
17
+ lambda_handler = "index.handler"
18
+ lambda_timeout = {% if environment == "prod" %}60{% else %}30{% endif %}
19
+
20
+ lambda_memory_size = {% if environment == "prod" %}512{% else %}256{% endif %}
21
+
22
+ lambda_deploy_in_vpc = {{ (environment == "prod") | tf_bool }}
23
+ {% endif %}
24
+
25
+ {% if "apigateway" in services %}
26
+ apigw_endpoint_type = "REGIONAL"
27
+ apigw_throttle_burst_limit = {% if environment == "prod" %}500{% else %}100{% endif %}
28
+
29
+ apigw_throttle_rate_limit = {% if environment == "prod" %}200{% else %}50{% endif %}
30
+
31
+ apigw_enable_cors = true
32
+ {% endif %}
33
+
34
+ {% if "database" in services %}
35
+ ### MUST EDIT THIS ###
36
+ db_username = "dbadmin"
37
+ {% endif %}
38
+
39
+ {% if "monitoring" in services %}
40
+ ### MUST EDIT THIS ###
41
+ alarm_email = "alerts@example.com"
42
+ {% endif %}
43
+
44
+ {% if "messaging" in services %}
45
+ sqs_message_retention = {% if environment == "prod" %}1209600{% else %}345600{% endif %}
46
+
47
+ sqs_visibility_timeout = 30
48
+ {% endif %}
49
+
50
+ {% if "storage" in services %}
51
+ s3_enable_versioning = {{ (environment == "prod") | tf_bool }}
52
+ {% endif %}
@@ -0,0 +1,127 @@
1
+ # ---------------------------------------------------------------------------------------------------------------------
2
+ # ENVIRONMENT VARIABLES: {{ environment | upper }}
3
+ # Project: {{ project_name }}
4
+ # Generated by tf-starter
5
+ # ---------------------------------------------------------------------------------------------------------------------
6
+
7
+ variable "vpc_cidr" {
8
+ description = "CIDR block for the VPC"
9
+ type = string
10
+ }
11
+
12
+ variable "public_subnet_cidrs" {
13
+ description = "CIDR blocks for public subnets"
14
+ type = list(string)
15
+ }
16
+
17
+ variable "private_subnet_cidrs" {
18
+ description = "CIDR blocks for private subnets"
19
+ type = list(string)
20
+ }
21
+
22
+ variable "availability_zones" {
23
+ description = "Availability zones"
24
+ type = list(string)
25
+ }
26
+
27
+ {% if "lambda" in services %}
28
+ variable "lambda_function_name" {
29
+ description = "Short name for the Lambda function"
30
+ type = string
31
+ default = "app"
32
+ }
33
+
34
+ variable "lambda_runtime" {
35
+ description = "Lambda runtime"
36
+ type = string
37
+ default = "python3.12"
38
+ }
39
+
40
+ variable "lambda_handler" {
41
+ description = "Lambda handler"
42
+ type = string
43
+ default = "index.handler"
44
+ }
45
+
46
+ variable "lambda_timeout" {
47
+ description = "Lambda timeout in seconds"
48
+ type = number
49
+ default = 30
50
+ }
51
+
52
+ variable "lambda_memory_size" {
53
+ description = "Lambda memory in MB"
54
+ type = number
55
+ default = 256
56
+ }
57
+
58
+ variable "lambda_deploy_in_vpc" {
59
+ description = "Deploy Lambda in VPC"
60
+ type = bool
61
+ default = false
62
+ }
63
+ {% endif %}
64
+
65
+ {% if "apigateway" in services %}
66
+ variable "apigw_endpoint_type" {
67
+ description = "API Gateway endpoint type"
68
+ type = string
69
+ default = "REGIONAL"
70
+ }
71
+
72
+ variable "apigw_throttle_burst_limit" {
73
+ description = "API Gateway throttle burst limit"
74
+ type = number
75
+ default = 100
76
+ }
77
+
78
+ variable "apigw_throttle_rate_limit" {
79
+ description = "API Gateway throttle rate limit"
80
+ type = number
81
+ default = 50
82
+ }
83
+
84
+ variable "apigw_enable_cors" {
85
+ description = "Enable CORS on the API"
86
+ type = bool
87
+ default = true
88
+ }
89
+ {% endif %}
90
+
91
+ {% if "database" in services %}
92
+ variable "db_username" {
93
+ description = "Database master username"
94
+ type = string
95
+ sensitive = true
96
+ }
97
+ {% endif %}
98
+
99
+ {% if "monitoring" in services %}
100
+ variable "alarm_email" {
101
+ description = "Email for alarm notifications"
102
+ type = string
103
+ default = ""
104
+ }
105
+ {% endif %}
106
+
107
+ {% if "messaging" in services %}
108
+ variable "sqs_message_retention" {
109
+ description = "SQS message retention in seconds"
110
+ type = number
111
+ default = 345600
112
+ }
113
+
114
+ variable "sqs_visibility_timeout" {
115
+ description = "SQS visibility timeout in seconds"
116
+ type = number
117
+ default = 30
118
+ }
119
+ {% endif %}
120
+
121
+ {% if "storage" in services %}
122
+ variable "s3_enable_versioning" {
123
+ description = "Enable S3 bucket versioning"
124
+ type = bool
125
+ default = true
126
+ }
127
+ {% endif %}
@@ -0,0 +1,133 @@
1
+ # ---------------------------------------------------------------------------------------------------------------------
2
+ # GitHub Actions — Terraform CI/CD
3
+ # Project: {{ project_name }}
4
+ # Generated by tf-starter
5
+ # ---------------------------------------------------------------------------------------------------------------------
6
+
7
+ name: "Terraform"
8
+
9
+ on:
10
+ push:
11
+ branches:
12
+ - main
13
+ - develop
14
+ pull_request:
15
+ branches:
16
+ - main
17
+
18
+ permissions:
19
+ contents: read
20
+ pull-requests: write
21
+
22
+ env:
23
+ TF_LOG: INFO
24
+ {% if provider == "aws" %}
25
+ AWS_REGION: {{ region }}
26
+ {% elif provider == "gcp" %}
27
+ GCP_REGION: {{ region }}
28
+ {% elif provider == "azure" %}
29
+ ARM_LOCATION: {{ region }}
30
+ {% endif %}
31
+
32
+ jobs:
33
+ terraform-fmt:
34
+ name: "Terraform Format"
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - name: Checkout
38
+ uses: actions/checkout@v4
39
+
40
+ - name: Setup Terraform
41
+ uses: hashicorp/setup-terraform@v3
42
+ with:
43
+ terraform_version: "1.6.0"
44
+
45
+ - name: Terraform Format Check
46
+ run: terraform fmt -check -recursive -diff
47
+
48
+ terraform-validate:
49
+ name: "Terraform Validate"
50
+ runs-on: ubuntu-latest
51
+ needs: terraform-fmt
52
+ strategy:
53
+ matrix:
54
+ environment: {{ environments | tf_list }}
55
+ steps:
56
+ - name: Checkout
57
+ uses: actions/checkout@v4
58
+
59
+ - name: Setup Terraform
60
+ uses: hashicorp/setup-terraform@v3
61
+ with:
62
+ terraform_version: "1.6.0"
63
+
64
+ - name: Terraform Init
65
+ working-directory: environments/${{ '{{' }} matrix.environment {{ '}}' }}
66
+ run: terraform init -backend=false
67
+
68
+ - name: Terraform Validate
69
+ working-directory: environments/${{ '{{' }} matrix.environment {{ '}}' }}
70
+ run: terraform validate
71
+
72
+ terraform-lint:
73
+ name: "TFLint"
74
+ runs-on: ubuntu-latest
75
+ needs: terraform-fmt
76
+ steps:
77
+ - name: Checkout
78
+ uses: actions/checkout@v4
79
+
80
+ - name: Setup TFLint
81
+ uses: terraform-linters/setup-tflint@v4
82
+ with:
83
+ tflint_version: latest
84
+
85
+ - name: Init TFLint
86
+ run: tflint --init
87
+
88
+ - name: Run TFLint
89
+ run: tflint --recursive --format compact
90
+
91
+ terraform-plan:
92
+ name: "Terraform Plan"
93
+ runs-on: ubuntu-latest
94
+ needs: [terraform-validate, terraform-lint]
95
+ if: github.event_name == 'pull_request'
96
+ strategy:
97
+ matrix:
98
+ environment: {{ environments | tf_list }}
99
+ {% if provider == "aws" %}
100
+ env:
101
+ ### MUST EDIT THIS ###
102
+ # Configure AWS credentials via GitHub Secrets
103
+ AWS_ACCESS_KEY_ID: ${{ '{{' }} secrets.AWS_ACCESS_KEY_ID {{ '}}' }}
104
+ AWS_SECRET_ACCESS_KEY: ${{ '{{' }} secrets.AWS_SECRET_ACCESS_KEY {{ '}}' }}
105
+ {% elif provider == "gcp" %}
106
+ env:
107
+ ### MUST EDIT THIS ###
108
+ GOOGLE_CREDENTIALS: ${{ '{{' }} secrets.GCP_CREDENTIALS {{ '}}' }}
109
+ {% elif provider == "azure" %}
110
+ env:
111
+ ### MUST EDIT THIS ###
112
+ ARM_CLIENT_ID: ${{ '{{' }} secrets.ARM_CLIENT_ID {{ '}}' }}
113
+ ARM_CLIENT_SECRET: ${{ '{{' }} secrets.ARM_CLIENT_SECRET {{ '}}' }}
114
+ ARM_SUBSCRIPTION_ID: ${{ '{{' }} secrets.ARM_SUBSCRIPTION_ID {{ '}}' }}
115
+ ARM_TENANT_ID: ${{ '{{' }} secrets.ARM_TENANT_ID {{ '}}' }}
116
+ {% endif %}
117
+ steps:
118
+ - name: Checkout
119
+ uses: actions/checkout@v4
120
+
121
+ - name: Setup Terraform
122
+ uses: hashicorp/setup-terraform@v3
123
+ with:
124
+ terraform_version: "1.6.0"
125
+
126
+ - name: Terraform Init
127
+ working-directory: environments/${{ '{{' }} matrix.environment {{ '}}' }}
128
+ run: terraform init
129
+
130
+ - name: Terraform Plan
131
+ working-directory: environments/${{ '{{' }} matrix.environment {{ '}}' }}
132
+ run: terraform plan -var-file=terraform.tfvars -no-color
133
+ continue-on-error: true
@@ -0,0 +1,60 @@
1
+ # ---------------------------------------------------------------------------------------------------------------------
2
+ # Makefile for {{ project_name }}
3
+ # Provider: {{ provider | upper }}
4
+ # Generated by tf-starter
5
+ # ---------------------------------------------------------------------------------------------------------------------
6
+
7
+ .PHONY: init plan apply destroy validate fmt clean help
8
+
9
+ ENV ?= dev
10
+ TF_DIR = environments/$(ENV)
11
+
12
+ help: ## Show this help
13
+ @grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | \
14
+ awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-15s\033[0m %s\n", $$1, $$2}'
15
+
16
+ init: ## Initialize Terraform (ENV=dev|staging|prod)
17
+ @echo "Initializing Terraform for environment: $(ENV)"
18
+ cd $(TF_DIR) && terraform init
19
+
20
+ plan: ## Show execution plan (ENV=dev|staging|prod)
21
+ @echo "Planning Terraform for environment: $(ENV)"
22
+ cd $(TF_DIR) && terraform plan -var-file=terraform.tfvars
23
+
24
+ apply: ## Apply infrastructure changes (ENV=dev|staging|prod)
25
+ @echo "Applying Terraform for environment: $(ENV)"
26
+ cd $(TF_DIR) && terraform apply -var-file=terraform.tfvars
27
+
28
+ destroy: ## Destroy infrastructure (ENV=dev|staging|prod)
29
+ @echo "WARNING: Destroying infrastructure for environment: $(ENV)"
30
+ cd $(TF_DIR) && terraform destroy -var-file=terraform.tfvars
31
+
32
+ validate: ## Validate Terraform configuration
33
+ @echo "Validating Terraform configuration..."
34
+ terraform fmt -check -recursive
35
+ @for dir in environments/*/; do \
36
+ echo "Validating $$dir..."; \
37
+ cd $$dir && terraform init -backend=false > /dev/null 2>&1 && terraform validate && cd ../..; \
38
+ done
39
+ @echo "All configurations valid."
40
+
41
+ fmt: ## Format Terraform files
42
+ @echo "Formatting Terraform files..."
43
+ terraform fmt -recursive
44
+ @echo "Done."
45
+
46
+ clean: ## Remove .terraform directories and lock files
47
+ @echo "Cleaning Terraform cache..."
48
+ find . -type d -name ".terraform" -exec rm -rf {} + 2>/dev/null || true
49
+ find . -name ".terraform.lock.hcl" -delete 2>/dev/null || true
50
+ @echo "Done."
51
+
52
+ output: ## Show Terraform outputs (ENV=dev|staging|prod)
53
+ cd $(TF_DIR) && terraform output
54
+
55
+ state-list: ## List resources in state (ENV=dev|staging|prod)
56
+ cd $(TF_DIR) && terraform state list
57
+
58
+ cost: ## Estimate cost using infracost (requires infracost CLI)
59
+ @command -v infracost >/dev/null 2>&1 || { echo "infracost not installed"; exit 1; }
60
+ cd $(TF_DIR) && infracost breakdown --path .