File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ terraform {
2+ required_version = " >= 1.0"
3+
4+ required_providers {
5+ aws = {
6+ source = " hashicorp/aws"
7+ version = " ~> 5.0"
8+ }
9+ }
10+
11+ backend "s3" {
12+ bucket = var. terraform_backend_bucket
13+ key = " ${ var . project_name } /${ var . environment } /tfstate"
14+ region = var. aws_region
15+ }
16+ }
17+
18+ provider "aws" {
19+ region = var. aws_region
20+
21+ default_tags {
22+ tags = local. common_tags
23+ }
24+ }
25+
26+ locals {
27+ common_tags = {
28+ Environment = var.environment
29+ Project = var.project_name
30+ ManagedBy = " Terraform"
31+ CreatedAt = timestamp ()
32+ }
33+ }
Original file line number Diff line number Diff line change @@ -2,4 +2,30 @@ variable "aws_region" {
22 default = " us-east-1"
33 description = " AWS region"
44 type = string
5+ }
6+
7+ variable "terraform_backend_bucket" {
8+ default = " "
9+ description = " AWS Bucket for Terraform backend"
10+ type = string
11+ }
12+
13+ variable "environment" {
14+ validation {
15+ condition = contains ([" staging" , " prod" ], var. environment )
16+ error_message = " Environment must be either staging or prod"
17+ }
18+ description = " Deployment environment name (staging or prod)"
19+ type = string
20+ }
21+
22+ variable "lambda_funtion_dir" {
23+ default = " ../lambda"
24+ description = " Directory containing Lambda function source code"
25+ type = string
26+ }
27+ variable "project_name" {
28+ default = " serverless-health-check-api"
29+ description = " Project name for tagging and resource naming"
30+ type = string
531}
You can’t perform that action at this time.
0 commit comments