{"id":22477178,"url":"https://github.com/base2services/aws-lambda-port-check","last_synced_at":"2025-07-29T07:02:51.071Z","repository":{"id":145343610,"uuid":"106780073","full_name":"base2Services/aws-lambda-port-check","owner":"base2Services","description":"Lambda function to check for tcp/ip port availability","archived":false,"fork":false,"pushed_at":"2023-11-24T00:29:07.000Z","size":10,"stargazers_count":15,"open_issues_count":2,"forks_count":14,"subscribers_count":7,"default_branch":"master","last_synced_at":"2023-11-24T01:29:54.512Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/base2Services.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-10-13T05:04:58.000Z","updated_at":"2023-10-26T02:30:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"2c053953-962e-49a0-8a04-7fd3d1668d22","html_url":"https://github.com/base2Services/aws-lambda-port-check","commit_stats":null,"previous_names":[],"tags_count":1,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base2Services%2Faws-lambda-port-check","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base2Services%2Faws-lambda-port-check/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base2Services%2Faws-lambda-port-check/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/base2Services%2Faws-lambda-port-check/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/base2Services","download_url":"https://codeload.github.com/base2Services/aws-lambda-port-check/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228476046,"owners_count":17926134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-06T14:09:45.848Z","updated_at":"2024-12-06T14:09:46.714Z","avatar_url":"https://github.com/base2Services.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Lambda port availability check\n\nLambda function to check specific tcp/ip port availability , and report on it\n\nOptionally, it can record metrics to CloudWatch.\n\n## Inputs\n\nAll inputs are either defined as environment variables or as part of event data. Event data\nwill take priority over environment variables\n\n`HOSTNAME` - url to be checked\n\n`PORT` - http method to use, defaults to `GET`\n\n`TIMEOUT` - timeout when connecting in seconds, defaults to 120s\n\n`REPORT_AS_CW_METRICS` - set to 1 if you wish to store reported data as CW\ncustom metrics, 0 otherwise, defaults to 1\n\n`CW_METRICS_NAMESPACE` - if CW custom metrics are being reported, this will determine\ntheir namespace, defaults to 'TcpPortCheck'\n\n## Outputs\n\nBy default, following properties will be rendered in output Json\n\n`Available` - 0 or 1\n\n`TimeTaken` - Time in ms it took to get response from remote server. Default timeout\nis 2 minutes for http requests.\n\n## Dependencies\n\nLambda function is having no external dependencies by design, so no additional packaging steps are required\nfor deploying it, such as doing `pip install [libname]`\n\n## CloudWatch Metrics\n\nIn order to get some metrics which you can alert on, `REPORT_AS_CW_METRICS` and `CW_METRICS_NAMESPACE` environment\nvariables are used. Following metrics will be reported\n\n- `Available` - 0 or 1, whether response was received in timely manner, indicating problems with network, DNS lookup or\nserver timeout\n\n- `TimeTaken` - Time taken to fetch response, reported in milliseconds\n\n\n## Deployment\n\nYou can either deploy Lambda manually, or through [serverless](serverless.com) project.\nIf serverless is being chosen as method of deployments use command below, while\nmaking sure that you have setup proper access keys. For more information [read here](https://serverless.com/framework/docs/providers/aws/guide/workflow/)\n\nServerless framework version used during development\nis `1.23.0`, but it is very likely that later versions\nwill function as well\n\n```\nsls deploy\n```\n\nIf you are setting up your Lambda function by hand, make sure it has proper IAM\npermissions to push Cloud Watch metrics data, and to write to CloudWatch logs\n\n## Testing\n\nTo test function locally with simple Google url (default), run following\n\n```bash\nsls invoke local  -f portcheck\n```\n\nFor more complex example with failed health check, look at test/example.json \n\n```bash\n\n$ sls invoke local -f portcheck -p test/example.json \nSocket connect result: 35\nSent data to CloudWatch requestId=:a840f551-afda-11e7-bfe8-532dcf9b380b\nResult of checking  example.com:23\n{\n    \"TimeTaken\": 5002,\n    \"Available\": \"0\"\n}\n{\n    \"TimeTaken\": 5002,\n    \"Available\": \"0\"\n}\n\n```\n\n\n## Schedule execution\n\nPull requests are welcome to serverless project to deploy CloudWatch rules in order\nto schedule execution of Http Checking Lambda function.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase2services%2Faws-lambda-port-check","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbase2services%2Faws-lambda-port-check","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbase2services%2Faws-lambda-port-check/lists"}