Skip to content

Commit 81279a9

Browse files
authored
chore(examples/templates/azure-linux): migrate to hashicorp/cloud-init provider (#15785)
1 parent 901ad3f commit 81279a9

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

examples/templates/azure-linux/main.tf

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@ terraform {
66
azurerm = {
77
source = "hashicorp/azurerm"
88
}
9+
cloudinit = {
10+
source = "hashicorp/cloudinit"
11+
}
912
}
1013
}
1114

@@ -167,12 +170,24 @@ module "jetbrains_gateway" {
167170

168171
locals {
169172
prefix = "coder-${data.coder_workspace_owner.me.name}-${data.coder_workspace.me.name}"
173+
}
174+
175+
data "cloudinit_config" "user_data" {
176+
gzip = false
177+
base64_encode = true
170178

171-
userdata = templatefile("cloud-config.yaml.tftpl", {
172-
username = "coder" # Ensure this user/group does not exist in your VM image
173-
init_script = base64encode(coder_agent.main.init_script)
174-
hostname = lower(data.coder_workspace.me.name)
175-
})
179+
boundary = "//"
180+
181+
part {
182+
filename = "cloud-config.yaml"
183+
content_type = "text/cloud-config"
184+
185+
content = templatefile("${path.module}/cloud-init/cloud-config.yaml.tftpl", {
186+
username = "coder" # Ensure this user/group does not exist in your VM image
187+
init_script = base64encode(coder_agent.main.init_script)
188+
hostname = lower(data.coder_workspace.me.name)
189+
})
190+
}
176191
}
177192

178193
resource "azurerm_resource_group" "main" {
@@ -275,7 +290,7 @@ resource "azurerm_linux_virtual_machine" "main" {
275290
sku = "20_04-lts-gen2"
276291
version = "latest"
277292
}
278-
user_data = base64encode(local.userdata)
293+
user_data = data.cloudinit_config.user_data.rendered
279294

280295
tags = {
281296
Coder_Provisioned = "true"

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy