Skip to content

Commit 363cf37

Browse files
committed
Path fix
1 parent 6b3d524 commit 363cf37

File tree

2 files changed

+22
-123
lines changed

2 files changed

+22
-123
lines changed

azure/templates/deploy-stage.yml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -152,42 +152,6 @@ jobs:
152152
displayName: Override FULLY_QUALIFIED_SERVICE_NAME
153153
- checkout: self
154154
path: "s/${{ parameters.service_name }}"
155-
submodules: recursive
156-
fetchDepth: 0 # Ensure complete history is fetched for submodules
157-
# Add this step after checkout and before terraform
158-
- task: Bash@3
159-
displayName: 'Debug Azure DevOps Structure'
160-
inputs:
161-
targetType: 'inline'
162-
script: |
163-
echo "=== SAW AZURE DEVOPS WORKSPACE DEBUG ==="
164-
echo "Pipeline.Workspace: $(Pipeline.Workspace)"
165-
echo "Build.SourcesDirectory: $(Build.SourcesDirectory)"
166-
echo "System.DefaultWorkingDirectory: $(System.DefaultWorkingDirectory)"
167-
echo "Agent.BuildDirectory: $(Agent.BuildDirectory)"
168-
echo "Current directory: $(pwd)"
169-
echo ""
170-
echo "=== WORKSPACE CONTENTS ==="
171-
echo "Pipeline workspace contents:"
172-
find $(Pipeline.Workspace) -maxdepth 3 -type d 2>/dev/null | head -20
173-
echo ""
174-
echo "=== SOURCE DIRECTORY CONTENTS ==="
175-
echo "Build sources directory contents:"
176-
ls -la $(Build.SourcesDirectory) 2>/dev/null || echo "Build.SourcesDirectory not accessible"
177-
echo ""
178-
echo "=== CURRENT DIRECTORY TREE ==="
179-
echo "Current directory tree:"
180-
find . -maxdepth 3 -type d 2>/dev/null || echo "Cannot access current directory"
181-
echo ""
182-
echo "=== SEARCH FOR LAMBDAS ==="
183-
echo "Searching for lambdas directory:"
184-
find $(Pipeline.Workspace) -name "lambdas" -type d 2>/dev/null || echo "No lambdas directory found"
185-
echo ""
186-
echo "=== SEARCH FOR DOCKERFILES ==="
187-
echo "Searching for Dockerfiles:"
188-
find $(Pipeline.Workspace) -name "*.Dockerfile" -type f 2>/dev/null || echo "No Dockerfiles found"
189-
echo "=== END DEBUG ==="
190-
191155

192156
- task: UsePythonVersion@0
193157
displayName: "Use Python ${{ parameters.python_version }}"

terraform/id_sync_lambda.tf

Lines changed: 22 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -1,112 +1,47 @@
11
# Define the directory containing the Docker image and calculate its SHA-256 hash for triggering redeployments
22
locals {
3-
lambdas_dir = abspath("${path.root}/../lambdas")
4-
shared_dir = "${local.lambdas_dir}/shared"
5-
id_sync_lambda_dir = "${local.lambdas_dir}/id_sync"
6-
id_sync_dockerfile = "${local.lambdas_dir}/id_sync.Dockerfile"
3+
lambdas_dir = abspath("${path.root}/../lambdas")
4+
shared_dir = "${local.lambdas_dir}/shared"
5+
id_sync_lambda_dir = "${local.lambdas_dir}/id_sync"
6+
id_sync_dockerfile = "${local.lambdas_dir}/id_sync.Dockerfile"
77

88
# Get files from both directories
9-
shared_files = fileset(local.shared_dir, "**")
10-
id_sync_lambda_files = fileset(local.id_sync_lambda_dir, "**")
9+
shared_files = fileset(local.shared_dir, "**")
10+
id_sync_lambda_files = fileset(local.id_sync_lambda_dir, "**")
1111

1212
# Calculate SHA for both directories
1313
shared_dir_sha = sha1(join("", [for f in local.shared_files : filesha1("${local.shared_dir}/${f}")]))
1414
id_sync_lambda_dir_sha = sha1(join("", [for f in local.id_sync_lambda_files : filesha1("${local.id_sync_lambda_dir}/${f}")]))
1515

1616
# Combined SHA to trigger rebuild when either directory changes
17-
combined_sha = sha1("${local.shared_dir_sha}${local.id_sync_lambda_dir_sha}")
18-
repo_root = abspath("${path.root}/..")
19-
is_azure_devops = can(regex("^/agent/_work", path.root))
17+
combined_sha = sha1("${local.shared_dir_sha}${local.id_sync_lambda_dir_sha}")
18+
repo_root = abspath("${path.root}/..")
19+
is_azure_devops = can(regex("^/agent/_work", path.root))
2020

2121
debug_paths = {
22-
terraform_root = path.root
22+
terraform_root = path.root
2323
repo_root = local.repo_root
2424
lambdas_dir = local.lambdas_dir
2525
dockerfile_path = local.id_sync_dockerfile
2626
is_azure = local.is_azure_devops
2727
}
2828
}
2929

