Skip to content

Commit e7d9bc9

Browse files
committed
path
1 parent e591a7f commit e7d9bc9

File tree

1 file changed

+41
-1
lines changed

1 file changed

+41
-1
lines changed

terraform/id_sync_lambda.tf

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ locals {
33
lambdas_dir = abspath("${path.root}/../lambdas")
44
shared_dir = "${local.lambdas_dir}/shared"
55
id_sync_lambda_dir = "${local.lambdas_dir}/id_sync"
6+
id_sync_dockerfile = "${local.lambdas_dir}/id_sync.Dockerfile"
67

78
# Get files from both directories
89
shared_files = fileset(local.shared_dir, "**")
@@ -14,6 +15,25 @@ locals {
1415

1516
# Combined SHA to trigger rebuild when either directory changes
1617
combined_sha = sha1("${local.shared_dir_sha}${local.id_sync_lambda_dir_sha}")
18+
debug_paths = {
19+
terraform_root = path.root
20+
lambdas_dir = local.lambdas_dir
21+
id_sync_dir = local.id_sync_lambda_dir
22+
dockerfile_path = "${local.lambdas_dir}/id_sync.Dockerfile"
23+
}
24+
}
25+
26+
output "debug_docker_paths" {
27+
value = local.debug_paths
28+
}
29+
30+
# ✅ Check if files exist
31+
data "local_file" "dockerfile_check" {
32+
filename = "${local.lambdas_dir}/id_sync.Dockerfile"
33+
}
34+
35+
output "dockerfile_exists" {
36+
value = "Dockerfile found at: ${data.local_file.dockerfile_check.filename}"
1737
}
1838

1939
resource "aws_ecr_repository" "id_sync_lambda_repository" {
@@ -23,7 +43,27 @@ resource "aws_ecr_repository" "id_sync_lambda_repository" {
2343
name = "${local.short_prefix}-id-sync-repo"
2444
force_delete = local.is_temp
2545
}
46+
resource "null_resource" "validate_dockerfile" {
47+
triggers = {
48+
dockerfile_path = "${local.lambdas_dir}/id_sync.Dockerfile"
49+
}
2650

51+
provisioner "local-exec" {
52+
command = <<-EOT
53+
echo "Checking for Dockerfile at: ${local.lambdas_dir}/id_sync.Dockerfile"
54+
if [ ! -f "${local.lambdas_dir}/id_sync.Dockerfile" ]; then
55+
echo "ERROR: Dockerfile not found!"
56+
echo "Current directory: $(pwd)"
57+
echo "Looking for: ${local.lambdas_dir}/id_sync.Dockerfile"
58+
echo "Files in lambdas directory:"
59+
ls -la "${local.lambdas_dir}/" || echo "lambdas directory not found"
60+
exit 1
61+
else
62+
echo "✅ Dockerfile found!"
63+
fi
64+
EOT
65+
}
66+
}
2767
# Module for building and pushing Docker image to ECR
2868
module "id_sync_docker_image" {
2969
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
@@ -51,7 +91,7 @@ module "id_sync_docker_image" {
5191

5292
platform = "linux/amd64"
5393
use_image_tag = false
54-
source_path = local.id_sync_lambda_dir
94+
source_path = local.lambdas_dir
5595
triggers = {
5696
dir_sha = local.id_sync_lambda_dir_sha
5797
}

0 commit comments

Comments
 (0)