Search in sources :

Example 1 with CreateLaunchConfigurationRequest

use of com.amazonaws.services.autoscaling.model.CreateLaunchConfigurationRequest in project incubator-gobblin by apache.

the class AWSSdkClient method createLaunchConfig.

/**
 * Create a launch configuration that can be later used to create {@link AmazonAutoScaling} groups
 *
 * @param launchConfigName Desired launch config name
 * @param imageId AMI image id to use
 * @param instanceType EC2 instance type to use
 * @param keyName Key name
 * @param securityGroups Security groups to apply
 * @param kernelId Optional kernel id
 * @param ramdiskId Optional ram disk id
 * @param blockDeviceMapping Optional EBS device mapping
 * @param iamInstanceProfile Optional IAM instance profile
 * @param instanceMonitoring Optional instance monitoring
 * @param userData User data (eg. shell script to execute at instance boot under this launch config)
 */
public void createLaunchConfig(String launchConfigName, String imageId, String instanceType, String keyName, String securityGroups, Optional<String> kernelId, Optional<String> ramdiskId, Optional<BlockDeviceMapping> blockDeviceMapping, Optional<String> iamInstanceProfile, Optional<InstanceMonitoring> instanceMonitoring, String userData) {
    final AmazonAutoScaling autoScaling = getAmazonAutoScalingClient();
    CreateLaunchConfigurationRequest createLaunchConfigurationRequest = new CreateLaunchConfigurationRequest().withLaunchConfigurationName(launchConfigName).withImageId(imageId).withInstanceType(instanceType).withSecurityGroups(SPLITTER.splitToList(securityGroups)).withKeyName(keyName).withUserData(userData);
    if (kernelId.isPresent()) {
        createLaunchConfigurationRequest = createLaunchConfigurationRequest.withKernelId(kernelId.get());
    }
    if (ramdiskId.isPresent()) {
        createLaunchConfigurationRequest = createLaunchConfigurationRequest.withRamdiskId(ramdiskId.get());
    }
    if (blockDeviceMapping.isPresent()) {
        createLaunchConfigurationRequest = createLaunchConfigurationRequest.withBlockDeviceMappings(blockDeviceMapping.get());
    }
    if (iamInstanceProfile.isPresent()) {
        createLaunchConfigurationRequest = createLaunchConfigurationRequest.withIamInstanceProfile(iamInstanceProfile.get());
    }
    if (instanceMonitoring.isPresent()) {
        createLaunchConfigurationRequest = createLaunchConfigurationRequest.withInstanceMonitoring(instanceMonitoring.get());
    }
    autoScaling.createLaunchConfiguration(createLaunchConfigurationRequest);
    LOGGER.info("Created Launch Configuration: " + launchConfigName);
}
Also used : AmazonAutoScaling(com.amazonaws.services.autoscaling.AmazonAutoScaling) CreateLaunchConfigurationRequest(com.amazonaws.services.autoscaling.model.CreateLaunchConfigurationRequest)

Aggregations

AmazonAutoScaling (com.amazonaws.services.autoscaling.AmazonAutoScaling)1 CreateLaunchConfigurationRequest (com.amazonaws.services.autoscaling.model.CreateLaunchConfigurationRequest)1