Class AccessKey


  • public class AccessKey
    extends com.pulumi.resources.CustomResource
    Provides an IAM access key. This is a set of credentials that allow API requests to be made as an IAM user. ## Example Usage
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.iam.User;
     import com.pulumi.aws.iam.UserArgs;
     import com.pulumi.aws.iam.AccessKey;
     import com.pulumi.aws.iam.AccessKeyArgs;
     import com.pulumi.aws.iam.IamFunctions;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentArgs;
     import com.pulumi.aws.iam.inputs.GetPolicyDocumentStatementArgs;
     import com.pulumi.aws.iam.UserPolicy;
     import com.pulumi.aws.iam.UserPolicyArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     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) {
             var lbUser = new User("lbUser", UserArgs.builder()
                 .name("loadbalancer")
                 .path("/system/")
                 .build());
     
             var lb = new AccessKey("lb", AccessKeyArgs.builder()
                 .user(lbUser.name())
                 .pgpKey("keybase:some_person_that_exists")
                 .build());
     
             final var lbRo = IamFunctions.getPolicyDocument(GetPolicyDocumentArgs.builder()
                 .statements(GetPolicyDocumentStatementArgs.builder()
                     .effect("Allow")
                     .actions("ec2:Describe*")
                     .resources("*")
                     .build())
                 .build());
     
             var lbRoUserPolicy = new UserPolicy("lbRoUserPolicy", UserPolicyArgs.builder()
                 .name("test")
                 .user(lbUser.name())
                 .policy(lbRo.json())
                 .build());
     
             ctx.export("secret", lb.encryptedSecret());
         }
     }
     
     
     
     package generated_program;
     
     import com.pulumi.Context;
     import com.pulumi.Pulumi;
     import com.pulumi.core.Output;
     import com.pulumi.aws.iam.User;
     import com.pulumi.aws.iam.UserArgs;
     import com.pulumi.aws.iam.AccessKey;
     import com.pulumi.aws.iam.AccessKeyArgs;
     import java.util.ArrayList;
     import java.util.Arrays;
     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) {
             var test = new User("test", UserArgs.builder()
                 .name("test")
                 .path("/test/")
                 .build());
     
             var testAccessKey = new AccessKey("testAccessKey", AccessKeyArgs.builder()
                 .user(test.name())
                 .build());
     
             ctx.export("awsIamSmtpPasswordV4", testAccessKey.sesSmtpPasswordV4());
         }
     }
     
     
    ## Import ### Identity Schema #### Required * `id` - (String) Access key ID. #### Optional * `accountId` (String) AWS Account where this resource is managed. Using `pulumi import`, import IAM Access Keys using the identifier. For example: ```sh $ pulumi import aws:iam/accessKey:AccessKey example AKIA1234567890 ``` Resource attributes such as `encryptedSecret`, `keyFingerprint`, `pgpKey`, `secret`, `sesSmtpPasswordV4`, and `encryptedSesSmtpPasswordV4` are not available for imported resources as this information cannot be read from the IAM API.
    • 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
    • Constructor Summary

      Constructors 
      Constructor Description
      AccessKey​(java.lang.String name)  
      AccessKey​(java.lang.String name, AccessKeyArgs args)  
      AccessKey​(java.lang.String name, AccessKeyArgs args, com.pulumi.resources.CustomResourceOptions options)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      com.pulumi.core.Output<java.lang.String> createDate()  
      com.pulumi.core.Output<java.lang.String> encryptedSecret()  
      com.pulumi.core.Output<java.lang.String> encryptedSesSmtpPasswordV4()  
      static AccessKey get​(java.lang.String name, com.pulumi.core.Output<java.lang.String> id, AccessKeyState 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.lang.String> keyFingerprint()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> pgpKey()  
      com.pulumi.core.Output<java.lang.String> secret()  
      com.pulumi.core.Output<java.lang.String> sesSmtpPasswordV4()  
      com.pulumi.core.Output<java.util.Optional<java.lang.String>> status()  
      com.pulumi.core.Output<java.lang.String> user()  
      • 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

      • AccessKey

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

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

        public AccessKey​(java.lang.String name,
                         AccessKeyArgs 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

      • createDate

        public com.pulumi.core.Output<java.lang.String> createDate()
        Returns:
        Date and time in [RFC3339 format](https://tools.ietf.org/html/rfc3339#section-5.8) that the access key was created.
      • encryptedSecret

        public com.pulumi.core.Output<java.lang.String> encryptedSecret()
        Returns:
        Encrypted secret, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted secret may be decrypted using the command line.
      • encryptedSesSmtpPasswordV4

        public com.pulumi.core.Output<java.lang.String> encryptedSesSmtpPasswordV4()
        Returns:
        Encrypted SES SMTP password, base64 encoded, if `pgpKey` was specified. This attribute is not available for imported resources. The encrypted password may be decrypted using the command line.
      • keyFingerprint

        public com.pulumi.core.Output<java.lang.String> keyFingerprint()
        Returns:
        Fingerprint of the PGP key used to encrypt the secret. This attribute is not available for imported resources.
      • pgpKey

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> pgpKey()
        Returns:
        Either a base-64 encoded PGP public key, or a keybase username in the form `keybase:some_person_that_exists`, for use in the `encryptedSecret` output attribute. If providing a base-64 encoded PGP public key, make sure to provide the "raw" version and not the "armored" one (e.g. avoid passing the `-a` option to `gpg --export`).
      • secret

        public com.pulumi.core.Output<java.lang.String> secret()
        Returns:
        Secret access key. This attribute is not available for imported resources. Note that this will be written to the state file. If you use this, please protect your backend state file judiciously. Alternatively, you may supply a `pgpKey` instead, which will prevent the secret from being stored in plaintext, at the cost of preventing the use of the secret key in automation.
      • sesSmtpPasswordV4

        public com.pulumi.core.Output<java.lang.String> sesSmtpPasswordV4()
        Returns:
        Secret access key converted into an SES SMTP password by applying [AWS's documented Sigv4 conversion algorithm](https://docs.aws.amazon.com/ses/latest/DeveloperGuide/smtp-credentials.html#smtp-credentials-convert). This attribute is not available for imported resources. As SigV4 is region specific, valid Provider regions are `ap-south-1`, `ap-southeast-2`, `eu-central-1`, `eu-west-1`, `us-east-1` and `us-west-2`. See current [AWS SES regions](https://docs.aws.amazon.com/general/latest/gr/rande.html#ses_region).
      • status

        public com.pulumi.core.Output<java.util.Optional<java.lang.String>> status()
        Returns:
        Access key status to apply. Defaults to `Active`. Valid values are `Active` and `Inactive`.
      • user

        public com.pulumi.core.Output<java.lang.String> user()
        Returns:
        IAM user to associate with this access key.
      • get

        public static AccessKey get​(java.lang.String name,
                                    com.pulumi.core.Output<java.lang.String> id,
                                    @Nullable
                                    AccessKeyState 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.