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.119.0 (build 1634eac)",
date="2025-12-01T16:02:19.369Z")
@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
ConstructorsModifierConstructorDescriptionprotectedCloudFormationInit(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedCloudFormationInit(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddConfig(String configName, InitConfig config) Add a config with the given name to this CloudFormationInit object.voidaddConfigSet(String configSetName) Add a config set with the given name to this CloudFormationInit object.voidaddConfigSet(String configSetName, List<String> configNames) Add a config set with the given name to this CloudFormationInit object.voidattach(CfnResource attachedResource, AttachInitOptions attachOptions) Attach the CloudFormation Init config to the given resource.static CloudFormationInitfromConfig(InitConfig config) Use an existing InitConfig object as the default and only config.static CloudFormationInitfromConfigSets(ConfigSetProps props) Build a CloudFormationInit from config sets.static CloudFormationInitfromElements(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, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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 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::Initobject to the given resource's metadata, potentially adding aAWS::CloudFormation::Authenticationobject next to it if required. - Updates the instance role policy to be able to call the APIs required for
cfn-initandcfn-signalto work, and potentially add permissions to download referenced asset and bucket resources. - Updates the given UserData with commands to execute the
cfn-initscript.
- Parameters:
attachedResource- This parameter is required.attachOptions- This parameter is required.
- Renders the
-