1// Code generated by smithy-go-codegen DO NOT EDIT. 2 3package ec2 4 5import ( 6 "context" 7 awsmiddleware "github.com/aws/aws-sdk-go-v2/aws/middleware" 8 "github.com/aws/aws-sdk-go-v2/aws/signer/v4" 9 "github.com/aws/aws-sdk-go-v2/service/ec2/types" 10 "github.com/aws/smithy-go/middleware" 11 smithyhttp "github.com/aws/smithy-go/transport/http" 12) 13 14// Modify the instance metadata parameters on a running or stopped instance. When 15// you modify the parameters on a stopped instance, they are applied when the 16// instance is started. When you modify the parameters on a running instance, the 17// API responds with a state of “pending”. After the parameter modifications are 18// successfully applied to the instance, the state of the modifications changes 19// from “pending” to “applied” in subsequent describe-instances API calls. For more 20// information, see Instance metadata and user data 21// (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-metadata.html) 22// in the Amazon EC2 User Guide. 23func (c *Client) ModifyInstanceMetadataOptions(ctx context.Context, params *ModifyInstanceMetadataOptionsInput, optFns ...func(*Options)) (*ModifyInstanceMetadataOptionsOutput, error) { 24 if params == nil { 25 params = &ModifyInstanceMetadataOptionsInput{} 26 } 27 28 result, metadata, err := c.invokeOperation(ctx, "ModifyInstanceMetadataOptions", params, optFns, addOperationModifyInstanceMetadataOptionsMiddlewares) 29 if err != nil { 30 return nil, err 31 } 32 33 out := result.(*ModifyInstanceMetadataOptionsOutput) 34 out.ResultMetadata = metadata 35 return out, nil 36} 37 38type ModifyInstanceMetadataOptionsInput struct { 39 40 // The ID of the instance. 41 // 42 // This member is required. 43 InstanceId *string 44 45 // Checks whether you have the required permissions for the action, without 46 // actually making the request, and provides an error response. If you have the 47 // required permissions, the error response is DryRunOperation. Otherwise, it is 48 // UnauthorizedOperation. 49 DryRun bool 50 51 // This parameter enables or disables the HTTP metadata endpoint on your instances. 52 // If the parameter is not specified, the existing state is maintained. If you 53 // specify a value of disabled, you will not be able to access your instance 54 // metadata. 55 HttpEndpoint types.InstanceMetadataEndpointState 56 57 // The desired HTTP PUT response hop limit for instance metadata requests. The 58 // larger the number, the further instance metadata requests can travel. If no 59 // parameter is specified, the existing state is maintained. Possible values: 60 // Integers from 1 to 64 61 HttpPutResponseHopLimit int32 62 63 // The state of token usage for your instance metadata requests. If the parameter 64 // is not specified in the request, the default state is optional. If the state is 65 // optional, you can choose to retrieve instance metadata with or without a signed 66 // token header on your request. If you retrieve the IAM role credentials without a 67 // token, the version 1.0 role credentials are returned. If you retrieve the IAM 68 // role credentials using a valid signed token, the version 2.0 role credentials 69 // are returned. If the state is required, you must send a signed token header with 70 // any instance metadata retrieval requests. In this state, retrieving the IAM role 71 // credential always returns the version 2.0 credentials; the version 1.0 72 // credentials are not available. 73 HttpTokens types.HttpTokensState 74} 75 76type ModifyInstanceMetadataOptionsOutput struct { 77 78 // The ID of the instance. 79 InstanceId *string 80 81 // The metadata options for the instance. 82 InstanceMetadataOptions *types.InstanceMetadataOptionsResponse 83 84 // Metadata pertaining to the operation's result. 85 ResultMetadata middleware.Metadata 86} 87 88func addOperationModifyInstanceMetadataOptionsMiddlewares(stack *middleware.Stack, options Options) (err error) { 89 err = stack.Serialize.Add(&awsEc2query_serializeOpModifyInstanceMetadataOptions{}, middleware.After) 90 if err != nil { 91 return err 92 } 93 err = stack.Deserialize.Add(&awsEc2query_deserializeOpModifyInstanceMetadataOptions{}, middleware.After) 94 if err != nil { 95 return err 96 } 97 if err = addSetLoggerMiddleware(stack, options); err != nil { 98 return err 99 } 100 if err = awsmiddleware.AddClientRequestIDMiddleware(stack); err != nil { 101 return err 102 } 103 if err = smithyhttp.AddComputeContentLengthMiddleware(stack); err != nil { 104 return err 105 } 106 if err = addResolveEndpointMiddleware(stack, options); err != nil { 107 return err 108 } 109 if err = v4.AddComputePayloadSHA256Middleware(stack); err != nil { 110 return err 111 } 112 if err = addRetryMiddlewares(stack, options); err != nil { 113 return err 114 } 115 if err = addHTTPSignerV4Middleware(stack, options); err != nil { 116 return err 117 } 118 if err = awsmiddleware.AddRawResponseToMetadata(stack); err != nil { 119 return err 120 } 121 if err = awsmiddleware.AddRecordResponseTiming(stack); err != nil { 122 return err 123 } 124 if err = addClientUserAgent(stack); err != nil { 125 return err 126 } 127 if err = smithyhttp.AddErrorCloseResponseBodyMiddleware(stack); err != nil { 128 return err 129 } 130 if err = smithyhttp.AddCloseResponseBodyMiddleware(stack); err != nil { 131 return err 132 } 133 if err = addOpModifyInstanceMetadataOptionsValidationMiddleware(stack); err != nil { 134 return err 135 } 136 if err = stack.Initialize.Add(newServiceMetadataMiddleware_opModifyInstanceMetadataOptions(options.Region), middleware.Before); err != nil { 137 return err 138 } 139 if err = addRequestIDRetrieverMiddleware(stack); err != nil { 140 return err 141 } 142 if err = addResponseErrorMiddleware(stack); err != nil { 143 return err 144 } 145 if err = addRequestResponseLogging(stack, options); err != nil { 146 return err 147 } 148 return nil 149} 150 151func newServiceMetadataMiddleware_opModifyInstanceMetadataOptions(region string) *awsmiddleware.RegisterServiceMetadata { 152 return &awsmiddleware.RegisterServiceMetadata{ 153 Region: region, 154 ServiceID: ServiceID, 155 SigningName: "ec2", 156 OperationName: "ModifyInstanceMetadataOptions", 157 } 158} 159