30-
resource "null_resource" "find_dockerfile" {
31-
provisioner "local-exec" {
32-
command = <<-EOT
33-
echo "=== FINDING DOCKERFILE ==="
34-
35-
ls -la "${local.lambdas_dir}/" || echo "lambdas directory not found"
36-
ls -la .. || echo "parent directory not found"
37-
ls -la ${path.root}/.. || echo "grandparent directory not found"
38-
39-
EOT
40-
}
41-
}
42-
43-
resource "null_resource" "debug_directory_structure" {
44-
provisioner "local-exec" {
45-
command = <<-EOT
46-
echo "=== AZURE DEVOPS DIRECTORY DEBUG ==="
47-
echo "Current working directory: $(pwd)"
48-
echo "Terraform root: ${path.root}"
49-
echo ""
50-
echo "=== DIRECTORY CONTENTS ==="
51-
echo "Contents of current directory:"
52-
ls -la
53-
echo ""
54-
echo "Contents of parent directory:"
55-
ls -la ..
56-
echo ""
57-
echo "Contents of grandparent directory:"
58-
ls -la ../..
59-
echo ""
60-
echo "Looking for lambdas directory at various levels:"
61-
echo "Level 1 (../lambdas):"
62-
ls -la ../lambdas 2>/dev/null || echo "Not found at ../lambdas"
63-
echo "Level 2 (../../lambdas):"
64-
ls -la ../../lambdas 2>/dev/null || echo "Not found at ../../lambdas"
65-
echo "Level 3 (../../../lambdas):"
66-
ls -la ../../../lambdas 2>/dev/null || echo "Not found at ../../../lambdas"
67-
echo ""
68-
echo "Looking for Dockerfiles:"
69-
find .. -name "*.Dockerfile" -type f 2>/dev/null || echo "No Dockerfiles found"
70-
echo "=== END DEBUG ==="
71-
EOT
72-
}
73-
}
74-
7530
resource "aws_ecr_repository" "id_sync_lambda_repository" {
7631
image_scanning_configuration {
7732
scan_on_push = true
7833
}
7934
name = "${local.short_prefix}-id-sync-repo"
8035
force_delete = local.is_temp
8136
}
82-
resource "null_resource" "validate_dockerfile" {
83-
triggers = {
84-
dockerfile_path = "${local.lambdas_dir}/id_sync.Dockerfile"
85-
}
8637

87-
provisioner "local-exec" {
88-
command = <<-EOT
89-
echo "Checking for Dockerfile at: ${local.lambdas_dir}/id_sync.Dockerfile"
90-
if [ ! -f "${local.lambdas_dir}/id_sync.Dockerfile" ]; then
91-
echo "ERROR: Dockerfile not found!"
92-
echo "Current directory: $(pwd)"
93-
echo "Looking for: ${local.lambdas_dir}/id_sync.Dockerfile"
94-
echo "Files in lambdas directory:"
95-
ls -la "${local.lambdas_dir}/" || echo "lambdas directory not found"
96-
exit 1
97-
else
98-
echo "✅ Dockerfile found!"
99-
fi
100-
EOT
101-
}
102-
}
10338
# Module for building and pushing Docker image to ECR
10439
module "id_sync_docker_image" {
10540
source = "terraform-aws-modules/lambda/aws//modules/docker-build"
10641
version = "8.0.1"
10742

108-
create_ecr_repo = false
109-
ecr_repo = aws_ecr_repository.id_sync_lambda_repository.name
43+
create_ecr_repo = false
44+
ecr_repo = aws_ecr_repository.id_sync_lambda_repository.name
11045
docker_file_path = "id_sync.Dockerfile"
11146
ecr_repo_lifecycle_policy = jsonencode({
11247
"rules" : [
@@ -127,7 +62,7 @@ module "id_sync_docker_image" {
12762

12863
platform = "linux/amd64"
12964
use_image_tag = false
130-
source_path = local.lambdas_dir
65+
source_path = local.id_sync_lambda_dir
13166
triggers = {
13267
dir_sha = local.id_sync_lambda_dir_sha
13368
}
@@ -335,7 +270,7 @@ data "aws_iam_policy_document" "id_sync_policy_document" {
335270
resource "aws_iam_policy" "id_sync_lambda_dynamodb_access_policy" {
336271
name = "${local.short_prefix}-id-sync-lambda-dynamodb-access-policy"
337272
description = "Allow Lambda to access DynamoDB"
338-
policy = data.aws_iam_policy_document.id_sync_policy_document.json
273+
policy = data.aws_iam_policy_document.id_sync_policy_document.json
339274
}
340275

341276
# Attach the dynamodb policy to the Lambda role
@@ -360,15 +295,15 @@ resource "aws_lambda_function" "id_sync_lambda" {
360295

361296
environment {
362297
variables = {
363-
CONFIG_BUCKET_NAME = local.config_bucket_name
364-
REDIS_HOST = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].address
365-
REDIS_PORT = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].port
366-
ID_SYNC_PROC_LAMBDA_NAME = "imms-${var.sub_environment}-id_sync_lambda"
298+
CONFIG_BUCKET_NAME = local.config_bucket_name
299+
REDIS_HOST = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].address
300+
REDIS_PORT = data.aws_elasticache_cluster.existing_redis.cache_nodes[0].port
301+
ID_SYNC_PROC_LAMBDA_NAME = "imms-${var.sub_environment}-id_sync_lambda"
367302
# NEW
368-
DELTA_TABLE_NAME = aws_dynamodb_table.delta-dynamodb-table.name
369-
IEDS_TABLE_NAME = aws_dynamodb_table.events-dynamodb-table.name
370-
PDS_ENV = var.pds_environment
371-
SPLUNK_FIREHOSE_NAME = module.splunk.firehose_stream_name
303+
DELTA_TABLE_NAME = aws_dynamodb_table.delta-dynamodb-table.name
304+
IEDS_TABLE_NAME = aws_dynamodb_table.events-dynamodb-table.name
305+
PDS_ENV = var.pds_environment
306+
SPLUNK_FIREHOSE_NAME = module.splunk.firehose_stream_name
372307
}
373308
}
374309
kms_key_arn = data.aws_kms_key.existing_lambda_encryption_key.arn

0 commit comments

Comments
 (0)