-
Notifications
You must be signed in to change notification settings - Fork 932
Description
Describe the need
A github_release_asset data source would enable users to natively fetch and/or read GitHub release assets in Terraform.
For example, imagine a owner/repo GitHub release with various *.json file assets. To read those *.json files' contents via a github_release_asset data source, I'm imagining something akin to the following (although, it would be useful to support additional/alternative arguments beyond just id too, and perhaps even the option to download the asset):
data "github_release" "latest" {
repository = "owner"
owner = "repo"
retrieve_by = "latest"
}
data "github_release_asset" "release_assets" {
count = length(data.github_release.latest.assets)
url = data.github_release.latest.assets[count.index].url
}
output "release_assets" {
value = data.github_release_asset.release_assets.*.body
}However, currently, without a github_release_asset data source, it's necessary to utilize suboptimal workarounds, such as the use of the http provider and some not-ideal mechanism (such as a var.github_token) for providing a GitHub token:
data "github_release" "latest" {
repository = "owner"
owner = "repo"
retrieve_by = "latest"
}
data "http" "release_assets" {
count = length(data.github_release.latest.assets)
url = data.github_release.latest.assets[count.index].url
request_headers = {
Accept = "application/octet-stream"
Authorization = "Bearer ${var.github_token}"
}
}
output "release_assets" {
value = data.http.release_assets.*.body
}Note that, in addition to requiring the use of an additional provider (i.e. the http provider), the use of the var.github_token creates a few complications:
- It's necessary to ensure it's not printed in plain text in logs, Terraform state, etc.
- If its value is generated dynamically via a GitHub app -- and if
planandapplyare divided across distinct phases run on different CI/CD compute infrastructure, each with their own distinctvar.github_token-generation -- then the token's value can change across each phase, resulting inError: Can't change variable when applying a saved planduring apply.
So, a github_release_asset data source would be very helpful!
SDK Version
No response
API Version
No response
Relevant log output
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Status