Skip to content

chore(examples/templates/azure-linux): migrate to hashicorp/cloud-init provider #15785

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

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions examples/templates/azure-linux/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ terraform {
azurerm = {
source = "hashicorp/azurerm"
}
cloudinit = {
source = "hashicorp/cloudinit"
}
}
}

Expand Down Expand Up @@ -167,12 +170,24 @@ module "jetbrains_gateway" {

locals {
prefix = "coder-${data.coder_workspace_owner.me.name}-${data.coder_workspace.me.name}"
}

data "cloudinit_config" "user_data" {
gzip = false
base64_encode = true

userdata = templatefile("cloud-config.yaml.tftpl", {
username = "coder" # Ensure this user/group does not exist in your VM image
init_script = base64encode(coder_agent.main.init_script)
hostname = lower(data.coder_workspace.me.name)
})
boundary = "//"

part {
filename = "cloud-config.yaml"
content_type = "text/cloud-config"

content = templatefile("${path.module}/cloud-init/cloud-config.yaml.tftpl", {
username = "coder" # Ensure this user/group does not exist in your VM image
init_script = base64encode(coder_agent.main.init_script)
hostname = lower(data.coder_workspace.me.name)
})
}
}

resource "azurerm_resource_group" "main" {
Expand Down Expand Up @@ -275,7 +290,7 @@ resource "azurerm_linux_virtual_machine" "main" {
sku = "20_04-lts-gen2"
version = "latest"
}
user_data = base64encode(local.userdata)
user_data = data.cloudinit_config.user_data.rendered

tags = {
Coder_Provisioned = "true"
Expand Down
Loading