Skip to content

Commit

Permalink
fixing stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
arnol377 committed Apr 15, 2025
1 parent 93bb7f6 commit ab365d7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
8 changes: 8 additions & 0 deletions backend.tf
Original file line number Diff line number Diff line change
@@ -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"
}
}
16 changes: 8 additions & 8 deletions main.tf
Original file line number Diff line number Diff line change
@@ -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
}

Expand Down Expand Up @@ -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 {
Expand All @@ -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" {
Expand All @@ -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"
Expand All @@ -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"
Expand All @@ -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({
Expand Down
16 changes: 16 additions & 0 deletions varfiles/sct-engineering.tfvars
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
6 changes: 6 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}

0 comments on commit ab365d7

Please sign in to comment.