cool-teacher-39254
12/14/2023, 11:32 AMimport pulumi
import pulumi_cloudinit as cloudinit
class UserData(pulumi.ComponentResource):
def __init__(
self,
prefix: str,
content: str,
opts: pulumi.ResourceOptions = None
):
super().__init__('aws:UserData', prefix, {}, opts)
self.opts = pulumi.ResourceOptions(parent=self).merge(opts)
self.cloudinit_config = cloudinit.get_config(
base64_encode=True,
gzip=True,
parts=[cloudinit.GetConfigPartArgs(
content=content,
content_type="text/cloud-config"
)],
)
I'm trying to render a Jinja2 template and pass to get_config:
env = Environment(loader=FileSystemLoader('.'))
template = env.get_template('cloud_init.yml')
cloud_config_content = pulumi.Output.all(
service_name=service_name,
s3_region=current.name,
bucket_name=bucket_name,
root_password=root_password.result,
auth_tenant_id=azure_ad_application.current.tenant_id,
oauth_client_id=azure_ad_application.azuread_application.client_id,
self_signed_cert=self_cert.certificate.cert_pem,
self_signed_key=self_cert.private_key.private_key_pem
).apply(lambda kwargs: template.render(**kwargs))
then
user_data_instance = UserData(
prefix=prefix,
content=cloud_config_content
)
If I create everything in advance (like the root_password, self_signed_key) it works just great, but if any of these value changes, I got this error:
Exception: invoke of cloudinitindex/getConfiggetConfig failed: Missing required argument: The argument "part.0.content" is required, but no definition was found. ()cool-teacher-39254
12/15/2023, 6:41 AMadorable-house-61348
12/15/2023, 2:47 PM