Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

azurerm_platform_image: Add version argument #4402

Closed
jpbuecken opened this issue Sep 20, 2019 · 2 comments · Fixed by #6948
Closed

azurerm_platform_image: Add version argument #4402

jpbuecken opened this issue Sep 20, 2019 · 2 comments · Fixed by #6948

Comments

@jpbuecken
Copy link

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Hello,
is it possible to extend the data source azurerm_platform_image to allow version as argument?
Maybe we need a all=true/false flag es well, which is automatically true if version has been set.
The az image list command does not support a --version argument yet, but maybe it is possible to implement it anyway via filter Option in the API call (https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages/list)

With this it will be possible to boot your instance from a disk, but use a specific image (not latest). And if we boot from VHD, we are able manage tags of the boot disk via terraform.

  • azurerm_platform_image

Potential Terraform Configuration

data "azurerm_platform_image" "test" {
  location  = "West Europe"
  publisher = "Canonical"
  offer     = "UbuntuServer"
  sku       = "16.04-LTS"
  version = "16.04.201907290"
}

output "version" {
  value = "${data.azurerm_platform_image.test.id}"
}
@jpbuecken
Copy link
Author

jpbuecken commented Oct 21, 2019

Maybe it is possible to implement query.

Request is to implement the following request via az cli in the datasource:

az vm image list --location westus --publisher Canonical --offer UbuntuServer --sku 18.04-LTS --all --query "[?contains(version,'18.04.201907080')]"
[
  {
    "offer": "UbuntuServer",
    "publisher": "Canonical",
    "sku": "18.04-LTS",
    "urn": "Canonical:UbuntuServer:18.04-LTS:18.04.201907080",
    "version": "18.04.201907080"
  }
]

EDIT 2020-04-02: The filter option has been removed form the Rest API documentation.

Alternative: Add version as optional parameter with default "latest". If version is given and not latest, use
https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages/get
instead of
https://docs.microsoft.com/en-us/rest/api/compute/virtualmachineimages/list

curl -X GET -H "Authorization: Bearer $TOKEN" -H 'Content-Type: application/json' https://management.azure.com/subscriptions/${subscriptionId}/providers/Microsoft.Compute/locations/westus/publishers/Canonical/artifacttypes/vmimage/offers/UbuntuServer/skus/18.04-LTS/versions/18.04.201907080?api-version=2019-07-01


{
  "properties": {
    "hyperVGeneration": "V1",
    "replicaType": "Unmanaged",
    "disallowed": {
      "vmDiskType": "None"
    },
    "automaticOSUpgradeProperties": {
      "automaticOSUpgradeSupported": true
    },
    "osDiskImage": {
      "operatingSystem": "Linux",
      "sizeInGb": 30,
      "sizeInBytes": 32212255232
    },
    "dataDiskImages": []
  },
  "location": "westus",
  "name": "18.04.201907080",
  "id": "/Subscriptions/${subscriptionId}/Providers/Microsoft.Compute/Locations/westus/Publishers/Canonical/ArtifactTypes/VMImage/Offers/UbuntuServer/Skus/18.04-LTS/Versions/18.04.201907080"
}

@ghost
Copy link

ghost commented Jun 20, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. If you feel I made an error 🤖 🙉 , please reach out to my human friends 👉 hashibot-feedback@hashicorp.com. Thanks!

@hashicorp hashicorp locked and limited conversation to collaborators Jun 20, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants