Created
March 26, 2022 13:23
-
-
Save jjylik/b7a8a41005d90eb43b3e9af7705990e2 to your computer and use it in GitHub Desktop.
Pulumi configs to user data script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as pulumi from '@pulumi/pulumi' | |
import {Droplet, DropletSlug, Region} from '@pulumi/digitalocean'; | |
import * as fs from 'fs'; | |
const dropletName = 'myDroplet'; | |
const region = Region.AMS2; | |
const size = DropletSlug.DropletS1VCPU1GB; | |
const config = new pulumi.Config(); | |
const someConfig = config.require('someconfig'); | |
const someOtherConfig = config.require('someotherconfig'); | |
const baseUserData = fs.readFileSync('./user-data.sh', 'utf8') | |
const userData = pulumi.all([someConfig, someOtherConfig]).apply(([some, other]) => { | |
return ` | |
#!/bin/bash | |
export SOMETHING_I_NEED_IN_SCRIPT=${some} | |
export SOMETHING_ELSE_I_NEED_IN_SCRIPT=${other} | |
${baseUserData} | |
`; | |
}); | |
const droplet = new Droplet(dropletName, { | |
image: 'ubuntu-20-04-x64', | |
region, | |
size, | |
monitoring: true, | |
userData, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment