mirror of
https://github.com/Hestia-Homes/Model.git
synced 2026-06-08 11:17:27 +00:00
upload zip to s3 rather than copying via api
This commit is contained in:
parent
d45958843b
commit
c58cfee0b6
6 changed files with 26 additions and 12 deletions
|
|
@ -82,6 +82,7 @@ module "fastapi" {
|
|||
runtime = "python3.11"
|
||||
timeout = 600
|
||||
memory_size = 512
|
||||
artifact_bucket = data.terraform_remote_state.shared.outputs.ara_fast_api_state_bucket
|
||||
|
||||
# domain_name = "api.${var.domain_name}"
|
||||
# certificate_arn = data.aws_ssm_parameter.certificate_arn.value
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ resource "aws_lambda_function" "this" {
|
|||
function_name = var.name
|
||||
role = var.role_arn
|
||||
package_type = "Zip"
|
||||
filename = var.filename
|
||||
# filename = var.filename
|
||||
source_code_hash = var.source_code_hash
|
||||
handler = var.handler
|
||||
runtime = var.runtime
|
||||
|
|
@ -10,6 +10,10 @@ resource "aws_lambda_function" "this" {
|
|||
memory_size = var.memory_size
|
||||
publish = true
|
||||
|
||||
s3_bucket = var.s3_bucket
|
||||
s3_key = var.s3_key
|
||||
source_code_hash = var.source_code_hash
|
||||
|
||||
environment {
|
||||
variables = var.environment
|
||||
}
|
||||
|
|
@ -21,4 +25,4 @@ output "lambda_arn" {
|
|||
|
||||
output "function_name" {
|
||||
value = aws_lambda_function.this.function_name
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
variable "name" { type = string }
|
||||
variable "role_arn" { type = string }
|
||||
variable "filename" { type = string }
|
||||
# variable "filename" { type = string }
|
||||
variable "source_code_hash" { type = string }
|
||||
variable "handler" { type = string }
|
||||
variable "runtime" { type = string }
|
||||
|
|
@ -15,4 +15,7 @@ variable "memory_size" {
|
|||
variable "environment" {
|
||||
type = map(string)
|
||||
default = {}
|
||||
}
|
||||
}
|
||||
variable "s3_bucket" { type = string }
|
||||
variable "s3_key" { type = string }
|
||||
variable "source_code_hash" { type = string }
|
||||
|
|
@ -16,6 +16,16 @@ data "archive_file" "this" {
|
|||
excludes = var.zip_excludes
|
||||
}
|
||||
|
||||
############################################
|
||||
# Upload zip to S3
|
||||
############################################
|
||||
resource "aws_s3_object" "lambda_zip" {
|
||||
bucket = var.artifact_bucket
|
||||
key = "${var.name}-${var.stage}.zip"
|
||||
source = data.archive_file.this.output_path
|
||||
etag = data.archive_file.this.output_md5
|
||||
}
|
||||
|
||||
############################################
|
||||
# Lambda
|
||||
############################################
|
||||
|
|
@ -24,7 +34,8 @@ module "lambda" {
|
|||
|
||||
name = "${var.name}-${var.stage}"
|
||||
role_arn = module.role.role_arn
|
||||
filename = data.archive_file.this.output_path
|
||||
s3_bucket = var.artifact_bucket
|
||||
s3_key = aws_s3_object.lambda_zip.key
|
||||
source_code_hash = data.archive_file.this.output_base64sha256
|
||||
handler = var.handler
|
||||
runtime = var.runtime
|
||||
|
|
|
|||
|
|
@ -33,4 +33,5 @@ variable "certificate_arn" {
|
|||
variable "route53_zone_id" {
|
||||
type = string
|
||||
default = null
|
||||
}
|
||||
}
|
||||
variable "artifact_bucket" { type = string }
|
||||
|
|
@ -530,12 +530,6 @@ module "ara_fast_api_state_bucket" {
|
|||
bucket_name = "ara-fast-api-terraform-state"
|
||||
}
|
||||
|
||||
module "ara_fastapi_registry" {
|
||||
source = "../modules/container_registry"
|
||||
name = "ara-fastapi"
|
||||
stage = var.stage
|
||||
}
|
||||
|
||||
# S3 policy for FastAPI app to read and write from various S3 buckets
|
||||
module "fast_api_s3_read_and_write" {
|
||||
source = "../modules/s3_iam_policy"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue