All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pulumi.alicloud.ecs.EcsKeyPairAttachment Maven / Gradle / Ivy

There is a newer version: 3.63.0-alpha.1727424957
Show newest version
// *** WARNING: this file was generated by pulumi-java-gen. ***
// *** Do not edit by hand unless you're certain you know what you are doing! ***

package com.pulumi.alicloud.ecs;

import com.pulumi.alicloud.Utilities;
import com.pulumi.alicloud.ecs.EcsKeyPairAttachmentArgs;
import com.pulumi.alicloud.ecs.inputs.EcsKeyPairAttachmentState;
import com.pulumi.core.Output;
import com.pulumi.core.annotations.Export;
import com.pulumi.core.annotations.ResourceType;
import com.pulumi.core.internal.Codegen;
import java.lang.Boolean;
import java.lang.String;
import java.util.List;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Provides a ECS Key Pair Attachment resource.
 * 
 * For information about ECS Key Pair Attachment and how to use it, see [What is Key Pair Attachment](https://www.alibabacloud.com/help/en/doc-detail/51775.htm).
 * 
 * > **NOTE:** Available since v1.121.0+.
 * 
 * ## Example Usage
 * 
 * Basic Usage
 * 
 * <!--Start PulumiCodeChooser -->
 * 
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.alicloud.AlicloudFunctions;
 * import com.pulumi.alicloud.inputs.GetZonesArgs;
 * import com.pulumi.alicloud.ecs.EcsFunctions;
 * import com.pulumi.alicloud.ecs.inputs.GetInstanceTypesArgs;
 * import com.pulumi.alicloud.ecs.inputs.GetImagesArgs;
 * import com.pulumi.alicloud.vpc.Network;
 * import com.pulumi.alicloud.vpc.NetworkArgs;
 * import com.pulumi.alicloud.vpc.Switch;
 * import com.pulumi.alicloud.vpc.SwitchArgs;
 * import com.pulumi.alicloud.ecs.SecurityGroup;
 * import com.pulumi.alicloud.ecs.SecurityGroupArgs;
 * import com.pulumi.alicloud.ecs.Instance;
 * import com.pulumi.alicloud.ecs.InstanceArgs;
 * import com.pulumi.random.integer;
 * import com.pulumi.random.IntegerArgs;
 * import com.pulumi.alicloud.ecs.EcsKeyPair;
 * import com.pulumi.alicloud.ecs.EcsKeyPairArgs;
 * import com.pulumi.alicloud.ecs.EcsKeyPairAttachment;
 * import com.pulumi.alicloud.ecs.EcsKeyPairAttachmentArgs;
 * import java.util.List;
 * import java.util.ArrayList;
 * import java.util.Map;
 * import java.io.File;
 * import java.nio.file.Files;
 * import java.nio.file.Paths;
 * 
 * public class App {
 *     public static void main(String[] args) {
 *         Pulumi.run(App::stack);
 *     }
 * 
 *     public static void stack(Context ctx) {
 *         final var example = AlicloudFunctions.getZones(GetZonesArgs.builder()
 *             .availableResourceCreation("Instance")
 *             .build());
 * 
 *         final var exampleGetInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder()
 *             .availabilityZone(example.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
 *             .cpuCoreCount(1)
 *             .memorySize(2)
 *             .build());
 * 
 *         final var exampleGetImages = EcsFunctions.getImages(GetImagesArgs.builder()
 *             .nameRegex("^ubuntu_18.*64")
 *             .owners("system")
 *             .build());
 * 
 *         var exampleNetwork = new Network("exampleNetwork", NetworkArgs.builder()
 *             .vpcName("terraform-example")
 *             .cidrBlock("172.17.3.0/24")
 *             .build());
 * 
 *         var exampleSwitch = new Switch("exampleSwitch", SwitchArgs.builder()
 *             .vswitchName("terraform-example")
 *             .cidrBlock("172.17.3.0/24")
 *             .vpcId(exampleNetwork.id())
 *             .zoneId(example.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
 *             .build());
 * 
 *         var exampleSecurityGroup = new SecurityGroup("exampleSecurityGroup", SecurityGroupArgs.builder()
 *             .name("terraform-example")
 *             .vpcId(exampleNetwork.id())
 *             .build());
 * 
 *         var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder()
 *             .imageId(exampleGetImages.applyValue(getImagesResult -> getImagesResult.images()[0].id()))
 *             .instanceType(exampleGetInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id()))
 *             .availabilityZone(example.applyValue(getZonesResult -> getZonesResult.zones()[0].id()))
 *             .securityGroups(exampleSecurityGroup.id())
 *             .instanceName("terraform-example")
 *             .internetChargeType("PayByBandwidth")
 *             .vswitchId(exampleSwitch.id())
 *             .build());
 * 
 *         var default_ = new Integer("default", IntegerArgs.builder()
 *             .min(10000)
 *             .max(99999)
 *             .build());
 * 
 *         var exampleEcsKeyPair = new EcsKeyPair("exampleEcsKeyPair", EcsKeyPairArgs.builder()
 *             .keyPairName(String.format("tf-example-%s", default_.result()))
 *             .build());
 * 
 *         var exampleEcsKeyPairAttachment = new EcsKeyPairAttachment("exampleEcsKeyPairAttachment", EcsKeyPairAttachmentArgs.builder()
 *             .keyPairName(exampleEcsKeyPair.keyPairName())
 *             .instanceIds(exampleInstance.id())
 *             .build());
 * 
 *     }
 * }
 * }
 * 
