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

New Data Source: azurerm_compute_resource_sku #3798

Closed

Conversation

MattMencel
Copy link
Contributor

@MattMencel MattMencel commented Jul 5, 2019

Adding a data resource for Compute Resource SKUs so we can get access to the availability zone data for a particular SKU.

#3025

I added support for most of the available attributes. I'm not 100% sure of the response data for restrictions so there are still a few things marked //TODO in the code.

EXAMPLE USAGE:

provider "azurerm" {}

data "azurerm_compute_resource_skus" "test" {
  name     = "Standard_DS2_v2"
  location = "centralus"
}

output "name" {
  value = "${data.azurerm_compute_resource_skus.test.name}"
}

output "resource_type" {
  value = "${data.azurerm_compute_resource_skus.test.resource_type}"
}

output "tier" {
  value = "${data.azurerm_compute_resource_skus.test.tier}"
}

output "size" {
  value = "${data.azurerm_compute_resource_skus.test.size}"
}

output "family" {
  value = "${data.azurerm_compute_resource_skus.test.family}"
}

output "location_info" {
  value = "${data.azurerm_compute_resource_skus.test.location_info}"
}

output "zones" {
  value = "${data.azurerm_compute_resource_skus.test.location_info.0.zones}"
}

output "capabilities" {
  value = "${data.azurerm_compute_resource_skus.test.capabilities}"
}

output "costs" {
  value = "${data.azurerm_compute_resource_skus.test.costs}"
}

output "restrictions" {
  value = "${data.azurerm_compute_resource_skus.test.restrictions}"
}

OUTPUT:

data.azurerm_compute_resource_skus.test: Refreshing state...

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

Outputs:

capabilities = [
    {
        name = MaxResourceVolumeMB,
        value = 14336
    },
    {
        name = OSVhdSizeMB,
        value = 1047552
    },
    {
        name = vCPUs,
        value = 2
    },
    {
        name = HyperVGenerations,
        value = V1,V2
    },
    {
        name = MemoryGB,
        value = 7
    },
    {
        name = MaxDataDiskCount,
        value = 8
    },
    {
        name = LowPriorityCapable,
        value = True
    },
    {
        name = PremiumIO,
        value = True
    },
    {
        name = vCPUsAvailable,
        value = 2
    },
    {
        name = ACUs,
        value = 210
    },
    {
        name = vCPUsPerCore,
        value = 1
    },
    {
        name = CombinedTempDiskAndCachedIOPS,
        value = 8000
    },
    {
        name = CombinedTempDiskAndCachedReadBytesPerSecond,
        value = 67108864
    },
    {
        name = CombinedTempDiskAndCachedWriteBytesPerSecond,
        value = 67108864
    },
    {
        name = CachedDiskBytes,
        value = 92341796864
    },
    {
        name = UncachedDiskIOPS,
        value = 6400
    },
    {
        name = UncachedDiskBytesPerSecond,
        value = 100663296
    },
    {
        name = EphemeralOSDiskSupported,
        value = True
    }
]
family = standardDSv2Family
location_info = [
    {
        location = centralus,
        zones = [1 2 3]
    }
]
name = Standard_DS2_v2
resource_type = virtualMachines
restrictions = []
size = DS2_v2
tier = Standard
zones = [
    1,
    2,
    3
]

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

thanks for the PR @MattMencel,

Would this be better as azurerm_compute_resource_sku? as you are returning the information for a single SKU, not all skus available as i would expect azurerm_compute_resource_skus would

@MattMencel
Copy link
Contributor Author

Yeah, that makes sense. I was just following along with the pattern in the API (resourceSkusClient).

I also see I'm failing tests and need to put some additional fixes in.

@MattMencel MattMencel changed the title New data source for azurerm_compute_resource_skus New data source for azurerm_compute_resource_sku Aug 15, 2019
@MattMencel
Copy link
Contributor Author

Hi @katbyte,

The resource is renamed to azurerm_compute_resource_sku. I also fixed the failing tests.

At some point, if someone really wanted to retrieve the information for multiple SKUs, it would be possible with some additions to the code. Or I could undo my new changes, and have the data resource accept a list of SKUs which it would then return the data for.

I kind of like it only returning one SKU at a time though.

@katbyte
Copy link
Collaborator

