Skip to content

Commit

Permalink
Merge pull request #821 from asfadmin/gjc/refactor/aws_s3_object
Browse files Browse the repository at this point in the history
Use aws_s3_object instead of aws_s3_bucket_object
  • Loading branch information
gjclark authored Jun 12, 2024
2 parents ab12fb0 + d0c2d3c commit 977b429
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

# Tools
.terraform
/terraform/providers.tf
terraform.tfstate*
*.tfvars
/thin_egress_app/.chalice
Expand Down
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
8 changes: 8 additions & 0 deletions terraform/providers.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 4.0"
}
}
}

0 comments on commit 977b429

Please sign in to comment.