Class InitUser
Create Linux/UNIX users and to assign user IDs.
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class InitUser : InitElement
Syntax (vb)
Public Class InitUser
Inherits InitElement
Remarks
Users are created as non-interactive system users with a shell of /sbin/nologin. This is by design and cannot be modified.
Not supported for Windows systems.
ExampleMetadata: infused
Examples
Vpc vpc;
InstanceType instanceType;
IMachineImage machineImage;
new Instance(this, "Instance", new InstanceProps {
Vpc = vpc,
InstanceType = instanceType,
MachineImage = machineImage,
// Showing the most complex setup, if you have simpler requirements
// you can use `CloudFormationInit.fromElements()`.
Init = CloudFormationInit.FromConfigSets(new ConfigSetProps {
ConfigSets = new Dictionary<string, string[]> {
// Applies the configs below in this order
{ "default", new [] { "yumPreinstall", "config" } }
},
Configs = new Dictionary<string, InitConfig> {
{ "yumPreinstall", new InitConfig(new [] { InitPackage.Yum("git") }) },
{ "config", new InitConfig(new [] { InitFile.FromObject("/etc/stack.json", new Dictionary<string, object> {
{ "stackId", Stack.Of(this).StackId },
{ "stackName", Stack.Of(this).StackName },
{ "region", Stack.Of(this).Region }
}), InitGroup.FromName("my-group"), InitUser.FromName("my-user"), InitPackage.Rpm("http://mirrors.ukfast.co.uk/sites/dl.fedoraproject.org/pub/epel/8/Everything/x86_64/Packages/r/rubygem-git-1.5.0-2.el8.noarch.rpm") }) }
}
}),
InitOptions = new ApplyCloudFormationInitOptions {
// Optional, which configsets to activate (['default'] by default)
ConfigSets = new [] { "default" },
// Optional, how long the installation is expected to take (5 minutes by default)
Timeout = Duration.Minutes(30),
// Optional, whether to include the --url argument when running cfn-init and cfn-signal commands (false by default)
IncludeUrl = true,
// Optional, whether to include the --role argument when running cfn-init and cfn-signal commands (false by default)
IncludeRole = true
}
});
Synopsis
Constructors
InitUser(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
InitUser(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
InitUser(String, IInitUserOptions) |
Properties
ElementType | Returns the init element type for this element. |
Methods
FromName(String, IInitUserOptions) | Create a user from user name. |
Constructors
InitUser(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected InitUser(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
InitUser(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected InitUser(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
InitUser(String, IInitUserOptions)
public InitUser(string userName, IInitUserOptions userOptions)
Parameters
- userName System.String
- userOptions IInitUserOptions
Properties
ElementType
Returns the init element type for this element.
public override string ElementType { get; }
Property Value
System.String
Overrides
Methods
FromName(String, IInitUserOptions)
Create a user from user name.
public static InitUser FromName(string userName, IInitUserOptions options = null)
Parameters
- userName System.String
- options IInitUserOptions
Returns