diff --git a/.github/workflows/deploy_push.yml b/.github/workflows/deploy_push.yml index b6ffe1a..cdc1e80 100644 --- a/.github/workflows/deploy_push.yml +++ b/.github/workflows/deploy_push.yml @@ -3,6 +3,7 @@ on: push: paths: - 'infra/api/**.py' + - 'infra/**.tf' - 'html/**' - '.github/workflows/deploy_push.yml' - 'requirements.txt' @@ -114,6 +115,11 @@ jobs: run: | cd infra tfcmt apply -- terraform apply -auto-approve -no-color + if [ "$(terraform workspace show)" == "default" ]; then + echo "Deleting aws_lambda_function.scan resource as workspace is default" + terraform destroy --target aws_lambda_function.scan + terraform destroy --target aws_cloudwatch_event_target.target + fi - name: Website URL id: websiteUrl run: | diff --git a/infra/main.tf b/infra/main.tf index 2078175..e465dd9 100644 --- a/infra/main.tf +++ b/infra/main.tf @@ -228,7 +228,6 @@ resource "aws_lambda_function" "lambda" { } resource "aws_lambda_function" "scan" { - count = terraform.workspace == "mtchoun-mouh-master" ? 1 : 0 filename = data.archive_file.lambda_zip.output_path function_name = (terraform.workspace == "mtchoun-mouh-master") ? "scan_user_consulcam" : "${terraform.workspace}-scan_user_consulcam" role = data.aws_iam_role.role.arn