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.95.0 (build f1ff514)", date="2024-03-26T18:09:22.717Z") @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

    Constructors
    Modifier
    Constructor
    Description
    protected
    CloudFormationInit(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    CloudFormationInit(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    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.
    Use an existing InitConfig object as the default and only config.
    Build a CloudFormationInit from config sets.
    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

      @Stability(Stable) @NotNull public static CloudFormationInit fromConfig(@NotNull InitConfig config)
      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

      @Stability(Stable) public void addConfig(@NotNull String configName, @NotNull InitConfig config)
      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

      @Stability(Stable) public void addConfigSet(@NotNull String configSetName)
      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() or autoScalingGroup.applyCloudFormationInit() to trigger this method.

      This method does the following:

      • Renders the AWS::CloudFormation::Init object to the given resource's metadata, potentially adding a AWS::CloudFormation::Authentication object next to it if required.
      • Updates the instance role policy to be able to call the APIs required for cfn-init and cfn-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.