@@ -34,23 +34,22 @@ resource "aws_security_group" "unison" {
3434 }
3535}
3636
37- locals {
38- unison_user_data = base64encode (templatefile (" ${ path . module } /cloud-init.yaml" , {
39- unison_cloud_image_tag = var.unison_cloud_image_tag
40- region = data.aws_region.current.name
41- config_template = base64encode (data. template_file . config_template . rendered )
42- }))
43- }
44-
45- data "template_file" "config_template" {
46- template = file (" ${ path . module } /config.json.template" )
47- vars = {
48- blob_bucket_name = aws_s3_bucket.unison_cloud_byoc_blobs.bucket
49- services_bucket_name = aws_s3_bucket.unison_cloud_byoc_native_services.bucket
50- cluster_token = data.http.cluster_token.response_body
51- region = data.aws_region.current.name
52- dynamodb_table = aws_dynamodb_table.unison_cloud_byoc_state.id
53- cluster_name = var.cluster_name
37+ data "cloudinit_config" "unison-cloudinint" {
38+ part {
39+ merge_type = " list(append)+dict(recurse_array)+str()"
40+ content_type = " text/cloud-config"
41+ content = templatefile (" ${ path . module } /cloud-init.yaml" , {
42+ unison_cloud_image_tag = var.unison_cloud_image_tag
43+ region = data.aws_region.current.name
44+ config_template = base64encode (templatefile (" ${ path . module } /config.json.template" , {
45+ blob_bucket_name = aws_s3_bucket.unison_cloud_byoc_blobs.bucket
46+ services_bucket_name = aws_s3_bucket.unison_cloud_byoc_native_services.bucket
47+ cluster_token = data.http.cluster_token.response_body
48+ region = data.aws_region.current.name
49+ dynamodb_table = aws_dynamodb_table.unison_cloud_byoc_state.id
50+ cluster_name = var.cluster_name
51+ }))
52+ })
5453 }
5554}
5655
@@ -69,7 +68,7 @@ resource "aws_launch_template" "unison" {
6968 name = aws_iam_instance_profile. unison . name
7069 }
7170
72- user_data = local . unison_user_data
71+ user_data = data . cloudinit_config . unison-cloudinint . rendered
7372
7473 tag_specifications {
7574 resource_type = " instance"
0 commit comments