{"id":20331182,"url":"https://github.com/comcast/speculative-plan-pr-reporter-resource","last_synced_at":"2026-04-30T06:36:50.873Z","repository":{"id":196580847,"uuid":"690236088","full_name":"Comcast/speculative-plan-pr-reporter-resource","owner":"Comcast","description":"A concourse resource to publish the speculative terraform plan as a PR comment.","archived":false,"fork":false,"pushed_at":"2023-10-17T20:35:12.000Z","size":33,"stargazers_count":3,"open_issues_count":1,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-01-14T15:24:54.780Z","etag":null,"topics":["cicd","concourse","terraform"],"latest_commit_sha":null,"homepage":"","language":"Python","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/Comcast.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-09-11T19:56:20.000Z","updated_at":"2023-10-25T18:38:00.000Z","dependencies_parsed_at":"2023-09-26T08:44:49.489Z","dependency_job_id":null,"html_url":"https://github.com/Comcast/speculative-plan-pr-reporter-resource","commit_stats":null,"previous_names":["comcast/speculative-plan-pr-reporter-resource"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Comcast%2Fspeculative-plan-pr-reporter-resource","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Comcast%2Fspeculative-plan-pr-reporter-resource/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Comcast%2Fspeculative-plan-pr-reporter-resource/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Comcast%2Fspeculative-plan-pr-reporter-resource/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Comcast","download_url":"https://codeload.github.com/Comcast/speculative-plan-pr-reporter-resource/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241846027,"owners_count":20029986,"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":["cicd","concourse","terraform"],"created_at":"2024-11-14T20:19:11.149Z","updated_at":"2026-04-30T06:36:50.819Z","avatar_url":"https://github.com/Comcast.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# concourse-terraform-plan-reporter-resource\n\nA Concourse resource to generate a report from a speculative terraform plan.\n\nWritten in Python, it currently supports publishing the report of changes as a table to a Github Pull Request\nby taking advantage of the [telia-oss/github-pr-resource](https://github.com/telia-oss/github-pr-resource)\nto fetch metadata for the PR.\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n## Source Configuration\n\n| Parameter | Required | Default | Description |\n|-|-|-|-|\n| gh_api_endpoint | No | `https://api.github.com` | The API endpoint for the Github instance to which the resource should publish the speculative plan report. |\n| gh_access_token | Yes |  | The Github Personal Access Token to be used for accessing the Github API endpoint. This is usually fetched from a secret store like Vault and defined in the pipeline configuration as ((github.access_token)) |\n| gh_repository | Yes | | The Github repository for which the pipeline is being executed. The path should be in the format `org_name/repo_name`. |\n| pr_path | Yes | | The directory path to the pull request where `get` on `github-pr-resource` fetches the repository and the pull request metadata. |\n\n## Behavior\n\n### `check`\n\nN/A. The check itself doesn't do anything in this resource currently to trigger\nany action.\n\n### `put`\n\n#### Parameters\n\n| Parameter | Required | Default | Description |\n|-|-|-|-|\n| plan_json_file | Yes | | The path to the terraform plan in the JSON format, generated using `terraform show --json \u003cplan_file\u003e`. This can be the result of a task or the use of `ljfranklin/terraform-resource` |\n\nThe version emitted from out is a `base64` representation of the comment posted to Github Pull Request.\nin the markdown table format, comprising of the resources that are being created, modified or removed and an expandable description of\nthe attributes that are changed for each resource.\n\n### `get`\n\nThe base64 representation of the comment URL is decoded and written to a file called `comment_url.txt`\nunder the resource directory.\n\n## Example\n\n```yml\nresource_types:\n- name: terraform\n  type: registry-image\n  source:\n    repository: ljfranklin/terraform-resource\n\n- name: terraform-plan-gh-pr-resource\n  type: docker-image\n  source:\n    repository: \u003cdocker-registry-namespace\u003e/terraform-plan-pr-reporter-resource # Registry URL and namespace where the resource image is pushed to. The image can be generated using the `Dockerfile`.\n\n- name: pull-request\n  type: registry-image\n  source:\n    repository: teliaoss/github-pr-resource\n\nresources:\n- name: examples\n  type: git\n  source:\n    uri: https://github.com/concourse/examples.git # This has a terraform example\n    branch: master\n\n- name: appcode-pull-request\n  type: pull-request\n  check_every: 12h\n  source:\n    repository: \u003cgh_org\u003e/\u003cgh_repository\u003e\n    access_token: ((github.access_token))\n    v3_endpoint: https://api.github.com\n    v4_endpoint: https://api.github.com/graphql\n    base_branch: main\n    states: [\"OPEN\"]\n    disable_forks: false\n\n- name: deve-env-terraform\n  type: terraform\n  source:\n    env_name: main\n    backend_type: s3\n    backend_config:\n      bucket     : ((terraform.backend.bucket))\n      region     : us-east-1\n      key        : ((terraform.backend.key))\n      access_key : ((aws.access_key_id))\n      secret_key : ((aws.secret_access_key))\n      token      : ((aws.session_token))\n\n- name: terraform-gh-pr\n  type: terraform-plan-gh-pr-resource\n  source:\n    gh_access_token: ((github.access_token))\n    gh_api: https://api.github.com\n    pr_path: appcode-pull-request\n    gh_repository: \u003cgh_org\u003e/gh_repository\u003e\njobs:\n\n- name: terraform-plan-aws\n  serial: true\n  plan:\n  \n  - get: examples\n  - put: deve-env-terraform\n    get_params:\n      output_planfile: true\n      output_statefile: true\n    params:\n      plan_only: true\n      env_name      : deve\n      terraform_source: examples/terraform/staging\n  - get: appcode-pull-request\n  - put: terraform-gh-pr\n    params:\n      plan_json_file: \"deve-env-terraform/plan.json\"\n```\n\n## Development\n\nPrerequisites:\n* python is required - version 3.11.1 is tested; earlier versions (3.x.x) may also work\n* docker is required for buidling the resource.\n\nTo use the newly built image, push it to a docker registry that's accessible to\nConcourse and configure your pipeline to use it:\nMake sure to [force-recheck the resource type](https://concourse-ci.org/managing-resource-types.html#fly-check-resource-type) for the new changes to reflect\n\n### Makefile\n\nA lot of useful make directives are provided. \n\n- To initialize the project, run `make all`.\n- To format the code base, run `make pretty`.\n\n### Building Docker image\n\nMake directives are provided to aide with both local testing of the resource and pushing the resource to a docker registry.\nEdit the `DOCKER_IMAGE_TAG` at the top of the `makefile`.\n\n- `make docker-build` To build the image.\n- `make docker-local` To test the image locally for `out` with a sample input.\n- `make docker-push` To push the image to a docker registry.\n\n\nPlease make sure the user is authenticated against the respective docker registry.\n\nThe build image has to be pushed to registry before using the same in concourse. \n\n## LICENSE\n\nThis project is licensed under the terms of the Apache 2.0 open source license. Please refer to [LICENSE](./LICENSE) for the full terms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomcast%2Fspeculative-plan-pr-reporter-resource","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomcast%2Fspeculative-plan-pr-reporter-resource","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomcast%2Fspeculative-plan-pr-reporter-resource/lists"}