Skip to content

Commit

Permalink
refactor: use aws_s3_object instead of aws_s3_bucket_object
Browse files Browse the repository at this point in the history
  • Loading branch information
gjclark committed Jun 11, 2024
1 parent ab12fb0 commit dd1e82e
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions terraform/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ resource "aws_s3_bucket" "lambda_source" {
tags = merge(var.tags, { DAR = "YES" })
}

resource "aws_s3_bucket_object" "lambda_source" {
resource "aws_s3_object" "lambda_source" {
bucket = aws_s3_bucket.lambda_source.bucket
key = "${filemd5(local.lambda_source_filename)}.zip"
source = local.lambda_source_filename
etag = filemd5(local.lambda_source_filename)
}

resource "aws_s3_bucket_object" "lambda_code_dependency_archive" {
resource "aws_s3_object" "lambda_code_dependency_archive" {
bucket = aws_s3_bucket.lambda_source.bucket
key = "${filemd5(local.dependency_layer_filename)}.zip"
source = local.dependency_layer_filename
etag = filemd5(local.dependency_layer_filename)
}

resource "aws_s3_bucket_object" "cloudformation_template" {
resource "aws_s3_object" "cloudformation_template" {
bucket = aws_s3_bucket.lambda_source.bucket
key = "${filemd5(local.cloudformation_template_filename)}.yaml"
source = local.cloudformation_template_filename
Expand All @@ -45,12 +45,12 @@ resource "aws_s3_bucket_object" "cloudformation_template" {

resource "aws_cloudformation_stack" "thin_egress_app" {
depends_on = [
aws_s3_bucket_object.lambda_source,
aws_s3_bucket_object.lambda_code_dependency_archive,
aws_s3_bucket_object.cloudformation_template
aws_s3_object.lambda_source,
aws_s3_object.lambda_code_dependency_archive,
aws_s3_object.cloudformation_template
]
name = substr(var.stack_name, 0, 36)
template_url = "https://s3.amazonaws.com/${aws_s3_bucket_object.lambda_source.bucket}/${aws_s3_bucket_object.cloudformation_template.key}"
template_url = "https://s3.amazonaws.com/${aws_s3_object.lambda_source.bucket}/${aws_s3_object.cloudformation_template.key}"
capabilities = ["CAPABILITY_NAMED_IAM"]
parameters = {
AuthBaseUrl = var.auth_base_url
Expand All @@ -67,9 +67,9 @@ resource "aws_cloudformation_stack" "thin_egress_app" {
HtmlTemplateDir = var.html_template_dir
JwtAlgo = var.jwt_algo
JwtKeySecretName = var.jwt_secret_name
LambdaCodeDependencyArchive = aws_s3_bucket_object.lambda_code_dependency_archive.key
LambdaCodeS3Bucket = aws_s3_bucket_object.lambda_source.bucket
LambdaCodeS3Key = aws_s3_bucket_object.lambda_source.key
LambdaCodeDependencyArchive = aws_s3_object.lambda_code_dependency_archive.key
LambdaCodeS3Bucket = aws_s3_object.lambda_source.bucket
LambdaCodeS3Key = aws_s3_object.lambda_source.key
LambdaTimeout = var.lambda_timeout
LambdaMemory = var.lambda_memory
Loglevel = var.log_level
Expand Down

0 comments on commit dd1e82e

Please sign in to comment.