Class InitPackage

java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ec2.InitElement
software.amazon.awscdk.services.ec2.InitPackage
All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable

@Generated(value="jsii-pacmak/1.97.0 (build 729de35)", date="2024-04-24T21:00:28.888Z") @Stability(Stable) public class InitPackage extends InitElement
A package to be installed during cfn-init time.

Example:

 Vpc vpc;
 InstanceType instanceType;
 IMachineImage machineImage;
 Instance.Builder.create(this, "Instance")
         .vpc(vpc)
         .instanceType(instanceType)
         .machineImage(machineImage)
         // Showing the most complex setup, if you have simpler requirements
         // you can use `CloudFormationInit.fromElements()`.
         .init(CloudFormationInit.fromConfigSets(ConfigSetProps.builder()
                 .configSets(Map.of(
                         // Applies the configs below in this order
                         "default", List.of("yumPreinstall", "config")))
                 .configs(Map.of(
                         "yumPreinstall", new InitConfig(List.of(InitPackage.yum("git"))),
                         "config", new InitConfig(List.of(InitFile.fromObject("/etc/stack.json", Map.of(
                                 "stackId", Stack.of(this).getStackId(),
                                 "stackName", Stack.of(this).getStackName(),
                                 "region", Stack.of(this).getRegion())), 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")))))
                 .build()))
         .initOptions(ApplyCloudFormationInitOptions.builder()
                 // Optional, which configsets to activate (['default'] by default)
                 .configSets(List.of("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)
                 .build())
         .build();
 
  • Constructor Details

    • InitPackage

      protected InitPackage(software.amazon.jsii.JsiiObjectRef objRef)
    • InitPackage

      protected InitPackage(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • InitPackage

      @Stability(Stable) protected InitPackage(@NotNull String type, @NotNull List<String> versions, @Nullable String packageName, @Nullable List<InitServiceRestartHandle> serviceHandles)
      Parameters:
      type - This parameter is required.
      versions - This parameter is required.
      packageName -
      serviceHandles -
    • InitPackage

      @Stability(Stable) protected InitPackage(@NotNull String type, @NotNull List<String> versions, @Nullable String packageName)
      Parameters:
      type - This parameter is required.
      versions - This parameter is required.
      packageName -
    • InitPackage

      @Stability(Stable) protected InitPackage(@NotNull String type, @NotNull List<String> versions)
      Parameters:
      type - This parameter is required.
      versions - This parameter is required.
  • Method Details

    • apt

      @Stability(Stable) @NotNull public static InitPackage apt(@NotNull String packageName, @Nullable NamedPackageOptions options)
      Install a package using APT.

      Parameters:
      packageName - This parameter is required.
      options -
    • apt

      @Stability(Stable) @NotNull public static InitPackage apt(@NotNull String packageName)
      Install a package using APT.

      Parameters:
      packageName - This parameter is required.
    • msi

      @Stability(Stable) @NotNull public static InitPackage msi(@NotNull String location, @Nullable LocationPackageOptions options)
      Install an MSI package from an HTTP URL or a location on disk.

      Parameters:
      location - This parameter is required.
      options -
    • msi

      @Stability(Stable) @NotNull public static InitPackage msi(@NotNull String location)
      Install an MSI package from an HTTP URL or a location on disk.

      Parameters:
      location - This parameter is required.
    • python

      @Stability(Stable) @NotNull public static InitPackage python(@NotNull String packageName, @Nullable NamedPackageOptions options)
      Install a package from PyPI.

      Parameters:
      packageName - This parameter is required.
      options -
    • python

      @Stability(Stable) @NotNull public static InitPackage python(@NotNull String packageName)
      Install a package from PyPI.

      Parameters:
      packageName - This parameter is required.
    • rpm

      @Stability(Stable) @NotNull public static InitPackage rpm(@NotNull String location, @Nullable LocationPackageOptions options)
      Install an RPM from an HTTP URL or a location on disk.

      Parameters:
      location - This parameter is required.
      options -
    • rpm

      @Stability(Stable) @NotNull public static InitPackage rpm(@NotNull String location)
      Install an RPM from an HTTP URL or a location on disk.

      Parameters:
      location - This parameter is required.
    • rubyGem

      @Stability(Stable) @NotNull public static InitPackage rubyGem(@NotNull String gemName, @Nullable NamedPackageOptions options)
      Install a package from RubyGems.

      Parameters:
      gemName - This parameter is required.
      options -
    • rubyGem

      @Stability(Stable) @NotNull public static InitPackage rubyGem(@NotNull String gemName)
      Install a package from RubyGems.

      Parameters:
      gemName - This parameter is required.
    • yum

      @Stability(Stable) @NotNull public static InitPackage yum(@NotNull String packageName, @Nullable NamedPackageOptions options)
      Install a package using Yum.

      Parameters:
      packageName - This parameter is required.
      options -
    • yum

      @Stability(Stable) @NotNull public static InitPackage yum(@NotNull String packageName)
      Install a package using Yum.

      Parameters:
      packageName - This parameter is required.
    • renderPackageVersions

      @Stability(Stable) @NotNull protected Object renderPackageVersions()
    • getElementType

      @Stability(Stable) @NotNull public String getElementType()
      Returns the init element type for this element.
      Specified by:
      getElementType in class InitElement