Class InitPackage
A package to be installed during cfn-init time.
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class InitPackage : InitElement
Syntax (vb)
Public Class InitPackage
Inherits InitElement
Remarks
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
InitPackage(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
InitPackage(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
InitPackage(String, String[], String, InitServiceRestartHandle[]) |
Properties
ElementType | Returns the init element type for this element. |
Methods
Apt(String, INamedPackageOptions) | Install a package using APT. |
Msi(String, ILocationPackageOptions) | Install an MSI package from an HTTP URL or a location on disk. |
Python(String, INamedPackageOptions) | Install a package from PyPI. |
RenderPackageVersions() | |
Rpm(String, ILocationPackageOptions) | Install an RPM from an HTTP URL or a location on disk. |
RubyGem(String, INamedPackageOptions) | Install a package from RubyGems. |
Yum(String, INamedPackageOptions) | Install a package using Yum. |
Constructors
InitPackage(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected InitPackage(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
InitPackage(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected InitPackage(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
InitPackage(String, String[], String, InitServiceRestartHandle[])
public InitPackage(string type, string[] versions, string packageName = null, InitServiceRestartHandle[] serviceHandles = null)
Parameters
- type System.String
- versions System.String[]
- packageName System.String
- serviceHandles InitServiceRestartHandle[]
Properties
ElementType
Returns the init element type for this element.
public override string ElementType { get; }
Property Value
System.String
Overrides
Methods
Apt(String, INamedPackageOptions)
Install a package using APT.
public static InitPackage Apt(string packageName, INamedPackageOptions options = null)
Parameters
- packageName System.String
- options INamedPackageOptions
Returns
Msi(String, ILocationPackageOptions)
Install an MSI package from an HTTP URL or a location on disk.
public static InitPackage Msi(string location, ILocationPackageOptions options = null)
Parameters
- location System.String
- options ILocationPackageOptions
Returns
Python(String, INamedPackageOptions)
Install a package from PyPI.
public static InitPackage Python(string packageName, INamedPackageOptions options = null)
Parameters
- packageName System.String
- options INamedPackageOptions
Returns
RenderPackageVersions()
protected virtual object RenderPackageVersions()
Returns
System.Object
Rpm(String, ILocationPackageOptions)
Install an RPM from an HTTP URL or a location on disk.
public static InitPackage Rpm(string location, ILocationPackageOptions options = null)
Parameters
- location System.String
- options ILocationPackageOptions
Returns
RubyGem(String, INamedPackageOptions)
Install a package from RubyGems.
public static InitPackage RubyGem(string gemName, INamedPackageOptions options = null)
Parameters
- gemName System.String
- options INamedPackageOptions
Returns
Yum(String, INamedPackageOptions)
Install a package using Yum.
public static InitPackage Yum(string packageName, INamedPackageOptions options = null)
Parameters
- packageName System.String
- options INamedPackageOptions
Returns