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

Adjust the "plan" input to properly set the image name and product #218

Merged
merged 1 commit into from
Jan 16, 2023

Conversation

AWSmith0216
Copy link
Contributor

Describe your changes

When attempting to use a marketplace image, the terraform apply will currently fail with:

│ Error: compute.VirtualMachinesClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="ResourcePurchaseValidationFailed" Message="User failed validation to purchase resources. Error message: 'The offer with Offer ID '8-gen1' was not
found. Try one of these: 1- Make sure the offer name is written correctly. 2- If this offer was recently created, allow up to 30 minutes for it to be available for purchase. 3- The offer may have been removed from the marketplace. Look for similar offers from this p
ublisher here: 'https://azuremarketplace.microsoft.com/en-us/marketplace/apps?page=1%26search=almalinux%208-gen1'. Publisher ID: 'almalinux', Offer ID: '8-gen1', Correlation ID 'XXX'.'"

Currently the "plan" input is constructed as:

  dynamic "plan" {
    for_each = var.is_marketplace_image ? ["plan"] : []

    content {
      name      = var.vm_os_offer
      product   = var.vm_os_sku
      publisher = var.vm_os_publisher
    }
  }

However, the name and product are being used incorrectly here. For example, consider image with URN almalinux:almalinux:8-gen1:8.7.2022122801. The 'az vm image list' and 'az vm image show' output for this image is (with some redactions):

[user@server]$ az vm image list --location eastus --publisher almalinux --offer almalinux --all
  {
    "offer": "almalinux",
    "publisher": "almalinux",
    "sku": "8-gen1",
    "urn": "almalinux:almalinux:8-gen1:8.7.2022122801",
    "version": "8.7.2022122801"
  },
[user@server]$ az vm image show -l eastus --urn almalinux:almalinux:8-gen1:8.7.2022122801
{
  "id": "/Subscriptions/f60cdb4a-1023-47c6-a3ff-6a3ef043f74d/Providers/Microsoft.Compute/Locations/eastus/Publishers/almalinux/ArtifactTypes/VMImage/Offers/almalinux/Skus/8-gen1/Versions/8.7.2022122801",
  "location": "eastus",
  "name": "8.7.2022122801",
  "plan": {
    "name": "8-gen1",
    "product": "almalinux",
    "publisher": "almalinux"
  },
}

So if I wish to schedule this image, the correct "plan" values are:

  • Publisher: almalinux
  • Product: almalinux
  • Name: 8-gen1

However, the incorrect "plan" input currently being constructed by this module instead is:

  • Publisher: almalinux
  • Product: 8-gen1
  • Name: almalinux

In short, the product and name are swapped. This PR is to correct this behavior.

Issue number

No issue

Checklist before requesting a review

  • The pr title can be used to describe what this pr did in CHANGELOG.md file
  • I have executed pre-commit on my machine
  • I have passed pr-check on my machine

Thanks for your cooperation!

@github-actions
Copy link
Contributor

Potential Breaking Changes in cd39b21:
[delete] "Variables.vm_extensions.Name" from 'vm_extensions' to ''

@AWSmith0216 AWSmith0216 temporarily deployed to acctests January 16, 2023 03:09 — with GitHub Actions Inactive
Copy link
Member

@lonegunmanb lonegunmanb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @AWSmith0216 , LGTM! 🚀

@lonegunmanb lonegunmanb merged commit f570ab6 into Azure:master Jan 16, 2023
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants