Skip to content
Prev Previous commit
Next Next commit
replace deprecated resource 'aws_s3_bucket_object' to 'aws_s3_object'
  • Loading branch information
liortct committed Mar 26, 2022
commit 562e7c7410181ad76b920bc2d3186dbad345b486
8 changes: 4 additions & 4 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ locals {
# s3_* - to get package from S3
s3_bucket = var.s3_existing_package != null ? lookup(var.s3_existing_package, "bucket", null) : (var.store_on_s3 ? var.s3_bucket : null)
s3_key = var.s3_existing_package != null ? lookup(var.s3_existing_package, "key", null) : (var.store_on_s3 ? var.s3_prefix != null ? format("%s%s", var.s3_prefix, replace(local.archive_filename_string, "/^.*//", "")) : replace(local.archive_filename_string, "/^\\.//", "") : null)
s3_object_version = var.s3_existing_package != null ? lookup(var.s3_existing_package, "version_id", null) : (var.store_on_s3 ? try(aws_s3_bucket_object.lambda_package[0].version_id, null) : null)
s3_object_version = var.s3_existing_package != null ? lookup(var.s3_existing_package, "version_id", null) : (var.store_on_s3 ? try(aws_s3_object.lambda_package[0].version_id, null) : null)

}

Expand Down Expand Up @@ -100,7 +100,7 @@ resource "aws_lambda_function" "this" {
# When a lambda function is invoked, AWS creates the log group automatically if it doesn't exist yet.
# Without the dependency, this can result in a race condition if the lambda function is invoked before
# Terraform can create the log group.
depends_on = [null_resource.archive, aws_s3_bucket_object.lambda_package, aws_cloudwatch_log_group.lambda]
depends_on = [null_resource.archive, aws_s3_object.lambda_package, aws_cloudwatch_log_group.lambda]
}

resource "aws_lambda_layer_version" "this" {
Expand All @@ -121,10 +121,10 @@ resource "aws_lambda_layer_version" "this" {
s3_key = local.s3_key
s3_object_version = local.s3_object_version

depends_on = [null_resource.archive, aws_s3_bucket_object.lambda_package]
depends_on = [null_resource.archive, aws_s3_object.lambda_package]
}

resource "aws_s3_bucket_object" "lambda_package" {
resource "aws_s3_object" "lambda_package" {
count = local.create && var.store_on_s3 && var.create_package ? 1 : 0

bucket = var.s3_bucket
Expand Down