Terraform: mudanças entre as edições

De Wiki Clusterlab.com.br
Ir para navegação Ir para pesquisar
(Criou página com '=IF Statement= I want an module in terraform which is able to execute two different codes. <br> One with a image from a Publisher and other with a custom image.<br> Codes abov...')
 
Sem resumo de edição
Linha 3: Linha 3:
One with a image from a Publisher and other with a custom image.<br>
One with a image from a Publisher and other with a custom image.<br>
Codes above show how to specify both operations in the same module:
Codes above show how to specify both operations in the same module:
<syntaxhighlight lang=text line=1 highlight=5-9>
<syntaxhighlight lang=text highlight=5-9>
module "virtualmachine" {
module "virtualmachine" {
   source = "git@github.com:accountname/git.git///path?ref=xxxxxxxx"
   source = "git@github.com:accountname/git.git///path?ref=xxxxxxxx"
Linha 18: Linha 18:
}
}
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang=text line=1 highlight=5-6>
<syntaxhighlight lang=text highlight=5-6>
module "virtualmachine" {
module "virtualmachine" {
   source = "git@github.com:accountname/git.git///path?ref=xxxxxxxx"
   source = "git@github.com:accountname/git.git///path?ref=xxxxxxxx"
Linha 30: Linha 30:
}
}
</syntaxhighlight>
</syntaxhighlight>
<syntaxhighlight lang=text line=1 highlight=2,8>
<syntaxhighlight lang=text highlight=2,8>
resource "azurerm_virtual_machine" "image" {
resource "azurerm_virtual_machine" "image" {
   count = "${format("%.1s", var.vm_image_reference) == "y" ? 1 : 0}"
   count = "${format("%.1s", var.vm_image_reference) == "y" ? 1 : 0}"

Edição das 15h08min de 15 de julho de 2019

IF Statement

I want an module in terraform which is able to execute two different codes.
One with a image from a Publisher and other with a custom image.
Codes above show how to specify both operations in the same module:

module "virtualmachine" {
  source = "git@github.com:accountname/git.git///path?ref=xxxxxxxx"
  vm_name = "virtualmachine"
  location = "East US 2"
  vm_image_reference = "no"
  image_publisher = "MicrosoftSQLServer"
  image_offer     = "SQL2016SP1-WS2016"
  image_sku       = "Enterprise"
  image_version   = "latest"
  vm_size = "Standard_DS11_v2"
  vm_disk_type = "Premium_LRS"
  vm_data_disks = ["1023"]
}
module "virtualmachine" {
  source = "git@github.com:accountname/git.git///path?ref=xxxxxxxx"
  vm_name = "virtualmachine"
  location = "East US 2"
  vm_image_reference = "yes"
  vm_image = "/subscriptions/xxxxxxxxxxxxx/resourceGroups/Images/providers/Microsoft.Compute/images/centos_720201230"
  vm_size = "Standard_DS11_v2"
  vm_disk_type = "Premium_LRS"
  vm_data_disks = ["1023"]
}
resource "azurerm_virtual_machine" "image" {
  count = "${format("%.1s", var.vm_image_reference) == "y" ? 1 : 0}"
.
.
.
}
resource "azurerm_virtual_machine" "market" {
  count = "${format("%.1s", var.vm_image_reference) == "n" ? 1 : 0}"
.
.
.
}