scaleway.InstanceUserData
Explore with Pulumi AI
Creates and manages Scaleway Compute Instance User Data values.
User data is a key value store API you can use to provide data from and to your server without authentication. It is the mechanism by which a user can pass information contained in a local file to an Instance at launch time.
The typical use case is to pass something like a shell script or a configuration file as user data.
For more information about user_data check our documentation guide here.
About cloud-init documentation please check this link.
Examples
Basic
import * as pulumi from "@pulumi/pulumi";
import * as scaleway from "@lbrlabs/pulumi-scaleway";
const config = new pulumi.Config();
const userData = config.getObject("userData") || {
"cloud-init": `#cloud-config
apt-update: true
apt-upgrade: true
`,
foo: "bar",
};
const mainInstanceServer = new scaleway.InstanceServer("mainInstanceServer", {
image: "ubuntu_focal",
type: "DEV1-S",
});
// User data with a single value
const mainInstanceUserData = new scaleway.InstanceUserData("mainInstanceUserData", {
serverId: mainInstanceServer.id,
key: "foo",
value: "bar",
});
// User Data with many keys.
const data: scaleway.InstanceUserData[] = [];
for (const range = {value: 0}; range.value < userData; range.value++) {
data.push(new scaleway.InstanceUserData(`data-${range.value}`, {
serverId: mainInstanceServer.id,
key: range.key,
value: range.value,
}));
}
import pulumi
import lbrlabs_pulumi_scaleway as scaleway
config = pulumi.Config()
user_data = config.get_object("userData")
if user_data is None:
user_data = {
"cloud-init": """#cloud-config
apt-update: true
apt-upgrade: true
""",
"foo": "bar",
}
main_instance_server = scaleway.InstanceServer("mainInstanceServer",
image="ubuntu_focal",
type="DEV1-S")
# User data with a single value
main_instance_user_data = scaleway.InstanceUserData("mainInstanceUserData",
server_id=main_instance_server.id,
key="foo",
value="bar")
# User Data with many keys.
data = []
for range in [{"value": i} for i in range(0, user_data)]:
data.append(scaleway.InstanceUserData(f"data-{range['value']}",
server_id=main_instance_server.id,
key=range["key"],
value=range["value"]))
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using Scaleway = Lbrlabs.PulumiPackage.Scaleway;
return await Deployment.RunAsync(() =>
{
var config = new Config();
var userData = config.GetObject<dynamic>("userData") ??
{
{ "cloud-init", @"#cloud-config
apt-update: true
apt-upgrade: true
" },
{ "foo", "bar" },
};
var mainInstanceServer = new Scaleway.InstanceServer("mainInstanceServer", new()
{
Image = "ubuntu_focal",
Type = "DEV1-S",
});
// User data with a single value
var mainInstanceUserData = new Scaleway.InstanceUserData("mainInstanceUserData", new()
{
ServerId = mainInstanceServer.Id,
Key = "foo",
Value = "bar",
});
// User Data with many keys.
var data = new List<Scaleway.InstanceUserData>();
for (var rangeIndex = 0; rangeIndex < userData; rangeIndex++)
{
var range = new { Value = rangeIndex };
data.Add(new Scaleway.InstanceUserData($"data-{range.Value}", new()
{
ServerId = mainInstanceServer.Id,
Key = range.Key,
Value = range.Value,
}));
}
});
package main
import (
"github.com/lbrlabs/pulumi-scaleway/sdk/go/scaleway"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)
func main() {
pulumi.Run(func(ctx *pulumi.Context) error {
cfg := config.New(ctx, "")
userData := map[string]interface{}{
"cloud-init": "#cloud-config\napt-update: true\napt-upgrade: true\n",
"foo": "bar",
}
if param := cfg.GetBool("userData"); param != nil {
userData = param
}
mainInstanceServer, err := scaleway.NewInstanceServer(ctx, "mainInstanceServer", &scaleway.InstanceServerArgs{
Image: pulumi.String("ubuntu_focal"),
Type: pulumi.String("DEV1-S"),
})
if err != nil {
return err
}
_, err = scaleway.NewInstanceUserData(ctx, "mainInstanceUserData", &scaleway.InstanceUserDataArgs{
ServerId: mainInstanceServer.ID(),
Key: pulumi.String("foo"),
Value: pulumi.String("bar"),
})
if err != nil {
return err
}
var data []*scaleway.InstanceUserData
for index := 0; index < userData; index++ {
key0 := index
val0 := index
__res, err := scaleway.NewInstanceUserData(ctx, fmt.Sprintf("data-%v", key0), &scaleway.InstanceUserDataArgs{
ServerId: mainInstanceServer.ID(),
Key: pulumi.Any(key0),
Value: pulumi.Any(val0),
})
if err != nil {
return err
}
data = append(data, __res)
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.scaleway.InstanceServer;
import com.pulumi.scaleway.InstanceServerArgs;
import com.pulumi.scaleway.InstanceUserData;
import com.pulumi.scaleway.InstanceUserDataArgs;
import com.pulumi.codegen.internal.KeyedValue;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;
public class App {
public static void main(String[] args) {
Pulumi.run(App::stack);
}
public static void stack(Context ctx) {
final var config = ctx.config();
final var userData = config.get("userData").orElse(%!v(PANIC=Format method: runtime error: invalid memory address or nil pointer dereference));
var mainInstanceServer = new InstanceServer("mainInstanceServer", InstanceServerArgs.builder()
.image("ubuntu_focal")
.type("DEV1-S")
.build());
var mainInstanceUserData = new InstanceUserData("mainInstanceUserData", InstanceUserDataArgs.builder()
.serverId(mainInstanceServer.id())
.key("foo")
.value("bar")
.build());
for (var i = 0; i < userData; i++) {
new InstanceUserData("data-" + i, InstanceUserDataArgs.builder()
.serverId(mainInstanceServer.id())
.key(range.key())
.value(range.value())
.build());
}
}
}
configuration:
userData:
type: dynamic
default:
cloud-init: |
#cloud-config
apt-update: true
apt-upgrade: true
foo: bar
resources:
# User data with a single value
mainInstanceUserData:
type: scaleway:InstanceUserData
properties:
serverId: ${mainInstanceServer.id}
key: foo
value: bar
# User Data with many keys.
data:
type: scaleway:InstanceUserData
properties:
serverId: ${mainInstanceServer.id}
key: ${range.key}
value: ${range.value}
options: {}
mainInstanceServer:
type: scaleway:InstanceServer
properties:
image: ubuntu_focal
type: DEV1-S
Create InstanceUserData Resource
new InstanceUserData(name: string, args: InstanceUserDataArgs, opts?: CustomResourceOptions);
@overload
def InstanceUserData(resource_name: str,
opts: Optional[ResourceOptions] = None,
key: Optional[str] = None,
server_id: Optional[str] = None,
value: Optional[str] = None,
zone: Optional[str] = None)
@overload
def InstanceUserData(resource_name: str,
args: InstanceUserDataArgs,
opts: Optional[ResourceOptions] = None)
func NewInstanceUserData(ctx *Context, name string, args InstanceUserDataArgs, opts ...ResourceOption) (*InstanceUserData, error)
public InstanceUserData(string name, InstanceUserDataArgs args, CustomResourceOptions? opts = null)
public InstanceUserData(String name, InstanceUserDataArgs args)
public InstanceUserData(String name, InstanceUserDataArgs args, CustomResourceOptions options)
type: scaleway:InstanceUserData
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args InstanceUserDataArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- resource_name str
- The unique name of the resource.
- args InstanceUserDataArgs
- The arguments to resource properties.
- opts ResourceOptions
- Bag of options to control resource's behavior.
- ctx Context
- Context object for the current deployment.
- name string
- The unique name of the resource.
- args InstanceUserDataArgs
- The arguments to resource properties.
- opts ResourceOption
- Bag of options to control resource's behavior.
- name string
- The unique name of the resource.
- args InstanceUserDataArgs
- The arguments to resource properties.
- opts CustomResourceOptions
- Bag of options to control resource's behavior.
- name String
- The unique name of the resource.
- args InstanceUserDataArgs
- The arguments to resource properties.
- options CustomResourceOptions
- Bag of options to control resource's behavior.
InstanceUserData Resource Properties
To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.
Inputs
The InstanceUserData resource accepts the following input properties:
- Key string
Key of the user data.
- Server
Id string The ID of the server associated with.
- Value string
Value associated with your key
- Zone string
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- Key string
Key of the user data.
- Server
Id string The ID of the server associated with.
- Value string
Value associated with your key
- Zone string
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- key String
Key of the user data.
- server
Id String The ID of the server associated with.
- value String
Value associated with your key
- zone String
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- key string
Key of the user data.
- server
Id string The ID of the server associated with.
- value string
Value associated with your key
- zone string
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- key str
Key of the user data.
- server_
id str The ID of the server associated with.
- value str
Value associated with your key
- zone str
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- key String
Key of the user data.
- server
Id String The ID of the server associated with.
- value String
Value associated with your key
- zone String
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
Outputs
All input properties are implicitly available as output properties. Additionally, the InstanceUserData resource produces the following output properties:
- Id string
The provider-assigned unique ID for this managed resource.
- Id string
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
- id string
The provider-assigned unique ID for this managed resource.
- id str
The provider-assigned unique ID for this managed resource.
- id String
The provider-assigned unique ID for this managed resource.
Look up Existing InstanceUserData Resource
Get an existing InstanceUserData resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.
public static get(name: string, id: Input<ID>, state?: InstanceUserDataState, opts?: CustomResourceOptions): InstanceUserData
@staticmethod
def get(resource_name: str,
id: str,
opts: Optional[ResourceOptions] = None,
key: Optional[str] = None,
server_id: Optional[str] = None,
value: Optional[str] = None,
zone: Optional[str] = None) -> InstanceUserData
func GetInstanceUserData(ctx *Context, name string, id IDInput, state *InstanceUserDataState, opts ...ResourceOption) (*InstanceUserData, error)
public static InstanceUserData Get(string name, Input<string> id, InstanceUserDataState? state, CustomResourceOptions? opts = null)
public static InstanceUserData get(String name, Output<String> id, InstanceUserDataState state, CustomResourceOptions options)
Resource lookup is not supported in YAML
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- resource_name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- name
- The unique name of the resulting resource.
- id
- The unique provider ID of the resource to lookup.
- state
- Any extra arguments used during the lookup.
- opts
- A bag of options that control this resource's behavior.
- Key string
Key of the user data.
- Server
Id string The ID of the server associated with.
- Value string
Value associated with your key
- Zone string
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- Key string
Key of the user data.
- Server
Id string The ID of the server associated with.
- Value string
Value associated with your key
- Zone string
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- key String
Key of the user data.
- server
Id String The ID of the server associated with.
- value String
Value associated with your key
- zone String
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- key string
Key of the user data.
- server
Id string The ID of the server associated with.
- value string
Value associated with your key
- zone string
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- key str
Key of the user data.
- server_
id str The ID of the server associated with.
- value str
Value associated with your key
- zone str
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
- key String
Key of the user data.
- server
Id String The ID of the server associated with.
- value String
Value associated with your key
- zone String
zone
) The zone in which the server should be created.Important: Use the
cloud-init
key to use cloud-init on your instance. You can define values using:- string
- UTF-8 encoded file content using file
Import
User data can be imported using the {zone}/{key}/{server_id}
, e.g. bash
$ pulumi import scaleway:index/instanceUserData:InstanceUserData main fr-par-1/cloud-init/11111111-1111-1111-1111-111111111111
Package Details
- Repository
- scaleway lbrlabs/pulumi-scaleway
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
scaleway
Terraform Provider.