chore(examples/pulumi): add example for multi-part cloud-init

This commit is contained in:
Michele Cereda
2024-04-23 00:00:14 +02:00
parent b2641f81c4
commit a816255d95
9 changed files with 143 additions and 21 deletions

View File

@@ -0,0 +1,14 @@
#cloud-config
# Install and enable the SSM agent on supported instances.
# Tested on:
# - Amazon Linux 2023.4.20240416
package_upgrade: false
packages:
- amazon-ssm-agent
runcmd:
- systemctl daemon-reload
- systemctl enable --now 'amazon-ssm-agent.service'

View File

@@ -0,0 +1 @@
PULUMI_CONFIG_PASSPHRASE=test123

View File

@@ -0,0 +1,3 @@
/bin/
/node_modules/
/package-lock.json

View File

@@ -0,0 +1,7 @@
encryptionsalt: v1:Tl2L4ymfbTk=:v1:PNPJ5bUKKgCFe8G/:hrgipeFmFMPSAYcf5lgS6dUCe33WtA==
config:
aws:defaultTags:
tags:
ManagedBy: pulumi
PulumiProject: cloud-init.multi-part
aws:region: eu-west-1

View File

@@ -0,0 +1,9 @@
name: cloud-init.multi-part
runtime: nodejs
description: Simple example of multi-part cloud-init usage
config:
pulumi:tags:
value:
pulumi:template: typescript
backend:
url: file://.

View File

@@ -0,0 +1,23 @@
import * as cloudinit from "@pulumi/cloudinit";
import * as fs from 'fs';
export const userData = new cloudinit.Config(
"userData",
{
gzip: false,
base64Encode: false,
parts: [
{
contentType: "text/cloud-config",
content: fs.readFileSync("../../cloud-init/aws.ssm.yaml", "utf8"),
filename: "cloud-config.ssm.yml",
},
{
contentType: "text/cloud-config",
content: fs.readFileSync("../../cloud-init/docker.yum.yaml", "utf8"),
filename: "cloud-config.docker.yml",
mergeType: "dict(recurse_array,no_replace)+list(append)",
},
],
},
);

View File

@@ -0,0 +1,11 @@
{
"name": "cloud-init.multi-part",
"main": "index.ts",
"devDependencies": {
"@types/node": "^18"
},
"dependencies": {
"@pulumi/cloudinit": "^1.4.1",
"typescript": "^5.0.0"
}
}

View File

@@ -0,0 +1,18 @@
{
"compilerOptions": {
"strict": true,
"outDir": "bin",
"target": "es2020",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"experimentalDecorators": true,
"pretty": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.ts"
]
}