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

com.pulumi.aws.ec2.KeyPair Maven / Gradle / Ivy

// *** 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.aws.ec2;

import com.pulumi.aws.Utilities;
import com.pulumi.aws.ec2.KeyPairArgs;
import com.pulumi.aws.ec2.inputs.KeyPairState;
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.String;
import java.util.Map;
import java.util.Optional;
import javax.annotation.Nullable;

/**
 * Provides an [EC2 key pair](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html) resource. A key pair is used to control login access to EC2 instances.
 * 
 * Currently this resource requires an existing user-supplied key pair. This key pair's public key will be registered with AWS to allow logging-in to EC2 instances.
 * 
 * When importing an existing key pair the public key material may be in any format supported by AWS. Supported formats (per the [AWS documentation](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-key-pairs.html#how-to-generate-your-own-key-and-import-it-to-aws)) are:
 * 
 * * OpenSSH public key format (the format in ~/.ssh/authorized_keys)
 * * Base64 encoded DER format
 * * SSH public key file format as specified in RFC4716
 * 
 * ## Example Usage
 * 
 * <!--Start PulumiCodeChooser -->
 * 
 * {@code
 * package generated_program;
 * 
 * import com.pulumi.Context;
 * import com.pulumi.Pulumi;
 * import com.pulumi.core.Output;
 * import com.pulumi.aws.ec2.KeyPair;
 * import com.pulumi.aws.ec2.KeyPairArgs;
 * 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 }{{@code
 *     public static void main(String[] args) }{{@code
 *         Pulumi.run(App::stack);
 *     }}{@code
 * 
 *     public static void stack(Context ctx) }{{@code
 *         var deployer = new KeyPair("deployer", KeyPairArgs.builder()
 *             .keyName("deployer-key")
 *             .publicKey("ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3F6tyPEFEzV0LX3X8BsXdMsQz1x2cEikKDEY0aIj41qgxMCP/iteneqXSIFZBp5vizPvaoIR3Um9xK7PGoW8giupGn+EPuxIA4cDM4vzOqOkiMPhz5XK0whEjkVzTo4+S0puvDZuwIsdiW9mxhJc7tgBNL0cYlWSYVkz4G/fslNfRPW5mYAM49f4fhtxPb5ok4Q2Lg9dPKVHO/Bgeu5woMc7RY0p1ej6D4CKFE6lymSDJpW0YHX/wqE9+cfEauh7xZcG0q9t2ta6F6fmX0agvpFyZo8aFbXeUBr7osSCJNgvavWbM/06niWrOvYX2xwWdhXmXSrbX8ZbabVohBK41 email}{@literal @}{@code example.com")
 *             .build());
 * 
 *     }}{@code
 * }}{@code
 * }
 * 
* <!--End PulumiCodeChooser --> * * ## Import * * Using `pulumi import`, import Key Pairs using the `key_name`. For example: * * ```sh * $ pulumi import aws:ec2/keyPair:KeyPair deployer deployer-key * ``` * ~> __NOTE:__ The AWS API does not include the public key in the response, so `pulumi up` will attempt to replace the key pair. There is currently no supported workaround for this limitation. * */ @ResourceType(type="aws:ec2/keyPair:KeyPair") public class KeyPair extends com.pulumi.resources.CustomResource { /** * The key pair ARN. * */ @Export(name="arn", refs={String.class}, tree="[0]") private Output arn; /** * @return The key pair ARN. * */ public Output arn() { return this.arn; } /** * The MD5 public key fingerprint as specified in section 4 of RFC 4716. * */ @Export(name="fingerprint", refs={String.class}, tree="[0]") private Output fingerprint; /** * @return The MD5 public key fingerprint as specified in section 4 of RFC 4716. * */ public Output fingerprint() { return this.fingerprint; } /** * The name for the key pair. If neither `key_name` nor `key_name_prefix` is provided, the provider will create a unique key name. * */ @Export(name="keyName", refs={String.class}, tree="[0]") private Output keyName; /** * @return The name for the key pair. If neither `key_name` nor `key_name_prefix` is provided, the provider will create a unique key name. * */ public Output keyName() { return this.keyName; } /** * Creates a unique name beginning with the specified prefix. Conflicts with `key_name`. If neither `key_name` nor `key_name_prefix` is provided, the provider will create a unique key name. * */ @Export(name="keyNamePrefix", refs={String.class}, tree="[0]") private Output keyNamePrefix; /** * @return Creates a unique name beginning with the specified prefix. Conflicts with `key_name`. If neither `key_name` nor `key_name_prefix` is provided, the provider will create a unique key name. * */ public Output keyNamePrefix() { return this.keyNamePrefix; } /** * The key pair ID. * */ @Export(name="keyPairId", refs={String.class}, tree="[0]") private Output keyPairId; /** * @return The key pair ID. * */ public Output keyPairId() { return this.keyPairId; } /** * The type of key pair. * */ @Export(name="keyType", refs={String.class}, tree="[0]") private Output keyType; /** * @return The type of key pair. * */ public Output keyType() { return this.keyType; } /** * The public key material. * */ @Export(name="publicKey", refs={String.class}, tree="[0]") private Output publicKey; /** * @return The public key material. * */ public Output publicKey() { return this.publicKey; } /** * Key-value map of resource tags. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. * */ @Export(name="tags", refs={Map.class,String.class}, tree="[0,1,1]") private Output> tags; /** * @return Key-value map of resource tags. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the provider-level. * */ public Output>> tags() { return Codegen.optional(this.tags); } /** * A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block. * * @deprecated * Please use `tags` instead. * */ @Deprecated /* Please use `tags` instead. */ @Export(name="tagsAll", refs={Map.class,String.class}, tree="[0,1,1]") private Output> tagsAll; /** * @return A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block. * */ public Output> tagsAll() { return this.tagsAll; } /** * * @param name The _unique_ name of the resulting resource. */ public KeyPair(java.lang.String name) { this(name, KeyPairArgs.Empty); } /** * * @param name The _unique_ name of the resulting resource. * @param args The arguments to use to populate this resource's properties. */ public KeyPair(java.lang.String name, KeyPairArgs 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 KeyPair(java.lang.String name, KeyPairArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("aws:ec2/keyPair:KeyPair", name, makeArgs(args, options), makeResourceOptions(options, Codegen.empty()), false); } private KeyPair(java.lang.String name, Output id, @Nullable KeyPairState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { super("aws:ec2/keyPair:KeyPair", name, state, makeResourceOptions(options, id), false); } private static KeyPairArgs makeArgs(KeyPairArgs args, @Nullable com.pulumi.resources.CustomResourceOptions options) { if (options != null && options.getUrn().isPresent()) { return null; } return args == null ? KeyPairArgs.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 KeyPair get(java.lang.String name, Output id, @Nullable KeyPairState state, @Nullable com.pulumi.resources.CustomResourceOptions options) { return new KeyPair(name, id, state, options); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy