diff --git a/backend.tf b/backend.tf index e69de29..eba3e91 100644 --- a/backend.tf +++ b/backend.tf @@ -0,0 +1,8 @@ +terraform { + backend "s3" { + bucket = "inf-tfstate-us-gov-west-1-229685449397" + key = "csvd-dev-gov/common/apps/eks-automation/terraform.tfstate" + region = "us-gov-west-1" + dynamodb_table = "tf_remote_state" + } +} diff --git a/main.tf b/main.tf index dc080c8..91bbd24 100644 --- a/main.tf +++ b/main.tf @@ -1,6 +1,6 @@ # API Gateway resource "aws_api_gateway_rest_api" "eks_automation" { - name = "eks-automation-api" + name = var.name tags = local.common_tags } @@ -90,7 +90,7 @@ resource "aws_api_gateway_integration_response" "options" { } resource "aws_api_gateway_usage_plan" "eks_automation" { - name = "eks-automation-usage-plan" + name = "${var.name}-usage-plan" description = "Usage plan for EKS Automation API" api_stages { @@ -112,7 +112,7 @@ resource "aws_api_gateway_usage_plan" "eks_automation" { } resource "aws_api_gateway_api_key" "eks_automation" { - name = "eks-automation-api-key" + name = "${var.name}-key" } resource "aws_api_gateway_usage_plan_key" "eks_automation" { @@ -124,15 +124,15 @@ resource "aws_api_gateway_usage_plan_key" "eks_automation" { # Lambda Layer resource "aws_lambda_layer_version" "git" { filename = "layer.zip" # Make sure to create this zip file with Git binaries - layer_name = "git-lambda-layer" - description = "Git Lambda Layer" + layer_name = "${var.name}-lambda-layer" + description = "${var.name} Lambda Layer" compatible_runtimes = ["python3.9", "python3.10", "python3.11"] } # Lambda Function resource "aws_lambda_function" "eks_automation" { filename = "eks_automation.zip" # Make sure to create this zip file - function_name = "eks-automation" + function_name = "${var.name}-eks-automation" role = aws_iam_role.lambda_role.arn handler = "app.lambda_handler" runtime = "python3.11" @@ -156,7 +156,7 @@ resource "aws_lambda_function" "eks_automation" { # IAM Role for Lambda resource "aws_iam_role" "lambda_role" { - name = "eks-automation-lambda-role" + name = "${var.name}-lambda-role" assume_role_policy = jsonencode({ Version = "2012-10-17" @@ -181,7 +181,7 @@ resource "aws_iam_role_policy_attachment" "lambda_vpc_access" { } resource "aws_iam_role_policy" "lambda_ssm_access" { - name = "eks-automation-ssm-access" + name = "${var.name}-ssm-access" role = aws_iam_role.lambda_role.id policy = jsonencode({ diff --git a/varfiles/sct-engineering.tfvars b/varfiles/sct-engineering.tfvars index f710d01..3fe9e6f 100644 --- a/varfiles/sct-engineering.tfvars +++ b/varfiles/sct-engineering.tfvars @@ -1,3 +1,19 @@ +name = "eks-repo-automation" +# This file contains the variable values for the Terraform configuration. +# It is used to set up the AWS Lambda function and its associated resources. +# The values here are specific to the development environment and should be +# adjusted for production or other environments as needed. +# +# Environment variables +# These variables are used to configure the AWS Lambda function and its +# associated resources. They include the environment name, organization, +# FinOps project details, VPC security group IDs, subnet IDs, and Lambda +# timeout settings. +# The AWS region is set to "us-gov-west-1" for the development environment. +# The VPC security group IDs and subnet IDs are specific to the AWS +# infrastructure setup and should be verified before deployment. +# The Lambda timeout is set to 30 seconds, which should be sufficient for +# most operations. environment = "development" environment_abbr = "dev" organization = "census:ocio:csvd" diff --git a/variables.tf b/variables.tf index a8ea3da..dccbac5 100644 --- a/variables.tf +++ b/variables.tf @@ -47,4 +47,10 @@ variable "aws_region" { description = "AWS region" type = string default = "us-gov-west-2" +} + +variable name { + description = "Name of the resource" + type = string + default = "eks-automation" } \ No newline at end of file