Class CloudFormationInit
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ec2.CloudFormationInit
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.109.0 (build c221850)",
date="2025-03-14T03:24:57.186Z")
@Stability(Stable)
public class CloudFormationInit
extends software.amazon.jsii.JsiiObject
A CloudFormation-init configuration.
Example:
Vpc vpc; InstanceType instanceType; Instance.Builder.create(this, "Instance") .vpc(vpc) .instanceType(instanceType) .machineImage(MachineImage.latestAmazonLinux2023()) .init(CloudFormationInit.fromElements(InitService.systemdConfigFile("simpleserver", SystemdConfigFileOptions.builder() .command("/usr/bin/python3 -m http.server 8080") .cwd("/var/www/html") .build()), InitService.enable("simpleserver", InitServiceOptions.builder() .serviceManager(ServiceManager.SYSTEMD) .build()), InitFile.fromString("/var/www/html/index.html", "Hello! It's working!"))) .build();
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
CloudFormationInit
(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protected
CloudFormationInit
(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConfig
(String configName, InitConfig config) Add a config with the given name to this CloudFormationInit object.void
addConfigSet
(String configSetName) Add a config set with the given name to this CloudFormationInit object.void
addConfigSet
(String configSetName, List<String> configNames) Add a config set with the given name to this CloudFormationInit object.void
attach
(CfnResource attachedResource, AttachInitOptions attachOptions) Attach the CloudFormation Init config to the given resource.static CloudFormationInit
fromConfig
(InitConfig config) Use an existing InitConfig object as the default and only config.static CloudFormationInit
fromConfigSets
(ConfigSetProps props) Build a CloudFormationInit from config sets.static CloudFormationInit
fromElements
(@NotNull InitElement... elements) Build a new config from a set of Init Elements.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
CloudFormationInit
protected CloudFormationInit(software.amazon.jsii.JsiiObjectRef objRef) -
CloudFormationInit
protected CloudFormationInit(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
-
-
Method Details
-
fromConfig
Use an existing InitConfig object as the default and only config.- Parameters:
config
- This parameter is required.
-
fromConfigSets
@Stability(Stable) @NotNull public static CloudFormationInit fromConfigSets(@NotNull ConfigSetProps props) Build a CloudFormationInit from config sets.- Parameters:
props
- This parameter is required.
-
fromElements
@Stability(Stable) @NotNull public static CloudFormationInit fromElements(@NotNull @NotNull InitElement... elements) Build a new config from a set of Init Elements.- Parameters:
elements
- This parameter is required.
-
addConfig
Add a config with the given name to this CloudFormationInit object.- Parameters:
configName
- This parameter is required.config
- This parameter is required.
-
addConfigSet
@Stability(Stable) public void addConfigSet(@NotNull String configSetName, @Nullable List<String> configNames) Add a config set with the given name to this CloudFormationInit object.The new configset will reference the given configs in the given order.
- Parameters:
configSetName
- This parameter is required.configNames
-
-
addConfigSet
Add a config set with the given name to this CloudFormationInit object.The new configset will reference the given configs in the given order.
- Parameters:
configSetName
- This parameter is required.
-
attach
@Stability(Stable) public void attach(@NotNull CfnResource attachedResource, @NotNull AttachInitOptions attachOptions) Attach the CloudFormation Init config to the given resource.As an app builder, use
instance.applyCloudFormationInit()
orautoScalingGroup.applyCloudFormationInit()
to trigger this method.This method does the following:
- Renders the
AWS::CloudFormation::Init
object to the given resource's metadata, potentially adding aAWS::CloudFormation::Authentication
object next to it if required. - Updates the instance role policy to be able to call the APIs required for
cfn-init
andcfn-signal
to work, and potentially add permissions to download referenced asset and bucket resources. - Updates the given UserData with commands to execute the
cfn-init
script.
- Parameters:
attachedResource
- This parameter is required.attachOptions
- This parameter is required.
- Renders the
-