Class EcsKeyPairAttachment


  • public class EcsKeyPairAttachment
    extends com.pulumi.resources.CustomResource
    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 ```java 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.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 exampleZones = AlicloudFunctions.getZones(GetZonesArgs.builder() .availableResourceCreation("Instance") .build()); final var exampleInstanceTypes = EcsFunctions.getInstanceTypes(GetInstanceTypesArgs.builder() .availabilityZone(exampleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id())) .cpuCoreCount(1) .memorySize(2) .build()); final var exampleImages = EcsFunctions.getImages(GetImagesArgs.builder() .nameRegex("^ubuntu_[0-9]+_[0-9]+_x64*") .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(exampleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id())) .build()); var exampleSecurityGroup = new SecurityGroup("exampleSecurityGroup", SecurityGroupArgs.builder() .vpcId(exampleNetwork.id()) .build()); var exampleInstance = new Instance("exampleInstance", InstanceArgs.builder() .imageId(exampleImages.applyValue(getImagesResult -> getImagesResult.images()[0].id())) .instanceType(exampleInstanceTypes.applyValue(getInstanceTypesResult -> getInstanceTypesResult.instanceTypes()[0].id())) .availabilityZone(exampleZones.applyValue(getZonesResult -> getZonesResult.zones()[0].id())) .securityGroups(exampleSecurityGroup.id()) .instanceName("terraform-example") .internetChargeType("PayByBandwidth") .vswitchId(exampleSwitch.id()) .build()); var exampleEcsKeyPair = new EcsKeyPair("exampleEcsKeyPair", EcsKeyPairArgs.builder() .keyPairName("tf-example") .build()); var exampleEcsKeyPairAttachment = new EcsKeyPairAttachment("exampleEcsKeyPairAttachment", EcsKeyPairAttachmentArgs.builder() .keyPairName(exampleEcsKeyPair.keyPairName()) .instanceIds(exampleInstance.id()) .build()); } } ``` ## 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> ```
    • Nested Class Summary

      • Nested classes/interfaces inherited from class com.pulumi.resources.CustomResource

        com.pulumi.resources.CustomResource.CustomResourceInternal
      • Nested classes/interfaces inherited from class com.pulumi.resources.Resource

        com.pulumi.resources.Resource.LazyField<T extends java.lang.Object>, com.pulumi.resources.Resource.LazyFields, com.pulumi.resources.Resource.ResourceInternal
    • Field Summary

      • Fields inherited from class com.pulumi.resources.Resource

        childResources, remote
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> force()  
      static EcsKeyPairAttachment get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, EcsKeyPairAttachmentState state, com.pulumi.resources.CustomResourceOptions options)
      Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
      com.pulumi.core.Output<java.util.List<java.lang.String>> instanceIds()  
      com.pulumi.core.Output<java.lang.String> keyName()  
      com.pulumi.core.Output<java.lang.String> keyPairName()  
      • Methods inherited from class com.pulumi.resources.CustomResource

        getId, id, idFuture
      • Methods inherited from class com.pulumi.resources.Resource

        getChildResources, getResourceName, getResourceType, getUrn, pulumiChildResources, pulumiResourceName, pulumiResourceType, urn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • EcsKeyPairAttachment

        public EcsKeyPairAttachment​(java.lang.String name)
        Parameters:
        name - The _unique_ name of the resulting resource.
      • EcsKeyPairAttachment

        public EcsKeyPairAttachment​(java.lang.String name,
                                    EcsKeyPairAttachmentArgs args)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
      • EcsKeyPairAttachment

        public EcsKeyPairAttachment​(java.lang.String name,
                                    EcsKeyPairAttachmentArgs args,
                                    @Nullable
                                    com.pulumi.resources.CustomResourceOptions options)
        Parameters:
        name - The _unique_ name of the resulting resource.
        args - The arguments to use to populate this resource's properties.
        options - A bag of options that control this resource's behavior.
    • Method Detail

      • force

        public com.pulumi.core.Output<java.util.Optional<java.lang.Boolean>> force()
        Returns:
        Set it to true and it will reboot instances which attached with the key pair to make key pair affect immediately.
      • instanceIds

        public com.pulumi.core.Output<java.util.List<java.lang.String>> instanceIds()
        Returns:
        The list of ECS instance's IDs.
      • keyName

        public com.pulumi.core.Output<java.lang.String> keyName()
        Returns:
        New field 'key_pair_name' instead.
      • keyPairName

        public com.pulumi.core.Output<java.lang.String> keyPairName()
        Returns:
        The name of key pair used to bind.
      • get

        public static EcsKeyPairAttachment get​(java.lang.String name,
                                               com.pulumi.core.Output<java.lang.String> id,
                                               @Nullable
                                               EcsKeyPairAttachmentState state,
                                               @Nullable
                                               com.pulumi.resources.CustomResourceOptions options)
        Get an existing Host resource's state with the given name, ID, and optional extra properties used to qualify the lookup.
        Parameters:
        name - The _unique_ name of the resulting resource.
        id - The _unique_ provider ID of the resource to lookup.
        state -
        options - Optional settings to control the behavior of the CustomResource.