* <!--End PulumiCodeChooser --> * * ## Import * * ECS Key Pair Attachment can be imported using the id, e.g. * * ```sh * $ pulumi import alicloud:ecs/ecsKeyPairAttachment:EcsKeyPairAttachment example <key_pair_name>:<instance_ids> * ``` * */ @ResourceType(type="alicloud:ecs/ecsKeyPairAttachment:EcsKeyPairAttachment") public class EcsKeyPairAttachment extends com.pulumi.resources.CustomResource { /** * Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately. * */ @Export(name="force", refs={Boolean.class}, tree="[0]") private Output force; /** * @return Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately. * */ public Output> force() { return Codegen.optional(this.force); } /** * The list of ECS instance's IDs. * */ @Export(name="instanceIds", refs={List.class,String.class}, tree="[0,1]") private Output> instanceIds; /** * @return The list of ECS instance's IDs. * */ public Output> instanceIds() { return this.instanceIds; } /** * New field 'key_pair_name' instead. * * @deprecated * Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead. * */ @Deprecated /* Field 'key_name' has been deprecated from provider version 1.121.0. New field 'key_pair_name' instead. */ @Export(name="keyName", refs={String.class}, tree="[0]") private Output keyName; /** * @return New field 'key_pair_name' instead. * */ public Output keyName() { return this.keyName; } /** * The name of key pair used to bind. * */ @Export(name="keyPairName", refs={String.class}, tree="[0]") private Output keyPairName; /** * @return The name of key pair used to bind. * */ public Output keyPairName() { return this.keyPairName; } /** * * @param name The _unique_ name of the resulting resource. */ public EcsKeyPairAttachment(java.lang.String name) { this(name, EcsKeyPairAttachmentArgs.Empty); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. */ public EcsKeyPairAttachment(java.lang.String name, EcsKeyPairAttachmentArgs args) { this(name, args, null); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. * @param options A bag of options that control this resource's behavior. */ public EcsKeyPairAttachment(java.lang.String name, EcsKeyPairAttachmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("alicloud:ecs/ecsKeyPairAttachment:EcsKeyPairAttachment", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); } private EcsKeyPairAttachment(java.lang.String name, Output id, @Nullable EcsKeyPairAttachmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("alicloud:ecs/ecsKeyPairAttachment:EcsKeyPairAttachment", name, state, makeResourceOptions(options, id), false); } private static EcsKeyPairAttachmentArgs makeArgs(EcsKeyPairAttachmentArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { if (options != null && options.getUrn().isPresent()) { return null; } return args == null ? EcsKeyPairAttachmentArgs.Empty : args; } private static com.pulumi.resources.CustomResourceOptions makeResourceOptions(@Nullable com.pulumi.resources.CustomResourceOptions options, @Nullable Output id) { var defaultOptions = com.pulumi.resources.CustomResourceOptions.builder() .version(Utilities.getVersion()) .build(); return com.pulumi.resources.CustomResourceOptions.merge(defaultOptions, options, id); } /** * Get an existing Host resource's state with the given name, ID, and optional extra * properties used to qualify the lookup. * * @param name The _unique_ name of the resulting resource. * @param id The _unique_ provider ID of the resource to lookup. * @param state * @param options Optional settings to control the behavior of the CustomResource. */ public static EcsKeyPairAttachment get(java.lang.String name, Output id, @Nullable EcsKeyPairAttachmentState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { return new EcsKeyPairAttachment(name, id, state, options); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy