Class CloudFormationInit
A CloudFormation-init configuration.
Inheritance
Namespace: Amazon.CDK.AWS.EC2
Assembly: Amazon.CDK.Lib.dll
Syntax (csharp)
public class CloudFormationInit : DeputyBase
Syntax (vb)
Public Class CloudFormationInit
Inherits DeputyBase
Remarks
ExampleMetadata: infused
Examples
Vpc vpc;
InstanceType instanceType;
new Instance(this, "Instance", new InstanceProps {
Vpc = vpc,
InstanceType = instanceType,
MachineImage = MachineImage.LatestAmazonLinux2023(),
Init = CloudFormationInit.FromElements(InitService.SystemdConfigFile("simpleserver", new SystemdConfigFileOptions {
Command = "/usr/bin/python3 -m http.server 8080",
Cwd = "/var/www/html"
}), InitService.Enable("simpleserver", new InitServiceOptions {
ServiceManager = ServiceManager.SYSTEMD
}), InitFile.FromString("/var/www/html/index.html", "Hello! It's working!"))
});
Synopsis
Constructors
CloudFormationInit(ByRefValue) | Used by jsii to construct an instance of this class from a Javascript-owned object reference |
CloudFormationInit(DeputyBase.DeputyProps) | Used by jsii to construct an instance of this class from DeputyProps |
Methods
AddConfig(String, InitConfig) | Add a config with the given name to this CloudFormationInit object. |
AddConfigSet(String, String[]) | Add a config set with the given name to this CloudFormationInit object. |
Attach(CfnResource, IAttachInitOptions) | Attach the CloudFormation Init config to the given resource. |
FromConfig(InitConfig) | Use an existing InitConfig object as the default and only config. |
FromConfigSets(IConfigSetProps) | Build a CloudFormationInit from config sets. |
FromElements(InitElement[]) | Build a new config from a set of Init Elements. |
Constructors
CloudFormationInit(ByRefValue)
Used by jsii to construct an instance of this class from a Javascript-owned object reference
protected CloudFormationInit(ByRefValue reference)
Parameters
- reference Amazon.JSII.Runtime.Deputy.ByRefValue
The Javascript-owned object reference
CloudFormationInit(DeputyBase.DeputyProps)
Used by jsii to construct an instance of this class from DeputyProps
protected CloudFormationInit(DeputyBase.DeputyProps props)
Parameters
- props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps
The deputy props
Methods
AddConfig(String, InitConfig)
Add a config with the given name to this CloudFormationInit object.
public virtual void AddConfig(string configName, InitConfig config)
Parameters
- configName System.String
- config InitConfig
AddConfigSet(String, String[])
Add a config set with the given name to this CloudFormationInit object.
public virtual void AddConfigSet(string configSetName, string[] configNames = null)
Parameters
- configSetName System.String
- configNames System.String[]
Remarks
The new configset will reference the given configs in the given order.
Attach(CfnResource, IAttachInitOptions)
Attach the CloudFormation Init config to the given resource.
public virtual void Attach(CfnResource attachedResource, IAttachInitOptions attachOptions)
Parameters
- attachedResource CfnResource
- attachOptions IAttachInitOptions
Remarks
As an app builder, use instance.applyCloudFormationInit()
or
autoScalingGroup.applyCloudFormationInit()
to trigger this method.
This method does the following:
FromConfig(InitConfig)
Use an existing InitConfig object as the default and only config.
public static CloudFormationInit FromConfig(InitConfig config)
Parameters
- config InitConfig
Returns
FromConfigSets(IConfigSetProps)
Build a CloudFormationInit from config sets.
public static CloudFormationInit FromConfigSets(IConfigSetProps props)
Parameters
- props IConfigSetProps
Returns
FromElements(InitElement[])
Build a new config from a set of Init Elements.
public static CloudFormationInit FromElements(params InitElement[] elements)
Parameters
- elements InitElement[]
Returns