From d2c99ef1f69b07d799a7da7a0d36e9596d626761 Mon Sep 17 00:00:00 2001 From: Frank Greguska <89428916+frankinspace@users.noreply.github.com> Date: Thu, 19 Oct 2023 18:34:54 -0700 Subject: [PATCH] building tf module --- .github/workflows/cicd-pipeline.yml | 8 ++- examples/cumulus-tf/.terraform.lock.hcl | 45 ++++++++++++++++ terraform/.terraform.lock.hcl | 45 ++++++++++++++++ terraform/lambda_functions.tf | 72 ++++++++++++++++--------- 4 files changed, 143 insertions(+), 27 deletions(-) create mode 100644 examples/cumulus-tf/.terraform.lock.hcl create mode 100644 terraform/.terraform.lock.hcl diff --git a/.github/workflows/cicd-pipeline.yml b/.github/workflows/cicd-pipeline.yml index 27b8ff3..863f821 100644 --- a/.github/workflows/cicd-pipeline.yml +++ b/.github/workflows/cicd-pipeline.yml @@ -128,7 +128,9 @@ jobs: terraform_wrapper: false - name: Validate Terraform working-directory: terraform - run: terraform validate -no-color + run: | + terraform init -backend=false + terraform validate -no-color - name: SonarCloud Scan uses: sonarsource/sonarcloud-github-action@master env: @@ -268,7 +270,9 @@ jobs: - name: Validate Terraform working-directory: examples/cumulus-tf - run: terraform validate -no-color + run: | + terraform init -backend=false + terraform validate -no-color - name: Deploy to venue id: terraform-deploy diff --git a/examples/cumulus-tf/.terraform.lock.hcl b/examples/cumulus-tf/.terraform.lock.hcl new file mode 100644 index 0000000..5e48231 --- /dev/null +++ b/examples/cumulus-tf/.terraform.lock.hcl @@ -0,0 +1,45 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.22.0" + constraints = ">= 2.31.0, >= 3.0.0, != 3.14.0" + hashes = [ + "h1:4oAjE3Fn/vXruaORPWH1lH7q/+oPEqxNm6+KjOMeMrI=", + "zh:09b8475cd519c945423b1e1183b71a4209dd2927e0d289a88c5abeecb53c1753", + "zh:2448e0c3ce9b991a5dd70f6a42d842366a6a2460cf63b31fb9bc5d2cc92ced19", + "zh:3b9fc2bf6714a9a9ab25eae3e56cead3d3917bc1b6d8b9fb3111c4198a790c72", + "zh:4fbd28ad5380529a36c54d7a96c9768df1288c625d28b8fa3a50d4fc2176ef0f", + "zh:54d550f190702a7edc2d459952d025e259a8c0b0ff7df3f15bbcc148539214bf", + "zh:638f406d084ac96f3a0b0a5ce8aa71a5a2a781a56ba96e3a235d3982b89eef0d", + "zh:69d4c175b13b6916b5c9398172cc384e7af46cb737b45870ab9907f12e82a28a", + "zh:81edec181a67255d25caf5e7ffe6d5e8f9373849b9e8f5e0705f277640abb18e", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a66efb2b3cf7be8116728ae5782d7550f23f3719da2ed3c10228d29c44b7dc84", + "zh:ae754478d0bfa42195d16cf46091fab7c1c075ebc965d919338e36aed45add78", + "zh:e0603ad0061c43aa1cb52740b1e700b8afb55667d7ee01c1cc1ceb6f983d4c9d", + "zh:e4cb701d0185884eed0492a66eff17251f5b4971d30e81acd5e0a55627059fc8", + "zh:f7db2fcf69679925dde1ae326526242fd61ba1f83f614b1f6d9d68c925417e51", + "zh:fef331b9b62bc26d900ae937cc662281ff30794edf48aebfe8997d0e16835f6d", + ] +} + +provider "registry.terraform.io/hashicorp/null" { + version = "2.1.2" + constraints = "~> 2.1" + hashes = [ + "h1:l0/ASa/TB1exgqdi33sOkFakJL2zAQBu+q5LgO5/SxI=", + "zh:0cc7236c1fbf971b8bad1540a7d0c5ac4579248239fd1034c023b0b660a8d1d5", + "zh:16fc2d9b10cf9e5123bf956e7032c338cc93a03be1ca2e9f3d3b7014c0e866c7", + "zh:1e26465ff40ded59cef1a9e745752eef9744471e69094d12f8bc40a060e8cdb9", + "zh:3c7afd28076245f455d4348af6c124b73409722be4a73680d4e4709a4f25ea91", + "zh:4190a92567efaa444527f19b28d65fac1a01aeba907013b5dceacd9ba2a23709", + "zh:677963437316b088fc1aac70fe7d608d2917c46530c4a25ec86a43e9acaf2811", + "zh:69fe15f6b851ff82700bc749c50a9299770515617e677c18cba2cb697daaff36", + "zh:6b505cc60cc1494e1cab61590bca127b06dd894d0b2a7dcacd23862bce1f492b", + "zh:719aa11ad7be974085af595089478eb24d5a021bc7b08364fa6745d9eb473dac", + "zh:7375b02189e14efbfaab994cd05d81e3ff8e46041fae778598b3903114093a3e", + "zh:c406573b2084a08f8faa0451923fbeb1ca6c5a5598bf039589ec2db13aacc622", + "zh:fb11299a3b20711595713d126abbbe78c554eb5995b02db536e9253686798fb6", + ] +} diff --git a/terraform/.terraform.lock.hcl b/terraform/.terraform.lock.hcl new file mode 100644 index 0000000..49cdad1 --- /dev/null +++ b/terraform/.terraform.lock.hcl @@ -0,0 +1,45 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "5.22.0" + constraints = ">= 3.0.0, != 3.14.0" + hashes = [ + "h1:4oAjE3Fn/vXruaORPWH1lH7q/+oPEqxNm6+KjOMeMrI=", + "zh:09b8475cd519c945423b1e1183b71a4209dd2927e0d289a88c5abeecb53c1753", + "zh:2448e0c3ce9b991a5dd70f6a42d842366a6a2460cf63b31fb9bc5d2cc92ced19", + "zh:3b9fc2bf6714a9a9ab25eae3e56cead3d3917bc1b6d8b9fb3111c4198a790c72", + "zh:4fbd28ad5380529a36c54d7a96c9768df1288c625d28b8fa3a50d4fc2176ef0f", + "zh:54d550f190702a7edc2d459952d025e259a8c0b0ff7df3f15bbcc148539214bf", + "zh:638f406d084ac96f3a0b0a5ce8aa71a5a2a781a56ba96e3a235d3982b89eef0d", + "zh:69d4c175b13b6916b5c9398172cc384e7af46cb737b45870ab9907f12e82a28a", + "zh:81edec181a67255d25caf5e7ffe6d5e8f9373849b9e8f5e0705f277640abb18e", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:a66efb2b3cf7be8116728ae5782d7550f23f3719da2ed3c10228d29c44b7dc84", + "zh:ae754478d0bfa42195d16cf46091fab7c1c075ebc965d919338e36aed45add78", + "zh:e0603ad0061c43aa1cb52740b1e700b8afb55667d7ee01c1cc1ceb6f983d4c9d", + "zh:e4cb701d0185884eed0492a66eff17251f5b4971d30e81acd5e0a55627059fc8", + "zh:f7db2fcf69679925dde1ae326526242fd61ba1f83f614b1f6d9d68c925417e51", + "zh:fef331b9b62bc26d900ae937cc662281ff30794edf48aebfe8997d0e16835f6d", + ] +} + +provider "registry.terraform.io/hashicorp/null" { + version = "2.1.2" + constraints = "~> 2.1" + hashes = [ + "h1:l0/ASa/TB1exgqdi33sOkFakJL2zAQBu+q5LgO5/SxI=", + "zh:0cc7236c1fbf971b8bad1540a7d0c5ac4579248239fd1034c023b0b660a8d1d5", + "zh:16fc2d9b10cf9e5123bf956e7032c338cc93a03be1ca2e9f3d3b7014c0e866c7", + "zh:1e26465ff40ded59cef1a9e745752eef9744471e69094d12f8bc40a060e8cdb9", + "zh:3c7afd28076245f455d4348af6c124b73409722be4a73680d4e4709a4f25ea91", + "zh:4190a92567efaa444527f19b28d65fac1a01aeba907013b5dceacd9ba2a23709", + "zh:677963437316b088fc1aac70fe7d608d2917c46530c4a25ec86a43e9acaf2811", + "zh:69fe15f6b851ff82700bc749c50a9299770515617e677c18cba2cb697daaff36", + "zh:6b505cc60cc1494e1cab61590bca127b06dd894d0b2a7dcacd23862bce1f492b", + "zh:719aa11ad7be974085af595089478eb24d5a021bc7b08364fa6745d9eb473dac", + "zh:7375b02189e14efbfaab994cd05d81e3ff8e46041fae778598b3903114093a3e", + "zh:c406573b2084a08f8faa0451923fbeb1ca6c5a5598bf039589ec2db13aacc622", + "zh:fb11299a3b20711595713d126abbbe78c554eb5995b02db536e9253686798fb6", + ] +} diff --git a/terraform/lambda_functions.tf b/terraform/lambda_functions.tf index a551ec2..1680668 100644 --- a/terraform/lambda_functions.tf +++ b/terraform/lambda_functions.tf @@ -65,7 +65,7 @@ resource "aws_lambda_function" "get_dataset_configuration" { package_type = "Image" image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" image_config { - command = ["podaac.big.get_dataset_configuration.lambda_handler"] + command = ["bignbit.get_dataset_configuration.lambda_handler"] } function_name = "${local.lambda_resources_name}-get_dataset_configuration-lambda" role = var.lambda_role.arn @@ -96,7 +96,7 @@ resource "aws_lambda_function" "get_granule_umm_json" { package_type = "Image" image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" image_config { - command = ["podaac.big.get_granule_umm_json.lambda_handler"] + command = ["bignbit.get_granule_umm_json.lambda_handler"] } function_name = "${local.lambda_resources_name}-get_granule_umm_json-lambda" role = var.lambda_role.arn @@ -129,7 +129,7 @@ resource "aws_lambda_function" "get_collection_concept_id" { package_type = "Image" image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" image_config { - command = ["podaac.big.get_collection_concept_id.lambda_handler"] + command = ["bignbit.get_collection_concept_id.lambda_handler"] } function_name = "${local.lambda_resources_name}-get_collection_concept_id-lambda" role = var.lambda_role.arn @@ -162,7 +162,7 @@ resource "aws_lambda_function" "identify_image_file" { package_type = "Image" image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" image_config { - command = ["podaac.big.identify_image_file.lambda_handler"] + command = ["bignbit.identify_image_file.lambda_handler"] } function_name = "${local.lambda_resources_name}-identify_image_file-lambda" role = var.lambda_role.arn @@ -193,7 +193,7 @@ resource "aws_lambda_function" "submit_harmony_job" { package_type = "Image" image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" image_config { - command = ["podaac.big.submit_harmony_job.lambda_handler"] + command = ["bignbit.submit_harmony_job.lambda_handler"] } function_name = "${local.lambda_resources_name}-submit_harmony_job-lambda" role = var.lambda_role.arn @@ -226,7 +226,7 @@ resource "aws_lambda_function" "generate_image_metadata" { package_type = "Image" image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" image_config { - command = ["podaac.big.generate_image_metadata.lambda_handler"] + command = ["bignbit.generate_image_metadata.lambda_handler"] } function_name = "${local.lambda_resources_name}-generate_image_metadata-lambda" role = var.lambda_role.arn @@ -257,7 +257,7 @@ resource "aws_lambda_function" "get_harmony_job_status" { package_type = "Image" image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" image_config { - command = ["podaac.big.get_harmony_job_status.lambda_handler"] + command = ["bignbit.get_harmony_job_status.lambda_handler"] } function_name = "${local.lambda_resources_name}-get_harmony_job_status-lambda" role = var.lambda_role.arn @@ -290,7 +290,7 @@ resource "aws_lambda_function" "copy_harmony_results_to_s3" { package_type = "Image" image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" image_config { - command = ["podaac.big.copy_harmony_results_to_s3.lambda_handler"] + command = ["bignbit.copy_harmony_results_to_s3.lambda_handler"] } function_name = "${local.lambda_resources_name}-copy_harmony_results_to_s3-lambda" role = var.lambda_role.arn @@ -323,7 +323,7 @@ resource "aws_lambda_function" "apply_opera_treatment" { package_type = "Image" image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" image_config { - command = ["podaac.big.apply_opera_treatment.lambda_handler"] + command = ["bignbit.apply_opera_treatment.lambda_handler"] } function_name = "${local.lambda_resources_name}-apply_opera_treatment-lambda" role = var.lambda_role.arn @@ -350,12 +350,19 @@ resource "aws_lambda_function" "apply_opera_treatment" { resource "aws_lambda_function" "build_image_sets" { - filename = "${path.module}/bignbit-lambda.zip" + + depends_on = [ + null_resource.upload_ecr_image + ] + + package_type = "Image" + image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" + image_config { + command = ["bignbit.build_image_sets.lambda_handler"] + } + function_name = local.build_image_sets_function_name - source_code_hash = filebase64sha256("${path.module}/bignbit-lambda.zip") - handler = "podaac.pobit.build_image_sets.lambda_handler" role = var.lambda_role.arn - runtime = "python3.8" timeout = 15 memory_size = 128 @@ -378,12 +385,17 @@ resource "aws_lambda_function" "build_image_sets" { } resource "aws_lambda_function" "send_to_gitc" { - filename = "${path.module}/bignbit-lambda.zip" + depends_on = [ + null_resource.upload_ecr_image + ] + + package_type = "Image" + image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" + image_config { + command = ["bignbit.send_to_gitc.lambda_handler"] + } function_name = "${local.lambda_resources_name}-send_to_gitc-lambda" - source_code_hash = filebase64sha256("${path.module}/bignbit-lambda.zip") - handler = "podaac.pobit.send_to_gitc.lambda_handler" role = var.lambda_role.arn - runtime = "python3.8" timeout = 15 memory_size = 128 @@ -407,12 +419,17 @@ resource "aws_lambda_function" "send_to_gitc" { resource "aws_lambda_function" "handle_gitc_response" { - filename = "${path.module}/bignbit-lambda.zip" + depends_on = [ + null_resource.upload_ecr_image + ] + + package_type = "Image" + image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" + image_config { + command = ["bignbit.handle_gitc_response.handler"] + } function_name = "${local.lambda_resources_name}-handle_gitc_response-lambda" - source_code_hash = filebase64sha256("${path.module}/bignbit-lambda.zip") - handler = "podaac.pobit.handle_gitc_response.handler" role = var.lambda_role.arn - runtime = "python3.8" timeout = 5 memory_size = 128 @@ -433,12 +450,17 @@ resource "aws_lambda_function" "handle_gitc_response" { } resource "aws_lambda_function" "save_cma_message" { - filename = "${path.module}/bignbit-lambda.zip" + depends_on = [ + null_resource.upload_ecr_image + ] + + package_type = "Image" + image_uri = "${aws_ecr_repository.lambda-image-repo.repository_url}:${local.ecr_image_tag}" + image_config { + command = ["bignbit.save_cma_message.lambda_handler"] + } function_name = "${local.lambda_resources_name}-save_cma_message-lambda" - source_code_hash = filebase64sha256("${path.module}/bignbit-lambda.zip") - handler = "podaac.pobit.save_cma_message.lambda_handler" role = var.lambda_role.arn - runtime = "python3.8" timeout = 5 memory_size = 128