api_op_GetAccessKeyInfo.go (4047B)
1 // Code generated by smithy-go-codegen DO NOT EDIT. 2 3 package sts 4 5 import ( 6 "context" 7 8 "github.com/aws/smithy-go/middleware" 9 ) 10 11 // Returns the account identifier for the specified access key ID. 12 // 13 // Access keys consist of two parts: an access key ID (for example, 14 // AKIAIOSFODNN7EXAMPLE ) and a secret access key (for example, 15 // wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY ). For more information about access 16 // keys, see [Managing Access Keys for IAM Users]in the IAM User Guide. 17 // 18 // When you pass an access key ID to this operation, it returns the ID of the 19 // Amazon Web Services account to which the keys belong. Access key IDs beginning 20 // with AKIA are long-term credentials for an IAM user or the Amazon Web Services 21 // account root user. Access key IDs beginning with ASIA are temporary credentials 22 // that are created using STS operations. If the account in the response belongs to 23 // you, you can sign in as the root user and review your root user access keys. 24 // Then, you can pull a [credentials report]to learn which IAM user owns the keys. To learn who 25 // requested the temporary credentials for an ASIA access key, view the STS events 26 // in your [CloudTrail logs]in the IAM User Guide. 27 // 28 // This operation does not indicate the state of the access key. The key might be 29 // active, inactive, or deleted. Active keys might not have permissions to perform 30 // an operation. Providing a deleted access key might return an error that the key 31 // doesn't exist. 32 // 33 // [credentials report]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_getting-report.html 34 // [CloudTrail logs]: https://docs.aws.amazon.com/IAM/latest/UserGuide/cloudtrail-integration.html 35 // [Managing Access Keys for IAM Users]: https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_access-keys.html 36 func (c *Client) GetAccessKeyInfo(ctx context.Context, params *GetAccessKeyInfoInput, optFns ...func(*Options)) (*GetAccessKeyInfoOutput, error) { 37 if params == nil { 38 params = &GetAccessKeyInfoInput{} 39 } 40 41 result, metadata, err := c.invokeOperation(ctx, "GetAccessKeyInfo", params, optFns, c.addOperationGetAccessKeyInfoMiddlewares) 42 if err != nil { 43 return nil, err 44 } 45 46 out := result.(*GetAccessKeyInfoOutput) 47 out.ResultMetadata = metadata 48 return out, nil 49 } 50 51 type GetAccessKeyInfoInput struct { 52 53 // The identifier of an access key. 54 // 55 // This parameter allows (through its regex pattern) a string of characters that 56 // can consist of any upper- or lowercase letter or digit. 57 // 58 // This member is required. 59 AccessKeyId *string 60 61 noSmithyDocumentSerde 62 } 63 64 type GetAccessKeyInfoOutput struct { 65 66 // The number used to identify the Amazon Web Services account. 67 Account *string 68 69 // Metadata pertaining to the operation's result. 70 ResultMetadata middleware.Metadata 71 72 noSmithyDocumentSerde 73 } 74 75 func (c *Client) addOperationGetAccessKeyInfoMiddlewares(stack *middleware.Stack, options Options) (err error) { 76 err = stack.Serialize.Add(&awsAwsquery_serializeOpGetAccessKeyInfo{}, middleware.After) 77 if err != nil { 78 return err 79 } 80 err = stack.Deserialize.Add(&awsAwsquery_deserializeOpGetAccessKeyInfo{}, middleware.After) 81 if err != nil { 82 return err 83 } 84 85 if err = addComputeContentLength(stack); err != nil { 86 return err 87 } 88 if err = addResolveEndpointMiddleware(stack, options); err != nil { 89 return err 90 } 91 if err = addComputePayloadSHA256(stack); err != nil { 92 return err 93 } 94 if err = addRecordResponseTiming(stack, options); err != nil { 95 return err 96 } 97 if err = addCredentialSource(stack, options); err != nil { 98 return err 99 } 100 if err = addOpGetAccessKeyInfoValidationMiddleware(stack); err != nil { 101 return err 102 } 103 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 104 return err 105 } 106 if err = addResponseErrorMiddleware(stack); err != nil { 107 return err 108 } 109 if err = addRequestResponseLogging(stack, options); err != nil { 110 return err 111 } 112 if err = addDisableHTTPSMiddleware(stack, options); err != nil { 113 return err 114 } 115 if err = addInterceptors(stack, options); err != nil { 116 return err 117 } 118 return nil 119 }