katbyte commented Aug 15, 2019

Thanks for the revisions @MattMencel,

I think it's best for this resource to only return for a single resource. If in the future we wanted to return all available SKUs or multiple i think that would be best as a separate resource azurerm_compute_resource_skus

Copy link
Collaborator

@katbyte katbyte left a comment

Choose a reason for hiding this comment

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

@MattMencel,

Given this a more thorough review, its looking good! Just a couple comments i've left inline that need to be addressed before merged

azurerm/data_source_compute_resource_sku.go Outdated Show resolved Hide resolved
azurerm/data_source_compute_resource_sku.go Outdated Show resolved Hide resolved
azurerm/data_source_compute_resource_sku.go Outdated Show resolved Hide resolved
azurerm/data_source_compute_resource_sku.go Outdated Show resolved Hide resolved
azurerm/data_source_compute_resource_sku.go Outdated Show resolved Hide resolved
azurerm/data_source_compute_resource_sku.go Outdated Show resolved Hide resolved
azurerm/data_source_compute_resource_sku_test.go Outdated Show resolved Hide resolved
azurerm/provider.go Show resolved Hide resolved
website/docs/d/compute_resource_sku.html.markdown Outdated Show resolved Hide resolved
website/docs/d/compute_resource_sku.html.markdown Outdated Show resolved Hide resolved
@katbyte katbyte changed the title New data source for azurerm_compute_resource_sku New Data Source: azurerm_compute_resource_sku Aug 18, 2019
@katbyte katbyte modified the milestones: v1.33.0, v1.34.0 Aug 21, 2019
@MattMencel MattMencel force-pushed the compute_sku_data_source branch 3 times, most recently from c9870aa to 77d29b5 Compare August 26, 2019 15:03
@MattMencel
Copy link
Contributor Author

@katbyte I think I've addressed the issues you highlighted. I removed all the TODOs. Still not 100% sure on the code for restriction info, but I think it's ok. There are currently zero compute SKUs in any region that have restrictions so I don't see an easy way to verify those at the moment.

@ghost ghost removed the waiting-response label Aug 26, 2019
@tombuildsstuff tombuildsstuff removed their assignment Aug 29, 2019
@tombuildsstuff tombuildsstuff modified the milestones: v1.34.0, v1.35.0 Sep 12, 2019
@MattMencel MattMencel force-pushed the compute_sku_data_source branch 3 times, most recently from 6d3e8e8 to ec1f946 Compare September 17, 2019 15:25
@MattMencel
Copy link
Contributor Author

Updated my branch to the latest commits and made some corrections. The lint test failed due to an out of memory error.

@tombuildsstuff tombuildsstuff modified the milestones: v1.35.0, v1.36.0 Oct 2, 2019
@tombuildsstuff tombuildsstuff modified the milestones: v1.36.0, v1.37.0 Oct 24, 2019
@tombuildsstuff tombuildsstuff modified the milestones: v1.37.0, v2.0.0 Oct 31, 2019
@tombuildsstuff tombuildsstuff modified the milestones: v2.0.0, v2.1.0 Feb 18, 2020
@tombuildsstuff tombuildsstuff modified the milestones: v2.1.0, v2.3.0 Mar 11, 2020
@tombuildsstuff tombuildsstuff modified the milestones: v2.3.0, v2.5.0 Mar 24, 2020
@tombuildsstuff tombuildsstuff removed this from the v2.5.0 milestone Apr 3, 2020
@katbyte
Copy link
Collaborator

katbyte commented Apr 7, 2020

Hi @MattMencel,

Thank you for this PR and the changes, but upon internal discussion we have decided that the use case of getting the zones for a region/service is probably better served by a more purpose specific azurerm_zones datasource that allows a user to specify a Resource (Microsoft.Compute/virtualMachines)/ and a region (westus) returning just the zones. It seems that is the only output from this datasource that would be useful in terraform and is required for other resource types as well. Given this, whilst I’d like to thank you for this PR, since we’re looking to take a different direction here I’m going to close this PR - but apologies this sat idle for so long.

@katbyte katbyte closed this Apr 7, 2020
@ghost
Copy link

ghost commented May 8, 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 👉 [email protected]. Thanks!

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

Successfully merging this pull request may close these issues.

3 participants