mlevit / aws-auto-cleanup

Programmatically delete AWS resources based on an allowlist and time to live (TTL) settings
MIT License
496 stars 55 forks source link

[ERROR] [Errno 2] No such file or directory: 'auto_cleanup/data/auto-cleanup-settings.json' (lambda_handler.py, setup_dynamodb(), line 283) #45

Closed kviliev closed 3 years ago

kviliev commented 4 years ago

Describe the bug For the first time after deployment lambda executed in 'DRY' mode as by default. I changed the rate of the lambda execution to 'every 5 minutes' then and the mode to 'DESTROY'. It executed successfully the first time and cleaned up the resources. After that, it started logging this error message for any of the next executions.

START RequestId: 4438f2ea-325f-4e23-b75c-03dc8eaf7c23 Version: $LATEST [ERROR] [Errno 2] No such file or directory: 'auto_cleanup/data/auto-cleanup-settings.json' (lambda_handler.py, setup_dynamodb(), line 283) [INFO] Auto Cleanup started in DESTROY mode. (lambda_handler.py, run_cleanup(), line 45) [INFO] Switching region to 'ap-south-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'eu-north-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'eu-west-3'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'eu-west-2'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'eu-west-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Skipping region 'ap-northeast-3'. (lambda_handler.py, run_cleanup(), line 152) [INFO] Switching region to 'ap-northeast-2'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'ap-northeast-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'ca-central-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'sa-east-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Skipping region 'cn-north-1'. (lambda_handler.py, run_cleanup(), line 152) [INFO] Switching region to 'ap-southeast-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'ap-southeast-2'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'eu-central-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'us-east-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'us-east-2'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Skipping region 'cn-northwest-1'. (lambda_handler.py, run_cleanup(), line 152) [INFO] Switching region to 'us-west-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'us-west-2'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'global'. (lambda_handler.py, run_cleanup(), line 155) [INFO] Skipping cleanup of S3 Buckets. (s3_cleanup.py, buckets(), line 186) [INFO] Skipping cleanup of IAM Roles. (iam_cleanup.py, roles(), line 286) [INFO] Auto Cleanup completed. (lambda_handler.py, run_cleanup(), line 171) [INFO] Resource tree has been built and uploaded to S3 's3://auto-cleanup-prod-resourcetreebucket-kiliev/resource_tree_2020_05_20_22_31_50.txt. (lambda_handler.py, build_tree(), line 349) END RequestId: 4438f2ea-325f-4e23-b75c-03dc8eaf7c23 REPORT RequestId: 4438f2ea-325f-4e23-b75c-03dc8eaf7c23 Duration: 81231.30 ms Billed Duration: 81300 ms Memory Size: 128 MB Max Memory Used: 126 MB XRAY TraceId: 1-5ec5af85-16cceece5b61aa7ad3ac5956 SegmentId: 3e54e9ca12b29144 Sampled: true

mlevit commented 4 years ago

Hey @kviliev that's strange, nothing deletes the settings file. Can you have a look into the Lambda function package within the data directory to see if the file exists or not?

kviliev commented 4 years ago

Hi @mlevit , yes - all the files are there(from the data directory) - locally and in the lambda package uploaded to the s3 bucket. I tried deploying/testing multiple times. I tried from a different host and to a different AWS account as well. I always run into this issue. Also, this error appeared a few times:

[ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [ERROR] An error occurred (ConditionalCheckFailedException) when calling the PutItem operation: The conditional request failed (lambda_handler.py, setup_dynamodb(), line 277) [INFO] Auto Cleanup started in DESTROY mode. (lambda_handler.py, run_cleanup(), line 45) [INFO] Switching region to 'ap-south-1'. (lambda_handler.py, run_cleanup(), line 49) [INFO] Switching region to 'eu-north-1'. (lambda_handler.py, run_cleanup(), line 49)

mlevit commented 4 years ago

@kviliev have you managed to resolve this issue?