{"id":26009963,"url":"https://github.com/byu-oit/terraform-aws-postman-test-lambda","last_synced_at":"2025-06-26T02:36:59.359Z","repository":{"id":37979388,"uuid":"278427509","full_name":"byu-oit/terraform-aws-postman-test-lambda","owner":"byu-oit","description":"Terraform module that creates a generic lambda function that will run newman tests against a postman collection","archived":false,"fork":false,"pushed_at":"2025-02-07T18:43:06.000Z","size":79713,"stargazers_count":4,"open_issues_count":4,"forks_count":3,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-04-08T16:54:54.876Z","etag":null,"topics":["terraform-module"],"latest_commit_sha":null,"homepage":"","language":"HCL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/byu-oit.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,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-07-09T17:22:49.000Z","updated_at":"2025-02-07T18:40:14.000Z","dependencies_parsed_at":"2025-02-07T18:38:26.216Z","dependency_job_id":null,"html_url":"https://github.com/byu-oit/terraform-aws-postman-test-lambda","commit_stats":null,"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"purl":"pkg:github/byu-oit/terraform-aws-postman-test-lambda","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byu-oit%2Fterraform-aws-postman-test-lambda","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byu-oit%2Fterraform-aws-postman-test-lambda/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byu-oit%2Fterraform-aws-postman-test-lambda/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byu-oit%2Fterraform-aws-postman-test-lambda/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byu-oit","download_url":"https://codeload.github.com/byu-oit/terraform-aws-postman-test-lambda/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byu-oit%2Fterraform-aws-postman-test-lambda/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261987780,"owners_count":23240911,"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":["terraform-module"],"created_at":"2025-03-05T22:26:41.352Z","updated_at":"2025-06-26T02:36:59.333Z","avatar_url":"https://github.com/byu-oit.png","language":"HCL","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Latest GitHub Release](https://img.shields.io/github/v/release/byu-oit/terraform-aws-postman-test-lambda?sort=semver)\n\n# Terraform AWS Postman Test Lambda\n\nTerraform module that creates a generic lambda function that runs newman tests against a postman collection.\n\nThis lambda function is intended for use with [CodeDeploy's lifecycle hooks](https://docs.aws.amazon.com/codedeploy/latest/userguide/reference-appspec-file-structure-hooks.html).\nThis lambda function will attempt to run the [newman](https://www.npmjs.com/package/newman) CLI to run your Postman collection as a test.\nThis lambda function will tell CodeDeploy if the tests pass or fail.\n\n#### [New to Terraform Modules at BYU?](https://github.com/byu-oit/terraform-documentation)\n\n## Usage\n\n```hcl\nmodule \"postman_test_lambda\" {\n  source = \"github.com/byu-oit/terraform-aws-postman-test-lambda?ref=v6.0.0\"\n  app_name = \"simple-example\"\n  postman_collections = [\n    {\n      collection = \"terraform-aws-postman-test-lambda-example.postman_collection.json\"\n      environment = \"terraform-aws-postman-test-lambda-env.postman_environment.json\"\n    }\n  ]\n  role_permissions_boundary_arn = data.aws_ssm_parameter.role_permissions_boundary_arn.value\n}\n```\n\nYou can specify multiple collections and environments to run in the lambda function. The function will run the\ncollections in order.\n\nYou can run collections/environments from local json files or using the [Postman API](#using-the-postman-api).\n\n**Note:** When [using the Postman API](#using-the-postman-api): the postman collections/environments must be viewable by\nthe postman account tied to the API key you provide.\n\n**DON'T** hard code your postman API key, treat it like all other secrets.\n\nThen add your lambda function_name to the CodeDeploy lifecycle hook you want the postman tests to run on. For instance,\nif you're using the [fargate-api module](https://github.com/byu-oit/terraform-aws-fargate-api):\n\n```hcl\n# ... postman-test-lambda module\n\nmodule \"fargate_api\" {\n  source = \"github.com/byu-oit/terraform-aws-fargate-api?ref=\" # latest version\n  # .. all other variables\n  codedeploy_lifecycle_hooks = {\n    BeforeInstall         = null\n    AfterInstall          = null\n    AfterAllowTestTraffic = module.postman_test_lambda.lambda_function.function_name\n    BeforeAllowTraffic    = null\n    AfterAllowTraffic     = null\n  }\n}\n```\n\nOr if you're using the [lambda-api module](https://github.com/byu-oit/terraform-aws-lambda-api):\n\n```hcl\n# ... postman-test-lambda module\n\nmodule \"lambda_api\" {\n  source = \"github.com/byu-oit/terraform-aws-lambda-api?ref=\" # latest version\n  # .. all other variables\n  codedeploy_lifecycle_hooks = {\n    BeforeAllowTraffic = module.postman_test_lambda.lambda_function.function_name\n    AfterAllowTraffic  = null\n  }\n}\n```\n\n### Using the Postman API\n\nIf you don't want to export your postman collections/environments into json files in order to run tests you can use the\nPostman API. Using the Postman API allows you to keep your postman collections/environments in Postman and not have to\nworry about keeping json files up to date.\n\nIn order to use the Postman API to retrieve the collections/environments you will need to provide the `postman_api_key`.\nYou can [generate an API key](https://learning.postman.com/docs/developer/intro-api/) from a Postman account.\n**PLEASE DON'T** hardcode the api key into your github repo.\n\nProvide the collection and environment IDs instead of the name of each. You can find the ID on the v8 Postman Client by\nselecting your collection/environment and clicking on the info icon.\n\n```hcl\nmodule \"postman_test_lambda\" {\n  source = \"github.com/byu-oit/terraform-aws-postman-test-lambda?ref=v6.0.0\"\n  app_name = \"from-postman-api-example\"\n  postman_collections = [\n    {\n      collection  = \"1117094-d4bd5a5f-c37c-4fe9-8723-3c3e8b1e2015\" # terraform-aws-postman-test-lambda-example collection from postman TF Modules and HW Examples workspace\n      environment = \"1117094-95627910-aeb0-4aed-b959-7e2034e2f6ce\" # terraform-aws-postman-test-lambda-env environment from postman TF Modules and HW Examples workspace\n    }\n  ]\n  postman_api_key               = var.postman_api_key\n  role_permissions_boundary_arn = data.aws_ssm_parameter.role_permissions_boundary_arn.value\n}\n```\n\n## Requirements\n\n* Terraform version 1.3.0 or greater\n* Terraform AWS Provider version 5.26.0 or greater\n* _Postman JSON collections/environments files (optional)_ if you want export them to JSON files and include them in your project repo\n* _Postman API (optional)_ if you want to download Postman collections/environments from Postman instead of providing the json files in your repo\n\n## Inputs\n\n| Name                          | Type        | Description                                                                                                                                                                           | Default |\n| ----------------------------- | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |\n| alb_wait_time                 | number      | The number of seconds the Lambda function should wait for the new ALB target group to initialize before running tests. If you increase this, you may also need to increase `timeout`. | 10      |\n| app_name                      | string      | Application name to prefix your postman test lambda function's name                                                                                                                   |         |\n| postman_collections           | list([object](#postman_collection))| List of postman collections and environments. See [postman_collection](#postman_collection)                                                                    |         |\n| postman_api_key               | string      | Postman API key to download collections/environments from Postman API (must be provided if you provide any postman IDs in `postman_collection` variable)                              | null    |\n| role_permissions_boundary_arn | string      | ARN of the IAM Role permissions boundary to place on each IAM role created                                                                                                            |         |\n| log_retention_in_days         | number      | CloudWatch log group and S3 log bucket retention in days                                                                                                                                                | 7       |\n| tags                          | map(string) | A map of AWS Tags to attach to each resource created                                                                                                                                  | {}      |\n| timeout                       | number      | The max number of seconds the lambda will run for without stopping.                                                                                                                   | 30      |\n| memory_size                   | number      | The size of the memory of the lambda                                                                                                                                                  | 128     |\n| vpc_id                        | string      | The id of the VPC the lambda will be behind if VPC configuration is desired. (must be provided with lambda_vpc_subnet_ids)                                                            | null    |\n| vpc_subnet_ids         | list(string) | A list of subnet ids the lambda will be put in if VPC configuration is desired. (must be provided with vpc_id)                                                                              | []      |\n| test_env_var_overrides | map(string) | Values to set or override in the Postman test environment.                                                                                                                                   | {}      |\n\n### postman_collection\nObject defining the collection and environment to run.\n* **`collection`** - (Required) path to local collection json file or Postman collection ID\n* **`environment`** - (Optional) path to local environment json file or Postman environment ID (can be set to `null` if you don't want an environment on your postman collection)\n\n## Outputs\n\n| Name            | Type                                                                                              | Description                                                               |\n| --------------- | ------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------- |\n| lambda_function | [object](https://www.terraform.io/docs/providers/aws/r/lambda_function.html#attributes-reference) | Created lambda function that runs newman to test the `postman_collection` |\n| lambda_iam_role | [object](https://www.terraform.io/docs/providers/aws/r/iam_role.html#attributes-reference)        | Created IAM role for the `lambda_function`                                |\n| postman_files_bucket | [object](https://www.terraform.io/docs/providers/aws/r/s3_bucket.html#attributes-reference)  | Created S3 Bucket where local postman files are uploaded                  |\n| cloudwatch_log_group | [object](https://www.terraform.io/docs/providers/aws/r/cloudwatch_log_group.html#attributes-reference)  | Created CloudWatch Log Group for the postman lambda logs       |\n| lambda_security_group | [object](https://www.terraform.io/docs/providers/aws/r/security_group.html#attributes-reference) | Created security group for the lambda's VPC configuration. |\n\n## Contributing\n\nTo contribute to this terraform module make a feature branch and create a Pull Request to the `master` branch.\n\nThis terraform module bakes in the lambda function code in the committed [function.zip](lambda/dist/function.zip) file.\n\nIf you change the [index.js](lambda/src/index.js) file then you'll need to run `npm run package` and commit\nthe [function.zip](lambda/dist/function.zip) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyu-oit%2Fterraform-aws-postman-test-lambda","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyu-oit%2Fterraform-aws-postman-test-lambda","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyu-oit%2Fterraform-aws-postman-test-lambda/lists"}